diff --git a/.cspell.json b/.cspell.json index 8038e73fbb..71ced17ccf 100644 --- a/.cspell.json +++ b/.cspell.json @@ -2,28 +2,47 @@ "version": "0.2", "language": "en", "words": [ + "ACCESSS", "AQUASECURITY", "AUTOBUILD", "BUILDX", + "Burstable", "Capi", + "Errorf", "FAISS", "GHACTION", "GOLANGCILINT", + "GOMAXPROCS", + "Godoc", + "Infof", "KUBELINTER", "LANGUAGETOOL", + "Milli", + "ONNX", "OTEL", "PROTOBUF", "REVIEWDOG", + "Roundtripper", "SARIF", "SOFTPROPS", + "Structs", "TELEPRESENCE", "VALD", "VALDCLI", + "VHOR", "Vald", + "Vectorizer", "accesslog", + "achive", + "addrs", + "apiserver", + "attirbute", "bbolt", + "boudary", "brandguidelines", + "buildbase", "chatops", + "chrono", "circuitbreaker", "cloudstorage", "clusterrole", @@ -32,38 +51,67 @@ "contributorsrc", "conv", "crds", + "crlfmt", + "ctxio", "daemonset", "deepsource", "devcontainer", + "devel", + "envoyproxy", "errdetails", "errgroup", + "facebookresearch", "faiss", + "fastime", + "fuid", "gache", + "getobject", "getstarted", "gitfiles", + "gofumpt", + "goimports", "golangci", "goleak", + "golines", "gongt", + "gonum", "gorules", + "gotest", + "gotests", "gotmpl", "hadolint", "helmignore", + "httputil", + "icfg", "initcontainer", + "innerproduct", + "ioutil", "jaccard", "japansearch", "kosarak", + "kpango", "kubelinter", "kustomization", "kvsdb", + "libhdf", + "loadbalancer", "loadtest", "lycorp", + "maxprocs", "minio", "mnist", "multiapis", "multicluster", + "nanos", + "nbits", "networkpolicy", + "nlist", + "normalizedangle", + "normalizedcosine", "nosql", "nytimes", + "oneof", + "onnx", "otel", "otlp", "pogreb", @@ -72,17 +120,33 @@ "priorityclass", "profefe", "promtail", + "prost", "protobuf", + "protoc", + "protos", "pyroscope", "readreplica", + "rebalance", + "rebalancing", + "replicasets", + "rerank", + "retrive", "reviewdog", + "rustc", + "rustup", "serviceaccount", "singleflight", "statefulset", + "steamsearch", + "streaminsert", + "structs", + "subtests", "testdata", "textlintrc", "timeutil", + "traefik", "upsert", + "upserted", "urlopener", "usecase", "vald", @@ -90,12 +154,22 @@ "valdbenchmarkoperatorrelease", "valdbenchmarkscenario", "valdhelmoperatorrelease", + "valdhelmopratorreleases", "valdmirrortarget", + "valdmirrortargets", "valdrelease", + "vbor", + "vdaas", "vdctl", + "vectorizer", + "vectorizing", + "vhor", "vqueue", "vtproto", + "werr", "whitesource", + "yahoojapan", + "yamlfmt", "zstd" ], "ignoreWords": [ diff --git a/.deepsource.toml b/.deepsource.toml index e8f0da1fa1..0eb01057c9 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -47,22 +47,35 @@ enabled = true [analyzers.meta] dockerfile_paths = [ - "dockers/agent/ngt/Dockerfile", - "dockers/discoverer/k8s/Dockerfile", + "dockers/agent/core/agent/Dockerfile", + "dockers/agent/core/faiss/Dockerfile", + "dockers/agent/core/ngt/Dockerfile", "dockers/agent/sidecar/Dockerfile", - "dockers/gateway/lb/Dockerfile", + "dockers/buildbase/Dockerfile", + "dockers/ci/base/Dockerfile", + "dockers/dev/Dockerfile", + "dockers/discoverer/k8s/Dockerfile", "dockers/gateway/filter/Dockerfile", + "dockers/gateway/lb/Dockerfile", + "dockers/gateway/mirror/Dockerfile", + "dockers/index/job/correction/Dockerfile", + "dockers/index/job/creation/Dockerfile", + "dockers/index/job/readreplica/rotate/Dockerfile", + "dockers/index/job/save/Dockerfile", + "dockers/index/operator/Dockerfile", "dockers/manager/index/Dockerfile", "dockers/operator/helm/Dockerfile", - "dockers/ci/base/Dockerfile", - "dockers/dev/Dockerfile", + "dockers/readreplica/job/readreplica/rotate/Dockerfile", + "dockers/tools/benchmark/job/Dockerfile", + "dockers/tools/benchmark/operator/Dockerfile", "dockers/tools/cli/loadtest/Dockerfile" ] trusted_registries = [ "docker.io", - "hub.docker.com", - "ghcr.io/vdaas/vald" + "gcr.io/distroless", + "ghcr.io/vdaas/vald", + "hub.docker.com" ] [[analyzers]] diff --git a/.gitfiles b/.gitfiles index 6389d905f6..13f61ddc34 100644 --- a/.gitfiles +++ b/.gitfiles @@ -80,6 +80,7 @@ .github/workflows/dockers-agent-sidecar-image.yml .github/workflows/dockers-benchmark-job-image.yml .github/workflows/dockers-benchmark-operator-image.yaml +.github/workflows/dockers-buildbase-image.yml .github/workflows/dockers-ci-container-image.yml .github/workflows/dockers-dev-container-image.yml .github/workflows/dockers-discoverer-k8s-image.yml @@ -161,8 +162,6 @@ apis/grpc/v1/filter/egress/egress_filter.pb.go apis/grpc/v1/filter/egress/egress_filter_vtproto.pb.go apis/grpc/v1/filter/ingress/ingress_filter.pb.go apis/grpc/v1/filter/ingress/ingress_filter_vtproto.pb.go -apis/grpc/v1/manager/index/index_manager.pb.go -apis/grpc/v1/manager/index/index_manager_vtproto.pb.go apis/grpc/v1/mirror/mirror.go apis/grpc/v1/mirror/mirror.pb.go apis/grpc/v1/mirror/mirror_vtproto.pb.go @@ -177,6 +176,8 @@ apis/grpc/v1/vald/filter.pb.go apis/grpc/v1/vald/filter_vtproto.pb.go apis/grpc/v1/vald/flush.pb.go apis/grpc/v1/vald/flush_vtproto.pb.go +apis/grpc/v1/vald/index.pb.go +apis/grpc/v1/vald/index_vtproto.pb.go apis/grpc/v1/vald/insert.pb.go apis/grpc/v1/vald/insert_vtproto.pb.go apis/grpc/v1/vald/object.pb.go @@ -197,12 +198,12 @@ apis/proto/v1/agent/sidecar/sidecar.proto apis/proto/v1/discoverer/discoverer.proto apis/proto/v1/filter/egress/egress_filter.proto apis/proto/v1/filter/ingress/ingress_filter.proto -apis/proto/v1/manager/index/index_manager.proto apis/proto/v1/mirror/mirror.proto apis/proto/v1/payload/payload.proto apis/proto/v1/rpc/errdetails/error_details.proto apis/proto/v1/vald/filter.proto apis/proto/v1/vald/flush.proto +apis/proto/v1/vald/index.proto apis/proto/v1/vald/insert.proto apis/proto/v1/vald/object.proto apis/proto/v1/vald/remove.proto @@ -214,12 +215,12 @@ apis/swagger/v1/agent/sidecar/sidecar.swagger.json apis/swagger/v1/discoverer/discoverer.swagger.json apis/swagger/v1/filter/egress/egress_filter.swagger.json apis/swagger/v1/filter/ingress/ingress_filter.swagger.json -apis/swagger/v1/manager/index/index_manager.swagger.json apis/swagger/v1/mirror/mirror.swagger.json apis/swagger/v1/payload/payload.swagger.json apis/swagger/v1/rpc/errdetails/error_details.swagger.json apis/swagger/v1/vald/filter.swagger.json apis/swagger/v1/vald/flush.swagger.json +apis/swagger/v1/vald/index.swagger.json apis/swagger/v1/vald/insert.swagger.json apis/swagger/v1/vald/object.swagger.json apis/swagger/v1/vald/remove.swagger.json @@ -228,6 +229,7 @@ apis/swagger/v1/vald/update.swagger.json apis/swagger/v1/vald/upsert.swagger.json assets/docs/guides/observability-configuration/architecture.png assets/docs/guides/operations/grafana-example.png +assets/docs/guides/read-replica-and-rotator/architecture.png assets/docs/overview/component/agent/agent.drawio assets/docs/overview/component/agent/ngt.png assets/docs/overview/component/agent/sidecar_backup.png @@ -455,6 +457,7 @@ charts/vald/values/vald-backup-via-pv.yaml charts/vald/values/vald-backup-via-s3.yaml charts/vald/values/vald-in-memory-mode-no-backup.yaml cmd/agent/core/faiss/main.go +cmd/agent/core/faiss/main_test.go cmd/agent/core/faiss/sample.yaml cmd/agent/core/ngt/main.go cmd/agent/core/ngt/main_test.go @@ -475,6 +478,7 @@ cmd/gateway/lb/main.go cmd/gateway/lb/main_test.go cmd/gateway/lb/sample.yaml cmd/gateway/mirror/main.go +cmd/gateway/mirror/main_test.go cmd/gateway/mirror/sample.yaml cmd/index/job/correction/main.go cmd/index/job/correction/main_test.go @@ -489,13 +493,16 @@ cmd/index/job/save/main.go cmd/index/job/save/main_test.go cmd/index/job/save/sample.yaml cmd/index/operator/main.go +cmd/index/operator/main_test.go cmd/index/operator/sample.yaml cmd/manager/index/main.go cmd/manager/index/main_test.go cmd/manager/index/sample.yaml cmd/tools/benchmark/job/main.go +cmd/tools/benchmark/job/main_test.go cmd/tools/benchmark/job/sample.yaml cmd/tools/benchmark/operator/main.go +cmd/tools/benchmark/operator/main_test.go cmd/tools/benchmark/operator/sample.yaml cmd/tools/cli/benchmark/core/main.go cmd/tools/cli/benchmark/core/main_test.go @@ -516,6 +523,7 @@ dockers/agent/core/ngt/Dockerfile dockers/agent/core/ngt/README.md dockers/agent/sidecar/Dockerfile dockers/agent/sidecar/README.md +dockers/buildbase/Dockerfile dockers/ci/base/Dockerfile dockers/ci/base/README.md dockers/dev/Dockerfile @@ -536,6 +544,7 @@ dockers/manager/index/Dockerfile dockers/manager/index/README.md dockers/operator/helm/Dockerfile dockers/operator/helm/README.md +dockers/readreplica/job/readreplica/rotate/Dockerfile dockers/template.md dockers/tools/benchmark/job/Dockerfile dockers/tools/benchmark/operator/Dockerfile @@ -556,6 +565,7 @@ docs/api/upsert.md docs/contributing/coding-style.md docs/contributing/contributing-guide.md docs/contributing/development.md +docs/contributing/reviewer-guideline.md docs/contributing/unit-test-guideline.md docs/overview/about-vald.md docs/overview/architecture.md @@ -571,8 +581,8 @@ docs/performance/benchmark.md docs/performance/continuous-benchmark.md docs/performance/loadtest.md docs/performance/tuning-search-performance.md +docs/support/FAQ.md docs/support/contacts.md -docs/support/faq.md docs/troubleshooting/README.md docs/troubleshooting/client-side.md docs/troubleshooting/mirror-gateway.md @@ -595,6 +605,7 @@ docs/user-guides/mirroring-configuration.md docs/user-guides/network-policy.md docs/user-guides/observability-configuration.md docs/user-guides/operations.md +docs/user-guides/read-replica-and-rotator.md docs/user-guides/sdks.md docs/user-guides/upgrade-cluster.md example/client/agent/main.go @@ -686,6 +697,7 @@ hack/benchmark/internal/starter/gateway/vald/vald_test.go hack/benchmark/internal/starter/starter.go hack/benchmark/metrics/metrics.go hack/benchmark/src/singleflight/singleflight_bench_test.go +hack/docker/gen/main.go hack/git/hooks/pre-commit hack/go.mod.default hack/gorules/rules.go @@ -746,7 +758,9 @@ internal/client/v1/client/filter/ingress/client_test.go internal/client/v1/client/filter/ingress/option.go internal/client/v1/client/filter/ingress/option_test.go internal/client/v1/client/mirror/mirror.go +internal/client/v1/client/mirror/mirror_test.go internal/client/v1/client/mirror/option.go +internal/client/v1/client/mirror/option_test.go internal/client/v1/client/vald/option.go internal/client/v1/client/vald/option_test.go internal/client/v1/client/vald/vald.go @@ -784,6 +798,7 @@ internal/config/backoff_test.go internal/config/backup.go internal/config/backup_test.go internal/config/benchmark.go +internal/config/benchmark_test.go internal/config/blob.go internal/config/blob_test.go internal/config/cassandra.go @@ -801,6 +816,7 @@ internal/config/corrector_test.go internal/config/discoverer.go internal/config/discoverer_test.go internal/config/faiss.go +internal/config/faiss_test.go internal/config/filter.go internal/config/filter_test.go internal/config/gateway.go @@ -811,6 +827,7 @@ internal/config/index.go internal/config/index_creation.go internal/config/index_creation_test.go internal/config/index_operator.go +internal/config/index_operator_test.go internal/config/index_save.go internal/config/index_save_test.go internal/config/index_test.go @@ -821,6 +838,7 @@ internal/config/log_test.go internal/config/meta.go internal/config/meta_test.go internal/config/mirror.go +internal/config/mirror_test.go internal/config/mysql.go internal/config/mysql_test.go internal/config/net.go @@ -964,6 +982,7 @@ internal/errors/errors.go internal/errors/errors_benchmark_test.go internal/errors/errors_test.go internal/errors/faiss.go +internal/errors/faiss_test.go internal/errors/file.go internal/errors/file_test.go internal/errors/filter.go @@ -1029,7 +1048,9 @@ internal/k8s/client/client_test.go internal/k8s/client/option.go internal/k8s/client/option_test.go internal/k8s/job/job.go +internal/k8s/job/job_test.go internal/k8s/job/option.go +internal/k8s/job/option_test.go internal/k8s/metrics/node/node.go internal/k8s/metrics/node/node_test.go internal/k8s/metrics/node/option.go @@ -1056,20 +1077,31 @@ internal/k8s/service/service.go internal/k8s/service/service_test.go internal/k8s/types.go internal/k8s/v2/pod/option.go +internal/k8s/v2/pod/option_test.go internal/k8s/v2/pod/pod.go +internal/k8s/v2/pod/pod_test.go internal/k8s/vald/annotations.go internal/k8s/vald/benchmark/api/v1/info.go internal/k8s/vald/benchmark/api/v1/job_types.go +internal/k8s/vald/benchmark/api/v1/job_types_test.go internal/k8s/vald/benchmark/api/v1/scenario_types.go +internal/k8s/vald/benchmark/api/v1/scenario_types_test.go internal/k8s/vald/benchmark/job/doc.go internal/k8s/vald/benchmark/job/job.go internal/k8s/vald/benchmark/job/job_template.go internal/k8s/vald/benchmark/job/job_template_option.go +internal/k8s/vald/benchmark/job/job_template_option_test.go +internal/k8s/vald/benchmark/job/job_template_test.go +internal/k8s/vald/benchmark/job/job_test.go internal/k8s/vald/benchmark/job/option.go +internal/k8s/vald/benchmark/job/option_test.go internal/k8s/vald/benchmark/scenario/doc.go internal/k8s/vald/benchmark/scenario/option.go +internal/k8s/vald/benchmark/scenario/option_test.go internal/k8s/vald/benchmark/scenario/scenario.go +internal/k8s/vald/benchmark/scenario/scenario_test.go internal/k8s/vald/mirror/api/v1/target_types.go +internal/k8s/vald/mirror/api/v1/target_types_test.go internal/k8s/vald/mirror/target/option.go internal/k8s/vald/mirror/target/target.go internal/k8s/vald/mirror/target/target_template.go @@ -1128,6 +1160,7 @@ internal/net/grpc/health/health.go internal/net/grpc/health/health_test.go internal/net/grpc/interceptor.go internal/net/grpc/interceptor/client/metric/metric.go +internal/net/grpc/interceptor/client/metric/metric_test.go internal/net/grpc/interceptor/client/trace/trace.go internal/net/grpc/interceptor/server/logging/accesslog.go internal/net/grpc/interceptor/server/logging/accesslog_test.go @@ -1141,6 +1174,7 @@ internal/net/grpc/keepalive/keepalive.go internal/net/grpc/logger/logger.go internal/net/grpc/logger/logger_test.go internal/net/grpc/metadata.go +internal/net/grpc/metadata_test.go internal/net/grpc/option.go internal/net/grpc/option_test.go internal/net/grpc/pool/option.go @@ -1200,6 +1234,7 @@ internal/observability/exporter/otlp/option_test.go internal/observability/exporter/otlp/otlp.go internal/observability/exporter/otlp/otlp_test.go internal/observability/metrics/agent/core/faiss/faiss.go +internal/observability/metrics/agent/core/faiss/faiss_test.go internal/observability/metrics/agent/core/ngt/ngt.go internal/observability/metrics/agent/core/ngt/ngt_test.go internal/observability/metrics/agent/sidecar/sidecar.go @@ -1209,6 +1244,7 @@ internal/observability/metrics/backoff/backoff_test.go internal/observability/metrics/circuitbreaker/circuitbreaker.go internal/observability/metrics/circuitbreaker/circuitbreaker_test.go internal/observability/metrics/gateway/mirror/mirror.go +internal/observability/metrics/gateway/mirror/mirror_test.go internal/observability/metrics/grpc/grpc.go internal/observability/metrics/grpc/grpc_test.go internal/observability/metrics/index/job/correction/correction.go @@ -1218,7 +1254,9 @@ internal/observability/metrics/info/info_test.go internal/observability/metrics/manager/index/index.go internal/observability/metrics/manager/index/index_test.go internal/observability/metrics/mem/index/index.go +internal/observability/metrics/mem/index/index_test.go internal/observability/metrics/mem/mem.go +internal/observability/metrics/mem/mem_test.go internal/observability/metrics/metrics.go internal/observability/metrics/metrics_test.go internal/observability/metrics/runtime/cgo/cgo.go @@ -1338,6 +1376,7 @@ internal/timeutil/location/loc_test.go internal/timeutil/location/set.go internal/timeutil/location/set_test.go internal/timeutil/rate/rate.go +internal/timeutil/rate/rate_test.go internal/timeutil/time.go internal/timeutil/time_bench_test.go internal/timeutil/time_test.go @@ -1518,31 +1557,51 @@ k8s/tools/cli/loadtest/configmap.yaml k8s/tools/cli/loadtest/cronjob.yaml k8s/tools/cli/loadtest/job.yaml pkg/agent/core/faiss/config/config.go +pkg/agent/core/faiss/config/config_test.go pkg/agent/core/faiss/handler/doc.go pkg/agent/core/faiss/handler/grpc/flush.go +pkg/agent/core/faiss/handler/grpc/flush_test.go pkg/agent/core/faiss/handler/grpc/handler.go +pkg/agent/core/faiss/handler/grpc/handler_test.go pkg/agent/core/faiss/handler/grpc/index.go +pkg/agent/core/faiss/handler/grpc/index_test.go pkg/agent/core/faiss/handler/grpc/insert.go +pkg/agent/core/faiss/handler/grpc/insert_test.go pkg/agent/core/faiss/handler/grpc/linear_search.go +pkg/agent/core/faiss/handler/grpc/linear_search_test.go pkg/agent/core/faiss/handler/grpc/object.go +pkg/agent/core/faiss/handler/grpc/object_test.go pkg/agent/core/faiss/handler/grpc/option.go +pkg/agent/core/faiss/handler/grpc/option_test.go pkg/agent/core/faiss/handler/grpc/remove.go +pkg/agent/core/faiss/handler/grpc/remove_test.go pkg/agent/core/faiss/handler/grpc/search.go +pkg/agent/core/faiss/handler/grpc/search_test.go pkg/agent/core/faiss/handler/grpc/update.go +pkg/agent/core/faiss/handler/grpc/update_test.go pkg/agent/core/faiss/handler/grpc/upsert.go +pkg/agent/core/faiss/handler/grpc/upsert_test.go pkg/agent/core/faiss/handler/rest/handler.go +pkg/agent/core/faiss/handler/rest/handler_test.go pkg/agent/core/faiss/handler/rest/option.go +pkg/agent/core/faiss/handler/rest/option_test.go pkg/agent/core/faiss/model/faiss.go pkg/agent/core/faiss/router/option.go +pkg/agent/core/faiss/router/option_test.go pkg/agent/core/faiss/router/router.go +pkg/agent/core/faiss/router/router_test.go pkg/agent/core/faiss/service/faiss.go +pkg/agent/core/faiss/service/faiss_test.go pkg/agent/core/faiss/service/option.go +pkg/agent/core/faiss/service/option_test.go pkg/agent/core/faiss/usecase/agentd.go +pkg/agent/core/faiss/usecase/agentd_test.go pkg/agent/core/ngt/README.md pkg/agent/core/ngt/config/config.go pkg/agent/core/ngt/config/config_test.go pkg/agent/core/ngt/handler/doc.go pkg/agent/core/ngt/handler/grpc/flush.go +pkg/agent/core/ngt/handler/grpc/flush_test.go pkg/agent/core/ngt/handler/grpc/handler.go pkg/agent/core/ngt/handler/grpc/handler_test.go pkg/agent/core/ngt/handler/grpc/index.go @@ -1564,7 +1623,9 @@ pkg/agent/core/ngt/handler/grpc/update_test.go pkg/agent/core/ngt/handler/grpc/upsert.go pkg/agent/core/ngt/handler/grpc/upsert_test.go pkg/agent/core/ngt/handler/rest/handler.go +pkg/agent/core/ngt/handler/rest/handler_test.go pkg/agent/core/ngt/handler/rest/option.go +pkg/agent/core/ngt/handler/rest/option_test.go pkg/agent/core/ngt/router/option.go pkg/agent/core/ngt/router/option_test.go pkg/agent/core/ngt/router/router.go @@ -1597,9 +1658,13 @@ pkg/agent/sidecar/handler/grpc/handler_test.go pkg/agent/sidecar/handler/grpc/option.go pkg/agent/sidecar/handler/grpc/option_test.go pkg/agent/sidecar/handler/rest/handler.go +pkg/agent/sidecar/handler/rest/handler_test.go pkg/agent/sidecar/handler/rest/option.go +pkg/agent/sidecar/handler/rest/option_test.go pkg/agent/sidecar/router/option.go +pkg/agent/sidecar/router/option_test.go pkg/agent/sidecar/router/router.go +pkg/agent/sidecar/router/router_test.go pkg/agent/sidecar/service/doc.go pkg/agent/sidecar/service/observer/hook.go pkg/agent/sidecar/service/observer/observer.go @@ -1630,9 +1695,13 @@ pkg/discoverer/k8s/handler/grpc/handler_test.go pkg/discoverer/k8s/handler/grpc/option.go pkg/discoverer/k8s/handler/grpc/option_test.go pkg/discoverer/k8s/handler/rest/handler.go +pkg/discoverer/k8s/handler/rest/handler_test.go pkg/discoverer/k8s/handler/rest/option.go +pkg/discoverer/k8s/handler/rest/option_test.go pkg/discoverer/k8s/router/option.go +pkg/discoverer/k8s/router/option_test.go pkg/discoverer/k8s/router/router.go +pkg/discoverer/k8s/router/router_test.go pkg/discoverer/k8s/service/discover.go pkg/discoverer/k8s/service/discover_test.go pkg/discoverer/k8s/service/doc.go @@ -1651,9 +1720,13 @@ pkg/gateway/filter/handler/grpc/handler_test.go pkg/gateway/filter/handler/grpc/option.go pkg/gateway/filter/handler/grpc/option_test.go pkg/gateway/filter/handler/rest/handler.go +pkg/gateway/filter/handler/rest/handler_test.go pkg/gateway/filter/handler/rest/option.go +pkg/gateway/filter/handler/rest/option_test.go pkg/gateway/filter/router/option.go +pkg/gateway/filter/router/option_test.go 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 @@ -1671,9 +1744,13 @@ pkg/gateway/lb/handler/grpc/pairing_heap.go pkg/gateway/lb/handler/grpc/pairing_heap_test.go pkg/gateway/lb/handler/grpc/search_benchmark_test.go pkg/gateway/lb/handler/rest/handler.go +pkg/gateway/lb/handler/rest/handler_test.go pkg/gateway/lb/handler/rest/option.go +pkg/gateway/lb/handler/rest/option_test.go pkg/gateway/lb/router/option.go +pkg/gateway/lb/router/option_test.go pkg/gateway/lb/router/router.go +pkg/gateway/lb/router/router_test.go pkg/gateway/lb/service/doc.go pkg/gateway/lb/service/gateway.go pkg/gateway/lb/service/gateway_test.go @@ -1683,27 +1760,38 @@ pkg/gateway/lb/usecase/vald.go pkg/gateway/lb/usecase/vald_test.go pkg/gateway/mirror/README.md pkg/gateway/mirror/config/config.go +pkg/gateway/mirror/config/config_test.go pkg/gateway/mirror/handler/doc.go pkg/gateway/mirror/handler/grpc/handler.go pkg/gateway/mirror/handler/grpc/handler_test.go pkg/gateway/mirror/handler/grpc/mock_test.go pkg/gateway/mirror/handler/grpc/option.go +pkg/gateway/mirror/handler/grpc/option_test.go pkg/gateway/mirror/handler/rest/handler.go +pkg/gateway/mirror/handler/rest/handler_test.go pkg/gateway/mirror/handler/rest/option.go +pkg/gateway/mirror/handler/rest/option_test.go pkg/gateway/mirror/router/option.go +pkg/gateway/mirror/router/option_test.go pkg/gateway/mirror/router/router.go +pkg/gateway/mirror/router/router_test.go pkg/gateway/mirror/service/discovery.go pkg/gateway/mirror/service/discovery_option.go +pkg/gateway/mirror/service/discovery_option_test.go pkg/gateway/mirror/service/discovery_test.go pkg/gateway/mirror/service/doc.go pkg/gateway/mirror/service/gateway.go pkg/gateway/mirror/service/gateway_mock_test.go +pkg/gateway/mirror/service/gateway_test.go pkg/gateway/mirror/service/mirror.go pkg/gateway/mirror/service/mirror_mock_test.go pkg/gateway/mirror/service/mirror_option.go +pkg/gateway/mirror/service/mirror_option_test.go pkg/gateway/mirror/service/mirror_test.go pkg/gateway/mirror/service/option.go +pkg/gateway/mirror/service/option_test.go pkg/gateway/mirror/usecase/vald.go +pkg/gateway/mirror/usecase/vald_test.go pkg/index/job/correction/config/config.go pkg/index/job/correction/config/config_test.go pkg/index/job/correction/service/corrector.go @@ -1737,10 +1825,13 @@ pkg/index/job/save/service/options_test.go pkg/index/job/save/usecase/save.go pkg/index/job/save/usecase/save_test.go pkg/index/operator/config/config.go +pkg/index/operator/config/config_test.go pkg/index/operator/service/operator.go pkg/index/operator/service/operator_test.go pkg/index/operator/service/options.go +pkg/index/operator/service/options_test.go pkg/index/operator/usecase/operator.go +pkg/index/operator/usecase/operator_test.go pkg/manager/index/README.md pkg/manager/index/config/config.go pkg/manager/index/config/config_test.go @@ -1750,9 +1841,13 @@ pkg/manager/index/handler/grpc/handler_test.go pkg/manager/index/handler/grpc/option.go pkg/manager/index/handler/grpc/option_test.go pkg/manager/index/handler/rest/handler.go +pkg/manager/index/handler/rest/handler_test.go pkg/manager/index/handler/rest/option.go +pkg/manager/index/handler/rest/option_test.go pkg/manager/index/router/option.go +pkg/manager/index/router/option_test.go pkg/manager/index/router/router.go +pkg/manager/index/router/router_test.go pkg/manager/index/service/doc.go pkg/manager/index/service/indexer.go pkg/manager/index/service/indexer_test.go @@ -1766,38 +1861,58 @@ pkg/tools/benchmark/job/config/config_test.go pkg/tools/benchmark/job/config/doc.go pkg/tools/benchmark/job/handler/doc.go pkg/tools/benchmark/job/handler/grpc/handler.go +pkg/tools/benchmark/job/handler/grpc/handler_test.go pkg/tools/benchmark/job/handler/grpc/option.go pkg/tools/benchmark/job/handler/rest/handler.go +pkg/tools/benchmark/job/handler/rest/handler_test.go pkg/tools/benchmark/job/handler/rest/option.go pkg/tools/benchmark/job/router/doc.go pkg/tools/benchmark/job/router/option.go +pkg/tools/benchmark/job/router/option_test.go pkg/tools/benchmark/job/router/router.go +pkg/tools/benchmark/job/router/router_test.go pkg/tools/benchmark/job/service/doc.go pkg/tools/benchmark/job/service/insert.go +pkg/tools/benchmark/job/service/insert_test.go pkg/tools/benchmark/job/service/job.go +pkg/tools/benchmark/job/service/job_test.go pkg/tools/benchmark/job/service/object.go +pkg/tools/benchmark/job/service/object_test.go pkg/tools/benchmark/job/service/option.go +pkg/tools/benchmark/job/service/option_test.go pkg/tools/benchmark/job/service/remove.go +pkg/tools/benchmark/job/service/remove_test.go pkg/tools/benchmark/job/service/search.go +pkg/tools/benchmark/job/service/search_test.go pkg/tools/benchmark/job/service/update.go +pkg/tools/benchmark/job/service/update_test.go pkg/tools/benchmark/job/service/upsert.go +pkg/tools/benchmark/job/service/upsert_test.go pkg/tools/benchmark/job/usecase/benchmarkd.go +pkg/tools/benchmark/job/usecase/benchmarkd_test.go pkg/tools/benchmark/operator/README.md pkg/tools/benchmark/operator/config/config.go +pkg/tools/benchmark/operator/config/config_test.go pkg/tools/benchmark/operator/config/doc.go pkg/tools/benchmark/operator/handler/doc.go pkg/tools/benchmark/operator/handler/grpc/handler.go +pkg/tools/benchmark/operator/handler/grpc/handler_test.go pkg/tools/benchmark/operator/handler/grpc/option.go pkg/tools/benchmark/operator/handler/rest/handler.go +pkg/tools/benchmark/operator/handler/rest/handler_test.go pkg/tools/benchmark/operator/handler/rest/option.go pkg/tools/benchmark/operator/router/doc.go pkg/tools/benchmark/operator/router/option.go +pkg/tools/benchmark/operator/router/option_test.go pkg/tools/benchmark/operator/router/router.go +pkg/tools/benchmark/operator/router/router_test.go pkg/tools/benchmark/operator/service/doc.go pkg/tools/benchmark/operator/service/operator.go pkg/tools/benchmark/operator/service/operator_test.go pkg/tools/benchmark/operator/service/option.go +pkg/tools/benchmark/operator/service/option_test.go pkg/tools/benchmark/operator/usecase/benchmarkd.go +pkg/tools/benchmark/operator/usecase/benchmarkd_test.go pkg/tools/cli/loadtest/assets/dataset.go pkg/tools/cli/loadtest/assets/dataset_test.go pkg/tools/cli/loadtest/assets/hdf5_loader.go @@ -1809,17 +1924,27 @@ pkg/tools/cli/loadtest/assets/small_dataset_test.go pkg/tools/cli/loadtest/config/config.go pkg/tools/cli/loadtest/config/config_test.go pkg/tools/cli/loadtest/service/insert.go +pkg/tools/cli/loadtest/service/insert_test.go pkg/tools/cli/loadtest/service/loader.go pkg/tools/cli/loadtest/service/loader_option.go pkg/tools/cli/loadtest/service/loader_option_test.go pkg/tools/cli/loadtest/service/loader_test.go pkg/tools/cli/loadtest/service/search.go +pkg/tools/cli/loadtest/service/search_test.go pkg/tools/cli/loadtest/usecase/load.go pkg/tools/cli/loadtest/usecase/load_test.go renovate.json rust/Cargo.lock rust/Cargo.toml rust/bin/agent/Cargo.toml +rust/bin/agent/src/handler.rs +rust/bin/agent/src/handler/common.rs +rust/bin/agent/src/handler/index.rs +rust/bin/agent/src/handler/insert.rs +rust/bin/agent/src/handler/remove.rs +rust/bin/agent/src/handler/search.rs +rust/bin/agent/src/handler/update.rs +rust/bin/agent/src/handler/upsert.rs rust/bin/agent/src/main.rs rust/libs/ngt-rs/Cargo.toml rust/libs/ngt-rs/build.rs @@ -1838,8 +1963,6 @@ rust/libs/proto/src/filter.egress.v1.tonic.rs rust/libs/proto/src/filter.ingress.v1.rs rust/libs/proto/src/filter.ingress.v1.tonic.rs rust/libs/proto/src/lib.rs -rust/libs/proto/src/manager.index.v1.rs -rust/libs/proto/src/manager.index.v1.tonic.rs rust/libs/proto/src/mirror.v1.rs rust/libs/proto/src/mirror.v1.tonic.rs rust/libs/proto/src/payload.v1.rs @@ -1877,6 +2000,7 @@ tests/e2e/sidecar/sidecar_test.go tests/performance/max_vector_dim_test.go versions/BUF_VERSION versions/CHAOS_MESH_VERSION +versions/DOCKER_VERSION versions/FAISS_VERSION versions/GOLANGCILINT_VERSION versions/GO_VERSION diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index d3f1047a60..8b4d110a67 100755 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -22,8 +22,11 @@ assignees: "" -- Go Version: 1.22.3 -- Rust Version: 1.77.2 -- Docker Version: 20.10.8 -- Kubernetes Version: v1.30.0 -- NGT Version: 2.2.1 +- Vald Version: v1.7.12 +- Go Version: v1.22.5 +- Rust Version: v1.77.2 +- Docker Version: v27.1.1 +- Kubernetes Version: v1.30.3 +- Helm Version: v3.15.3 +- NGT Version: v2.2.4 +- Faiss Version: v1.8.0 diff --git a/.github/ISSUE_TEMPLATE/security_issue_report.md b/.github/ISSUE_TEMPLATE/security_issue_report.md index d99285a63b..0d78df8f92 100644 --- a/.github/ISSUE_TEMPLATE/security_issue_report.md +++ b/.github/ISSUE_TEMPLATE/security_issue_report.md @@ -16,8 +16,11 @@ assignees: "" -- Go Version: 1.22.3 -- Rust Version: 1.77.2 -- Docker Version: 20.10.8 -- Kubernetes Version: v1.30.0 -- NGT Version: 2.2.1 +- Vald Version: v1.7.12 +- Go Version: v1.22.5 +- Rust Version: v1.77.2 +- Docker Version: v27.1.1 +- Kubernetes Version: v1.30.3 +- Helm Version: v3.15.3 +- NGT Version: v2.2.4 +- Faiss Version: v1.8.0 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8de6182643..831b078b81 100755 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -15,12 +15,14 @@ ### Versions - -- Go Version: 1.22.3 -- Rust Version: 1.77.2 -- Docker Version: 20.10.8 -- Kubernetes Version: v1.30.0 -- NGT Version: 2.2.1 +- Vald Version: v1.7.12 +- Go Version: v1.22.5 +- Rust Version: v1.77.2 +- Docker Version: v27.1.1 +- Kubernetes Version: v1.30.3 +- Helm Version: v3.15.3 +- NGT Version: v2.2.4 +- Faiss Version: v1.8.0 ### Checklist diff --git a/.github/actions/docker-build/action.yaml b/.github/actions/docker-build/action.yaml index d4f8304efc..8a152e28ad 100644 --- a/.github/actions/docker-build/action.yaml +++ b/.github/actions/docker-build/action.yaml @@ -113,7 +113,11 @@ runs: REMOTE="true" \ DOCKER="docker" \ BUILDKIT_INLINE_CACHE=0 \ - DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${LABEL_OPTS} --label org.opencontainers.image.version=${PRIMARY_TAG} --label org.opencontainers.image.title=${TARGET}" \ + DOCKER_OPTS="--platform ${PLATFORMS} --builder ${BUILDER} ${LABEL_OPTS} \ + --label org.opencontainers.image.version=${PRIMARY_TAG} \ + --label org.opencontainers.image.title=${TARGET} \ + --label org.opencontainers.image.created=\"$(date --rfc-3339=ns)\" \ + --label org.opencontainers.image.licenses=\"Apache 2.0\"" \ EXTRA_ARGS="${EXTRA_TAGS}" \ TAG="${PRIMARY_TAG}" \ docker/build/${TARGET} diff --git a/.github/actions/e2e-deploy-vald-helm-operator/action.yaml b/.github/actions/e2e-deploy-vald-helm-operator/action.yaml index edc38eccff..77dd769f0d 100644 --- a/.github/actions/e2e-deploy-vald-helm-operator/action.yaml +++ b/.github/actions/e2e-deploy-vald-helm-operator/action.yaml @@ -86,7 +86,8 @@ runs: sleep 6 - kubectl wait --for=condition=ready pod -l ${WAIT_FOR_SELECTOR} --timeout=${WAIT_FOR_TIMEOUT} + kubectl wait --for=condition=Ready pod -l ${WAIT_FOR_SELECTOR} --timeout=${WAIT_FOR_TIMEOUT} + kubectl wait --for=condition=ContainersReady pod -l ${WAIT_FOR_SELECTOR} --timeout=${WAIT_FOR_TIMEOUT} kubectl get pods diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 2af5ac45f2..d092b85019 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -23,7 +23,7 @@ on: env: TARGET_LABEL_NAME_PREFIX: "actions/backport/" BACKPORT_BRANCH_NAME_PREFIX: "backport" - FETCHED_GITHUB_INFO_PATH: github_info.json + FETCHED_GITHUB_INFO_PATH: /tmp/github_info.json GITHUB_USER: ${{ secrets.DISPATCH_USER }} GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} jobs: diff --git a/.github/workflows/dockers-agent-faiss-image.yml b/.github/workflows/dockers-agent-faiss-image.yml index 9c6ef548a6..0e2931fa86 100644 --- a/.github/workflows/dockers-agent-faiss-image.yml +++ b/.github/workflows/dockers-agent-faiss-image.yml @@ -25,22 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-faiss-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/agent/core/faiss/**" - - "cmd/agent/core/faiss/**" - - "dockers/agent/core/faiss/Dockerfile" - - "versions/GO_VERSION" - - "versions/FAISS_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-agent-image.yml b/.github/workflows/dockers-agent-image.yml index b4ae752529..3ccd1161f3 100644 --- a/.github/workflows/dockers-agent-image.yml +++ b/.github/workflows/dockers-agent-image.yml @@ -25,19 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-image.yml" - - "rust/Cargo.lock" - - "rust/Cargo.toml" - - "rust/bin/agent/**" - - "rust/libs/ngt/**" - - "rust/libs/ngt-rs/**" - - "rust/libs/proto/**" - - "dockers/agent/core/ngt-rust/Dockerfile" - - "versions/RUST_VERSION" - - "versions/NGT_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-agent-ngt-image.yml b/.github/workflows/dockers-agent-ngt-image.yml index a00ebe4158..64c8d7b74d 100644 --- a/.github/workflows/dockers-agent-ngt-image.yml +++ b/.github/workflows/dockers-agent-ngt-image.yml @@ -25,22 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-ngt-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/k8s/**" - - "apis/grpc/**" - - "pkg/agent/core/ngt/**" - - "cmd/agent/core/ngt/**" - - "dockers/agent/core/ngt/Dockerfile" - - "versions/GO_VERSION" - - "versions/NGT_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-agent-sidecar-image.yml b/.github/workflows/dockers-agent-sidecar-image.yml index 36d9807105..38ae9eeb3a 100644 --- a/.github/workflows/dockers-agent-sidecar-image.yml +++ b/.github/workflows/dockers-agent-sidecar-image.yml @@ -25,22 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-sidecar-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/db/storage/blob/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/agent/sidecar/**" - - "cmd/agent/sidecar/**" - - "dockers/agent/sidecar/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-benchmark-job-image.yml b/.github/workflows/dockers-benchmark-job-image.yml index 4ecd0e4b60..2d59b4356c 100644 --- a/.github/workflows/dockers-benchmark-job-image.yml +++ b/.github/workflows/dockers-benchmark-job-image.yml @@ -23,22 +23,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-benchmak-job-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "apis/grpc/**" - - "pkg/tools/benchmark/operator/**" - - "cmd/tools/benchmark/operator/**" - - "pkg/tools/benchmark/job/**" - - "cmd/tools/benchmark/job/**" - - "dockers/tools/benchmark/job/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-benchmark-operator-image.yaml b/.github/workflows/dockers-benchmark-operator-image.yaml index d56d0cd76f..2cc23d85b3 100644 --- a/.github/workflows/dockers-benchmark-operator-image.yaml +++ b/.github/workflows/dockers-benchmark-operator-image.yaml @@ -23,22 +23,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-benchmak-operator-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "apis/grpc/**" - - "pkg/tools/benchmark/operator/**" - - "cmd/tools/benchmark/operator/**" - - "pkg/tools/benchmark/job/**" - - "cmd/tools/benchmark/job/**" - - "dockers/tools/benchmark/operator/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-buildbase-image.yml b/.github/workflows/dockers-buildbase-image.yml new file mode 100644 index 0000000000..6819dd7618 --- /dev/null +++ b/.github/workflows/dockers-buildbase-image.yml @@ -0,0 +1,48 @@ +# +# 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. +# +name: "Build docker image: buildbase" +on: + schedule: + - cron: "0 * * * *" + push: + branches: + - "main" + - "release/v*.*" + - "!release/v*.*.*" + tags: + - "*.*.*" + - "v*.*.*" + - "*.*.*-*" + - "v*.*.*-*" + pull_request: + paths: + - ".github/actions/docker-build/action.yaml" + - ".github/workflows/_docker-image.yaml" + - ".github/workflows/dockers-buildbase-image.yml" + - "dockers/buildbase/Dockerfile" + pull_request_target: + paths: + - ".github/actions/docker-build/action.yaml" + - ".github/workflows/_docker-image.yaml" + - ".github/workflows/dockers-buildbase-image.yml" + - "dockers/buildbase/Dockerfile" +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: buildbase + platforms: linux/amd64,linux/arm64 + secrets: inherit diff --git a/.github/workflows/dockers-ci-container-image.yml b/.github/workflows/dockers-ci-container-image.yml index 8a77e749f3..2e0b034768 100644 --- a/.github/workflows/dockers-ci-container-image.yml +++ b/.github/workflows/dockers-ci-container-image.yml @@ -25,15 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-ci-container-image.yml" - - "dockers/ci/**" - - "Makefile" - - "Makefile.d/**" - - "versions/GO_VERSION" - - "versions/NGT_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-dev-container-image.yml b/.github/workflows/dockers-dev-container-image.yml index 55d347d9a1..f9eae6c6ae 100644 --- a/.github/workflows/dockers-dev-container-image.yml +++ b/.github/workflows/dockers-dev-container-image.yml @@ -20,15 +20,6 @@ on: - "main" - "release/v*.*" - "!release/v*.*.*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-dev-container-image.yml" - - "dockers/dev/**" - - "Makefile" - - "Makefile.d/**" - - "versions/GO_VERSION" - - "versions/NGT_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-discoverer-k8s-image.yml b/.github/workflows/dockers-discoverer-k8s-image.yml index 91c42623ed..6612d9cf2d 100644 --- a/.github/workflows/dockers-discoverer-k8s-image.yml +++ b/.github/workflows/dockers-discoverer-k8s-image.yml @@ -25,20 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-discoverer-k8s-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "apis/grpc/**" - - "pkg/discoverer/k8s/**" - - "cmd/discoverer/k8s/**" - - "dockers/discoverer/k8s/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-gateway-filter-image.yml b/.github/workflows/dockers-gateway-filter-image.yml index d0562e0092..94d9754912 100644 --- a/.github/workflows/dockers-gateway-filter-image.yml +++ b/.github/workflows/dockers-gateway-filter-image.yml @@ -25,23 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-gateway-filter-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/**/*_mock.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/gateway/filter/**" - - "cmd/gateway/filter/**" - - "pkg/gateway/internal/**" - - "dockers/gateway/filter/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-gateway-lb-image.yml b/.github/workflows/dockers-gateway-lb-image.yml index f69bb599ee..a438eb29bf 100644 --- a/.github/workflows/dockers-gateway-lb-image.yml +++ b/.github/workflows/dockers-gateway-lb-image.yml @@ -25,23 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-gateway-lb-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/**/*_mock.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/gateway/lb/**" - - "cmd/gateway/lb/**" - - "pkg/gateway/internal/**" - - "dockers/gateway/lb/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-gateway-mirror-image.yaml b/.github/workflows/dockers-gateway-mirror-image.yaml index 301fc6adcb..aeddaa45f0 100644 --- a/.github/workflows/dockers-gateway-mirror-image.yaml +++ b/.github/workflows/dockers-gateway-mirror-image.yaml @@ -23,22 +23,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/dockers-gateway-mirror-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/**/*_mock.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/gateway/mirror/**" - - "cmd/gateway/mirror/**" - - "pkg/gateway/internal/**" - - "dockers/gateway/mirror/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-helm-operator-image.yml b/.github/workflows/dockers-helm-operator-image.yml index b27f3106ab..3b36c307f7 100644 --- a/.github/workflows/dockers-helm-operator-image.yml +++ b/.github/workflows/dockers-helm-operator-image.yml @@ -25,18 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-helm-operator-image.yml" - - "dockers/operator/helm/Dockerfile" - - "charts/vald/Chart.yaml" - - "charts/vald/values.yaml" - - "charts/vald/templates/**" - - "charts/vald-helm-operator/Chart.yaml" - - "charts/vald-helm-operator/values.yaml" - - "charts/vald-helm-operator/templates/**" - - "versions/OPERATOR_SDK_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-index-correction.yml b/.github/workflows/dockers-index-correction.yml index 9187b487a2..c1bb1b8a29 100644 --- a/.github/workflows/dockers-index-correction.yml +++ b/.github/workflows/dockers-index-correction.yml @@ -23,20 +23,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/dockers-index-correction.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/correction/**" - - "cmd/index/job/correction/**" - - "dockers/index/job/correction/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-index-creation.yml b/.github/workflows/dockers-index-creation.yml index 90a49ee2a1..531e16aedf 100644 --- a/.github/workflows/dockers-index-creation.yml +++ b/.github/workflows/dockers-index-creation.yml @@ -23,20 +23,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/dockers-index-creation.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/creation/**" - - "cmd/index/job/creation/**" - - "dockers/index/job/creation/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-index-operator.yml b/.github/workflows/dockers-index-operator.yml index 5494d85e2f..fcc748d63e 100644 --- a/.github/workflows/dockers-index-operator.yml +++ b/.github/workflows/dockers-index-operator.yml @@ -23,20 +23,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/dockers-index-operator.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/operator/**" - - "cmd/index/operator/**" - - "dockers/index/operator/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-index-save.yml b/.github/workflows/dockers-index-save.yml index 7ee1509498..4669b534bf 100644 --- a/.github/workflows/dockers-index-save.yml +++ b/.github/workflows/dockers-index-save.yml @@ -23,20 +23,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/dockers-index-save.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/save/**" - - "cmd/index/job/save/**" - - "dockers/index/job/save/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-loadtest-image.yml b/.github/workflows/dockers-loadtest-image.yml index 5abb15ad7b..75e84f4cd2 100644 --- a/.github/workflows/dockers-loadtest-image.yml +++ b/.github/workflows/dockers-loadtest-image.yml @@ -25,21 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-loadtest-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/tools/cli/loadtest/**" - - "cmd/tools/cli/loadtest/**" - - "dockers/tools/cli/loadtest/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-manager-index-image.yml b/.github/workflows/dockers-manager-index-image.yml index 334a60dfa6..774979664c 100644 --- a/.github/workflows/dockers-manager-index-image.yml +++ b/.github/workflows/dockers-manager-index-image.yml @@ -25,21 +25,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-manager-index-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/manager/index/**" - - "cmd/manager/index/**" - - "dockers/manager/index/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/dockers-readreplica-rotate.yml b/.github/workflows/dockers-readreplica-rotate.yml index 23019dc82c..724e88a3f1 100644 --- a/.github/workflows/dockers-readreplica-rotate.yml +++ b/.github/workflows/dockers-readreplica-rotate.yml @@ -23,20 +23,6 @@ on: - "v*.*.*" - "*.*.*-*" - "v*.*.*-*" - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/dockers-readreplica-rotate.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/readreplica/rotate/**" - - "cmd/index/job/readreplica/rotate/**" - - "dockers/index/job/readreplica/rotate/Dockerfile" - - "versions/GO_VERSION" pull_request: paths: - ".github/actions/docker-build/action.yaml" diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 9b84555b31..684e04873f 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -59,7 +59,7 @@ jobs: - name: Run formatter and license.go run: | make format - git checkout go.mod go.sum ./rust/Cargo.lock + git checkout go.mod go.sum ./example/client/go.mod ./example/client/go.sum ./rust/Cargo.lock ./dockers - name: Check and Push to main branch continue-on-error: true run: | @@ -105,7 +105,7 @@ jobs: run: | make deps/install make format - git checkout go.mod go.sum ./example/client/go.mod ./example/client/go.sum ./rust/Cargo.lock + git checkout go.mod go.sum ./example/client/go.mod ./example/client/go.sum ./rust/Cargo.lock ./dockers - name: Check format and deps difference run: | if git diff --quiet --exit-code; then diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a443ce318..b6ef7ae669 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,7 +61,7 @@ jobs: git push origin ${VERSION} echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - name: Create release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} with: diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 967b34ed56..16261386f8 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -38,9 +38,6 @@ jobs: - name: Set Git config run: | git config --global --add safe.directory ${GITHUB_WORKSPACE} - - name: Go build - run: | - GOARCH=${GOARCH} GOOS=${GOOS} go build -mod=readonly ./... - name: Run golangci-lint run: | golangci-lint run --config .golangci.yml \ @@ -49,3 +46,17 @@ jobs: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPORTER: github-pr-review LEVEL: warning + go-build: + name: runner / go build + runs-on: ubuntu-latest + needs: [detect-ci-container] + container: + image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + steps: + - uses: actions/checkout@v4 + - name: Set Git config + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: Go build + run: | + make binary/build diff --git a/Makefile b/Makefile index f1699bb33c..663e4bd822 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ AGENT_NGT_IMAGE = $(NAME)-agent-ngt AGENT_FAISS_IMAGE = $(NAME)-agent-faiss AGENT_SIDECAR_IMAGE = $(NAME)-agent-sidecar AGENT_IMAGE = $(NAME)-agent +BUILDBASE_IMAGE = $(NAME)-buildbase CI_CONTAINER_IMAGE = $(NAME)-ci-container DEV_CONTAINER_IMAGE = $(NAME)-dev-container DISCOVERER_IMAGE = $(NAME)-discoverer-k8s @@ -48,6 +49,17 @@ VERSION ?= $(eval VERSION := $(shell cat versions/VALD_VERSION))$(VERSION) NGT_REPO = github.com/yahoojapan/NGT +NPM_GLOBAL_PREFIX := $(eval NPM_GLOBAL_PREFIX := $(shell npm prefix --location=global))$(NPM_GLOBAL_PREFIX) + +TEST_NOT_IMPL_PLACEHOLDER = NOT IMPLEMENTED BELOW + +TEMP_DIR := $(eval TEMP_DIR := $(shell mktemp -d))$(TEMP_DIR) +USR_LOCAL = /usr/local +BINDIR = $(USR_LOCAL)/bin +LIB_PATH = $(USR_LOCAL)/lib +$(LIB_PATH): + mkdir -p $(LIB_PATH) + GOPRIVATE = $(GOPKG),$(GOPKG)/apis,$(GOPKG)-client-go GOPROXY = "https://proxy.golang.org,direct" GOPATH := $(eval GOPATH := $(shell go env GOPATH))$(GOPATH) @@ -60,21 +72,16 @@ GO_CLEAN_DEPS := true GOTEST_TIMEOUT = 30m CGO_ENABLED = 1 -RUST_HOME ?= /usr/local/lib/rust +RUST_HOME ?= $(LIB_PATH)/rust RUSTUP_HOME ?= $(RUST_HOME)/rustup CARGO_HOME ?= $(RUST_HOME)/cargo RUST_VERSION := $(eval RUST_VERSION := $(shell cat versions/RUST_VERSION))$(RUST_VERSION) -NPM_GLOBAL_PREFIX := $(eval NPM_GLOBAL_PREFIX := $(shell npm prefix --location=global))$(NPM_GLOBAL_PREFIX) - -TEST_NOT_IMPL_PLACEHOLDER = NOT IMPLEMENTED BELOW - -TEMP_DIR := $(eval TEMP_DIR := $(shell mktemp -d))$(TEMP_DIR) - BUF_VERSION := $(eval BUF_VERSION := $(shell cat versions/BUF_VERSION))$(BUF_VERSION) -NGT_VERSION := $(eval NGT_VERSION := $(shell cat versions/NGT_VERSION))$(NGT_VERSION) +DOCKER_VERSION := $(eval DOCKER_VERSION := $(shell cat versions/DOCKER_VERSION))$(DOCKER_VERSION) FAISS_VERSION := $(eval FAISS_VERSION := $(shell cat versions/FAISS_VERSION))$(FAISS_VERSION) GOLANGCILINT_VERSION := $(eval GOLANGCILINT_VERSION := $(shell cat versions/GOLANGCILINT_VERSION))$(GOLANGCILINT_VERSION) +HDF5_VERSION := $(eval HDF5_VERSION := $(shell cat versions/HDF5_VERSION))$(HDF5_VERSION) HELM_DOCS_VERSION := $(eval HELM_DOCS_VERSION := $(shell cat versions/HELM_DOCS_VERSION))$(HELM_DOCS_VERSION) HELM_VERSION := $(eval HELM_VERSION := $(shell cat versions/HELM_VERSION))$(HELM_VERSION) JAEGER_OPERATOR_VERSION := $(eval JAEGER_OPERATOR_VERSION := $(shell cat versions/JAEGER_OPERATOR_VERSION))$(JAEGER_OPERATOR_VERSION) @@ -90,9 +97,7 @@ REVIEWDOG_VERSION := $(eval REVIEWDOG_VERSION := $(shell cat versions/RE TELEPRESENCE_VERSION := $(eval TELEPRESENCE_VERSION := $(shell cat versions/TELEPRESENCE_VERSION))$(TELEPRESENCE_VERSION) VALDCLI_VERSION := $(eval VALDCLI_VERSION := $(shell cat versions/VALDCLI_VERSION))$(VALDCLI_VERSION) YQ_VERSION := $(eval YQ_VERSION := $(shell cat versions/YQ_VERSION))$(YQ_VERSION) -BUF_VERSION := $(eval BUF_VERSION := $(shell cat versions/BUF_VERSION))$(BUF_VERSION) ZLIB_VERSION := $(eval ZLIB_VERSION := $(shell cat versions/ZLIB_VERSION))$(ZLIB_VERSION) -HDF5_VERSION := $(eval HDF5_VERSION := $(shell cat versions/HDF5_VERSION))$(HDF5_VERSION) OTEL_OPERATOR_RELEASE_NAME ?= opentelemetry-operator PROMETHEUS_RELEASE_NAME ?= prometheus @@ -101,8 +106,6 @@ SWAP_DEPLOYMENT_TYPE ?= deployment SWAP_IMAGE ?= "" SWAP_TAG ?= latest -BINDIR ?= /usr/local/bin - UNAME := $(eval UNAME := $(shell uname -s))$(UNAME) OS := $(eval OS := $(shell echo $(UNAME) | tr '[:upper:]' '[:lower:]'))$(OS) ARCH := $(eval ARCH := $(shell uname -m))$(ARCH) @@ -137,6 +140,13 @@ PBGOS = $(PROTOS:apis/proto/%.proto=apis/grpc/%.pb.go) SWAGGERS = $(PROTOS:apis/proto/%.proto=apis/swagger/%.swagger.json) PBDOCS = apis/docs/v1/docs.md +LDFLAGS = -static -fPIC -pthread -std=gnu++20 -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 + +NGT_LDFLAGS = -fopenmp -lopenblas -llapack +FAISS_LDFLAGS = $(NGT_LDFLAGS) -lgfortran +HDF5_LDFLAGS = -lhdf5 -lhdf5_hl -lsz -laec -lz -ldl +CGO_LDFLAGS = $(FAISS_LDFLAGS) $(HDF5_LDFLAGS) + ifeq ($(GOARCH),amd64) CFLAGS ?= -mno-avx512f -mno-avx512dq -mno-avx512cd -mno-avx512bw -mno-avx512vl CXXFLAGS ?= $(CFLAGS) @@ -239,6 +249,7 @@ GO_SOURCES = $(eval GO_SOURCES := $(shell find \ -not -path '$(ROOTDIR)/hack/benchmark/internal/starter/gateway/*' \ -not -path '$(ROOTDIR)/hack/gorules/*' \ -not -path '$(ROOTDIR)/hack/license/*' \ + -not -path '$(ROOTDIR)/hack/docker/*' \ -not -path '$(ROOTDIR)/hack/swagger/*' \ -not -path '$(ROOTDIR)/hack/tools/*' \ -not -path '$(ROOTDIR)/tests/*' \ @@ -270,6 +281,7 @@ GO_OPTION_SOURCES = $(eval GO_OPTION_SOURCES := $(shell find \ -not -path '$(ROOTDIR)/hack/benchmark/internal/starter/gateway/*' \ -not -path '$(ROOTDIR)/hack/gorules/*' \ -not -path '$(ROOTDIR)/hack/license/*' \ + -not -path '$(ROOTDIR)/hack/docker/*' \ -not -path '$(ROOTDIR)/hack/swagger/*' \ -not -path '$(ROOTDIR)/hack/tools/*' \ -not -path '$(ROOTDIR)/tests/*' \ @@ -324,21 +336,22 @@ SHELL = bash E2E_BIND_HOST ?= 127.0.0.1 E2E_BIND_PORT ?= 8082 -E2E_TIMEOUT ?= 30m E2E_DATASET_NAME ?= fashion-mnist-784-euclidean.hdf5 -E2E_INSERT_COUNT ?= 10000 -E2E_SEARCH_COUNT ?= 1000 -E2E_SEARCH_BY_ID_COUNT ?= 100 E2E_GET_OBJECT_COUNT ?= 10 -E2E_UPDATE_COUNT ?= 10 -E2E_UPSERT_COUNT ?= 10 +E2E_INSERT_COUNT ?= 10000 +E2E_PORTFORWARD_ENABLED ?= true E2E_REMOVE_COUNT ?= 3 -E2E_WAIT_FOR_CREATE_INDEX_DURATION ?= 8m +E2E_SEARCH_BY_ID_COUNT ?= 100 +E2E_SEARCH_COUNT ?= 1000 E2E_TARGET_NAME ?= vald-lb-gateway -E2E_TARGET_POD_NAME ?= $(eval E2E_TARGET_POD_NAME := $(shell kubectl get pods --selector=app=$(E2E_TARGET_NAME) -n $(E2E_TARGET_NAMESPACE) | tail -1 | cut -f1 -d " "))$(E2E_TARGET_POD_NAME) E2E_TARGET_NAMESPACE ?= default +E2E_TARGET_POD_NAME ?= $(eval E2E_TARGET_POD_NAME := $(shell kubectl get pods --selector=app=$(E2E_TARGET_NAME) -n $(E2E_TARGET_NAMESPACE) | tail -1 | cut -f1 -d " "))$(E2E_TARGET_POD_NAME) E2E_TARGET_PORT ?= 8081 -E2E_PORTFORWARD_ENABLED ?= true +E2E_TIMEOUT ?= 30m +E2E_UPDATE_COUNT ?= 10 +E2E_UPSERT_COUNT ?= 10 +E2E_WAIT_FOR_CREATE_INDEX_DURATION ?= 8m +E2E_WAIT_FOR_START_TIMEOUT ?= 10m TEST_RESULT_DIR ?= /tmp @@ -353,14 +366,14 @@ maintainer: ## print all available commands help: @awk '/^[a-zA-Z_0-9%:\\\/-]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = $$1; \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - gsub("\\\\", "", helpCommand); \ - gsub(":+$$", "", helpCommand); \ - printf " \x1b[32;01m%-38s\x1b[0m %s\n", helpCommand, helpMessage; \ - } \ + helpMessage = match(lastLine, /^## (.*)/); \ + if (helpMessage) { \ + helpCommand = $$1; \ + helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ + gsub("\\\\", "", helpCommand); \ + gsub(":+$$", "", helpCommand); \ + printf " \x1b[32;01m%-38s\x1b[0m %s\n", helpCommand, helpMessage; \ + } \ } \ { lastLine = $$0 }' $(MAKELISTS) | sort -u @printf "\n" @@ -412,6 +425,11 @@ files: license: $(call gen-license,$(ROOTDIR),$(MAINTAINER)) +.PHONY: dockerfile +## generate dockerfiles +dockerfile: + $(call gen-dockerfile,$(ROOTDIR),$(MAINTAINER)) + .PHONY: init ## initialize development environment init: \ @@ -445,6 +463,7 @@ update: \ .PHONY: format ## format go codes format: \ + dockerfile \ license \ format/proto \ format/go \ @@ -455,26 +474,30 @@ format: \ .PHONY: format/go ## run golines, gofumpt, goimports for all go files format/go: \ + crlfmt/install \ golines/install \ gofumpt/install \ strictgoimports/install \ goimports/install - find $(ROOTDIR)/ -type d -name .git -prune -o -type f -regex '.*[^\.pb]\.go' -print | xargs -P$(CORES) $(GOBIN)/golines -w -m $(GOLINES_MAX_WIDTH) - find $(ROOTDIR)/ -type d -name .git -prune -o -type f -regex '.*[^\.pb]\.go' -print | xargs -P$(CORES) $(GOBIN)/gofumpt -w - find $(ROOTDIR)/ -type d -name .git -prune -o -type f -regex '.*[^\.pb]\.go' -print | xargs -P$(CORES) $(GOBIN)/strictgoimports -w + find $(ROOTDIR)/ -type d -name .git -prune -o -type f -regex '.*\.go' -print | xargs -P$(CORES) $(GOBIN)/golines -w -m $(GOLINES_MAX_WIDTH) + find $(ROOTDIR)/ -type d -name .git -prune -o -type f -regex '.*\.go' -print | xargs -P$(CORES) $(GOBIN)/strictgoimports -w find $(ROOTDIR)/ -type d -name .git -prune -o -type f -regex '.*\.go' -print | xargs -P$(CORES) $(GOBIN)/goimports -w + find $(ROOTDIR)/ -type d -name .git -prune -o -type f -regex '.*\.go' -print | xargs -P$(CORES) $(GOBIN)/crlfmt -w -diff=false + find $(ROOTDIR)/ -type d -name .git -prune -o -type f -regex '.*\.go' -print | xargs -P$(CORES) $(GOBIN)/gofumpt -w .PHONY: format/go/test ## run golines, gofumpt, goimports for go test files format/go/test: \ + crlfmt/install \ golines/install \ gofumpt/install \ strictgoimports/install \ goimports/install find $(ROOTDIR) -name '*_test.go' | xargs -P$(CORES) $(GOBIN)/golines -w -m $(GOLINES_MAX_WIDTH) - find $(ROOTDIR) -name '*_test.go' | xargs -P$(CORES) $(GOBIN)/gofumpt -w find $(ROOTDIR) -name '*_test.go' | xargs -P$(CORES) $(GOBIN)/strictgoimports -w find $(ROOTDIR) -name '*_test.go' | xargs -P$(CORES) $(GOBIN)/goimports -w + find $(ROOTDIR) -name '*_test.go' | xargs -P$(CORES) $(GOBIN)/crlfmt -w -diff=false + find $(ROOTDIR) -name '*_test.go' | xargs -P$(CORES) $(GOBIN)/gofumpt -w .PHONY: format/yaml format/yaml: \ @@ -517,6 +540,7 @@ deps: \ .PHONY: deps/install ## install dependencies deps/install: \ + crlfmt/install \ golines/install \ gofumpt/install \ strictgoimports/install \ @@ -551,6 +575,16 @@ version/rust: version/ngt: @echo $(NGT_VERSION) +.PHONY: version/faiss +## print Faiss version +version/faiss: + @echo $(FAISS_VERSION) + +.PHONY: version/docker +## print Kubernetes version +version/docker: + @echo $(DOCKER_VERSION) + .PHONY: version/k8s ## print Kubernetes version version/k8s: @@ -578,12 +612,19 @@ version/telepresence: .PHONY: ngt/install ## install NGT -ngt/install: /usr/local/include/NGT/Capi.h -/usr/local/include/NGT/Capi.h: +ngt/install: $(USR_LOCAL)/include/NGT/Capi.h +$(USR_LOCAL)/include/NGT/Capi.h: git clone --depth 1 --branch v$(NGT_VERSION) https://github.com/yahoojapan/NGT $(TEMP_DIR)/NGT-$(NGT_VERSION) cd $(TEMP_DIR)/NGT-$(NGT_VERSION) && \ - cmake -DCMAKE_C_FLAGS="$(CFLAGS)" -DCMAKE_CXX_FLAGS="$(CXXFLAGS)" "$(NGT_EXTRA_FLAGS)" . - make -j -C $(TEMP_DIR)/NGT-$(NGT_VERSION) + cmake -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DBUILD_STATIC_EXECS=ON \ + -DBUILD_TESTING=OFF \ + -DCMAKE_C_FLAGS="$(CFLAGS)" \ + -DCMAKE_CXX_FLAGS="$(CXXFLAGS)" \ + -DCMAKE_INSTALL_PREFIX=$(USR_LOCAL) \ + "$(NGT_EXTRA_FLAGS)" . + make -j$(CORES) -C $(TEMP_DIR)/NGT-$(NGT_VERSION) make install -C $(TEMP_DIR)/NGT-$(NGT_VERSION) cd $(ROOTDIR) rm -rf $(TEMP_DIR)/NGT-$(NGT_VERSION) @@ -591,13 +632,23 @@ ngt/install: /usr/local/include/NGT/Capi.h .PHONY: faiss/install ## install Faiss -faiss/install: /usr/local/lib/libfaiss.so -/usr/local/lib/libfaiss.so: - curl -fsSLO https://github.com/facebookresearch/faiss/archive/v$(FAISS_VERSION).tar.gz - tar zxf v$(FAISS_VERSION).tar.gz -C $(TEMP_DIR)/ +faiss/install: $(LIB_PATH)/libfaiss.a +$(LIB_PATH)/libfaiss.a: + curl -fsSL https://github.com/facebookresearch/faiss/archive/v$(FAISS_VERSION).tar.gz -o $(TEMP_DIR)/v$(FAISS_VERSION).tar.gz + tar zxf $(TEMP_DIR)/v$(FAISS_VERSION).tar.gz -C $(TEMP_DIR)/ cd $(TEMP_DIR)/faiss-$(FAISS_VERSION) && \ - cmake -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -B build . && \ - make -C build -j faiss && \ + cmake -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DBUILD_STATIC_EXECS=ON \ + -DBUILD_TESTING=OFF \ + -DCMAKE_C_FLAGS="$(LDFLAGS)" \ + -DCMAKE_INSTALL_PREFIX=$(USR_LOCAL) \ + -DFAISS_ENABLE_PYTHON=OFF \ + -DFAISS_ENABLE_GPU=OFF \ + -DBLA_VENDOR=OpenBLAS \ + -DCMAKE_EXE_LINKER_FLAGS="$(FAISS_LDFLAGS)" \ + -B build . && \ + make -C build -j$(CORES) faiss && \ make -C build install rm -rf v$(FAISS_VERSION).tar.gz rm -rf $(TEMP_DIR)/faiss-$(FAISS_VERSION) @@ -608,7 +659,11 @@ faiss/install: /usr/local/lib/libfaiss.so lint: \ docs/lint \ files/lint \ - vet + vet \ + go/lint + +.PHONY: go/lint +go/lint: $(call go-lint) .PHONY: vet diff --git a/Makefile.d/bench.mk b/Makefile.d/bench.mk index e97d845c9c..685f372603 100644 --- a/Makefile.d/bench.mk +++ b/Makefile.d/bench.mk @@ -130,6 +130,7 @@ pprof/core/ngt/sequential.bin: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test \ -mod=readonly \ -count=1 \ @@ -154,6 +155,7 @@ pprof/core/ngt/parallel.bin: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test \ -mod=readonly \ -count=1 \ @@ -185,6 +187,7 @@ pprof/agent/stream.bin: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test \ -mod=readonly \ -count=1 \ @@ -210,6 +213,7 @@ pprof/agent/sequential/grpc.bin: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test \ -mod=readonly \ -count=1 \ @@ -240,6 +244,7 @@ pprof/gateway/sequential.bin: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test \ -mod=readonly \ -count=1 \ @@ -288,6 +293,7 @@ $(ROOTDIR)/metrics.gob: GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -mod=readonly -v --timeout=1h $(ROOTDIR)/hack/benchmark/e2e/agent/core/ngt/... -output=$(ROOTDIR)/metrics.gob .PHONY: metrics/chart diff --git a/Makefile.d/build.mk b/Makefile.d/build.mk index 17b0a1c11e..c2132a1630 100644 --- a/Makefile.d/build.mk +++ b/Makefile.d/build.mk @@ -17,8 +17,6 @@ .PHONY: binary/build ## build all binaries binary/build: \ - cmd/agent/core/faiss/faiss \ - cmd/agent/core/ngt/ngt \ cmd/agent/sidecar/sidecar \ cmd/discoverer/k8s/discoverer \ cmd/gateway/filter/filter \ @@ -28,21 +26,26 @@ binary/build: \ cmd/index/job/creation/index-creation \ cmd/index/job/readreplica/rotate/readreplica-rotate \ cmd/index/job/save/index-save \ + cmd/index/operator/index-operator \ cmd/manager/index/index \ cmd/tools/benchmark/job/job \ cmd/tools/benchmark/operator/operator \ - cmd/index/operator/index-operator + cmd/tools/cli/loadtest/loadtest \ + cmd/agent/core/ngt/ngt \ + cmd/agent/core/faiss/faiss \ + rust/target/debug/agent \ + rust/target/release/agent \ cmd/agent/core/ngt/ngt: \ ngt/install $(eval CGO_ENABLED = 1) - $(call go-build,agent/core/ngt,-linkmode 'external',-static -fPIC -pthread -fopenmp -std=gnu++20 -lstdc++ -lm -z relro -z now $(EXTLDFLAGS), cgo,NGT-$(NGT_VERSION),$@) + $(call go-build,agent/core/ngt,-linkmode 'external',$(LDFLAGS) $(NGT_LDFLAGS) $(EXTLDFLAGS), cgo,NGT-$(NGT_VERSION),$@) cmd/agent/core/faiss/faiss: \ faiss/install $(eval CGO_ENABLED = 1) - $(call go-build,agent/core/faiss,-linkmode 'external',-fPIC -pthread -fopenmp -std=gnu++20 -lstdc++ -lm -z relro -z now, cgo,FAISS-$(FAISS_VERSION),$@) + $(call go-build,agent/core/faiss,-linkmode 'external',$(LDFLAGS) $(FAISS_LDFLAGS), cgo,FAISS-$(FAISS_VERSION),$@) cmd/agent/sidecar/sidecar: $(eval CGO_ENABLED = 0) @@ -89,12 +92,17 @@ cmd/index/operator/index-operator: $(call go-build,index/operator,,-static,,,$@) cmd/tools/benchmark/job/job: - $(call go-build,tools/benchmark/job,-linkmode 'external',-static -fPIC -pthread -fopenmp -std=gnu++20 -lhdf5 -lhdf5_hl -lm -ldl, cgo,$(HDF5_VERSION),$@) + $(eval CGO_ENABLED = 1) + $(call go-build,tools/benchmark/job,-linkmode 'external',$(LDFLAGS) $(HDF5_LDFLAGS), cgo,$(HDF5_VERSION),$@) cmd/tools/benchmark/operator/operator: $(eval CGO_ENABLED = 0) $(call go-build,tools/benchmark/operator,,-static,,,$@) +cmd/tools/cli/loadtest/loadtest: + $(eval CGO_ENABLED = 1) + $(call go-build,tools/cli/loadtest,-linkmode 'external',$(LDFLAGS) $(HDF5_LDFLAGS), cgo,$(HDF5_VERSION),$@) + rust/target/release/agent: pushd rust && cargo build -p agent --release && popd @@ -107,16 +115,19 @@ binary/build/zip: \ artifacts/vald-agent-faiss-$(GOOS)-$(GOARCH).zip \ artifacts/vald-agent-ngt-$(GOOS)-$(GOARCH).zip \ artifacts/vald-agent-sidecar-$(GOOS)-$(GOARCH).zip \ + artifacts/vald-benchmark-job-$(GOOS)-$(GOARCH).zip \ + artifacts/vald-benchmark-operator-$(GOOS)-$(GOARCH).zip \ + artifacts/vald-cli-loadtest-$(GOOS)-$(GOARCH).zip \ artifacts/vald-discoverer-k8s-$(GOOS)-$(GOARCH).zip \ artifacts/vald-filter-gateway-$(GOOS)-$(GOARCH).zip \ artifacts/vald-index-correction-$(GOOS)-$(GOARCH).zip \ artifacts/vald-index-creation-$(GOOS)-$(GOARCH).zip \ + artifacts/vald-index-operator-$(GOOS)-$(GOARCH).zip \ artifacts/vald-index-save-$(GOOS)-$(GOARCH).zip \ artifacts/vald-lb-gateway-$(GOOS)-$(GOARCH).zip \ artifacts/vald-manager-index-$(GOOS)-$(GOARCH).zip \ artifacts/vald-mirror-gateway-$(GOOS)-$(GOARCH).zip \ - artifacts/vald-readreplica-rotate-$(GOOS)-$(GOARCH).zip \ - artifacts/vald-index-operator-$(GOOS)-$(GOARCH).zip + artifacts/vald-readreplica-rotate-$(GOOS)-$(GOARCH).zip artifacts/vald-agent-ngt-$(GOOS)-$(GOARCH).zip: cmd/agent/core/ngt/ngt $(call mkdir, $(dir $@)) @@ -154,6 +165,10 @@ artifacts/vald-benchmark-operator-$(GOOS)-$(GOARCH).zip: cmd/tools/benchmark/ope $(call mkdir, $(dir $@)) zip --junk-paths $@ $< +artifacts/vald-cli-loadtest-$(GOOS)-$(GOARCH).zip: cmd/tools/cli/loadtest/loadtest + $(call mkdir, $(dir $@)) + zip --junk-paths $@ $< + artifacts/vald-mirror-gateway-$(GOOS)-$(GOARCH).zip: cmd/gateway/mirror/mirror $(call mkdir, $(dir $@)) zip --junk-paths $@ $< diff --git a/Makefile.d/dependencies.mk b/Makefile.d/dependencies.mk index 8dece00fca..8e01f2fb07 100644 --- a/Makefile.d/dependencies.mk +++ b/Makefile.d/dependencies.mk @@ -47,14 +47,15 @@ go/download: .PHONY: go/deps ## install Go package dependencies -go/deps: +go/deps: \ + update/go sed -i "3s/go [0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?/go $(GO_VERSION)/g" $(ROOTDIR)/hack/go.mod.default if $(GO_CLEAN_DEPS); then \ rm -rf $(ROOTDIR)/vendor \ /go/pkg \ $(GOCACHE) \ $(ROOTDIR)/go.sum \ - $(ROOTDIR)/go.mod ; \ + $(ROOTDIR)/go.mod 2>/dev/null; \ cp $(ROOTDIR)/hack/go.mod.default $(ROOTDIR)/go.mod ; \ GOPRIVATE=$(GOPRIVATE) go mod tidy ; \ go clean -cache -modcache -testcache -i -r ; \ @@ -62,7 +63,7 @@ go/deps: /go/pkg \ $(GOCACHE) \ $(ROOTDIR)/go.sum \ - $(ROOTDIR)/go.mod ; \ + $(ROOTDIR)/go.mod 2>/dev/null; \ cp $(ROOTDIR)/hack/go.mod.default $(ROOTDIR)/go.mod ; \ fi cp $(ROOTDIR)/hack/go.mod.default $(ROOTDIR)/go.mod @@ -76,7 +77,7 @@ go/example/deps: $(GOCACHE) \ $(ROOTDIR)/example/client/vendor \ $(ROOTDIR)/example/client/go.mod \ - $(ROOTDIR)/example/client/go.sum + $(ROOTDIR)/example/client/go.sum 2>/dev/null; \ sed -i "3s/go [0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?/go $(GO_VERSION)/g" $(ROOTDIR)/example/client/go.mod.default cp $(ROOTDIR)/example/client/go.mod.default $(ROOTDIR)/example/client/go.mod cd $(ROOTDIR)/example/client && GOPRIVATE=$(GOPRIVATE) go mod tidy && cd - @@ -120,6 +121,11 @@ update/golangci-lint: update/rust: curl -fsSL https://releases.rs | grep -Po 'Stable: \K[\d.]+\s' | head -n 1 > $(ROOTDIR)/versions/RUST_VERSION +.PHONY: update/docker +## update docker version +update/docker: + curl -fsSL https://api.github.com/repos/moby/moby/releases/latest | grep -Po '"tag_name": "\K.*?(?=")' > $(ROOTDIR)/versions/DOCKER_VERSION + .PHONY: update/helm ## update helm version update/helm: @@ -218,22 +224,44 @@ update/valdcli: .PHONY: update/template ## update PULL_REQUEST_TEMPLATE and ISSUE_TEMPLATE update/template: + $(eval VALD_VERSION := $(shell $(MAKE) -s version/vald)) $(eval GO_VERSION := $(shell $(MAKE) -s version/go)) - $(eval NGT_VERSION := $(shell $(MAKE) -s version/ngt)) - $(eval KUBECTL_VERSION := $(shell $(MAKE) -s version/k8s)) $(eval RUST_VERSION := $(shell $(MAKE) -s version/rust)) - sed -i -e "s/^- Go Version: .*$$/- Go Version: $(GO_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md - sed -i -e "s/^- Go Version: .*$$/- Go Version: $(GO_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md - sed -i -e "s/^- Go Version: .*$$/- Go Version: $(GO_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md + $(eval DOCKER_VERSION := $(shell $(MAKE) -s version/docker)) + $(eval KUBECTL_VERSION := $(shell $(MAKE) -s version/k8s)) + $(eval HELM_VERSION := $(shell $(MAKE) -s version/helm)) + $(eval NGT_VERSION := $(shell $(MAKE) -s version/ngt)) + $(eval FAISS_VERSION := $(shell $(MAKE) -s version/faiss)) + + sed -i -e "s/^- Vald Version: .*$$/- Vald Version: $(VALD_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md + sed -i -e "s/^- Vald Version: .*$$/- Vald Version: $(VALD_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md + sed -i -e "s/^- Vald Version: .*$$/- Vald Version: $(VALD_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md - sed -i -e "s/^- NGT Version: .*$$/- NGT Version: $(NGT_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md - sed -i -e "s/^- NGT Version: .*$$/- NGT Version: $(NGT_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md - sed -i -e "s/^- NGT Version: .*$$/- NGT Version: $(NGT_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md + sed -i -e "s/^- Go Version: .*$$/- Go Version: v$(GO_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md + sed -i -e "s/^- Go Version: .*$$/- Go Version: v$(GO_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md + sed -i -e "s/^- Go Version: .*$$/- Go Version: v$(GO_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md + + sed -i -e "s/^- Rust Version: .*$$/- Rust Version: v$(RUST_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md + sed -i -e "s/^- Rust Version: .*$$/- Rust Version: v$(RUST_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md + sed -i -e "s/^- Rust Version: .*$$/- Rust Version: v$(RUST_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md + + sed -i -e "s/^- Docker Version: .*$$/- Docker Version: $(DOCKER_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md + sed -i -e "s/^- Docker Version: .*$$/- Docker Version: $(DOCKER_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md + sed -i -e "s/^- Docker Version: .*$$/- Docker Version: $(DOCKER_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md sed -i -e "s/^- Kubernetes Version: .*$$/- Kubernetes Version: $(KUBECTL_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md sed -i -e "s/^- Kubernetes Version: .*$$/- Kubernetes Version: $(KUBECTL_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md sed -i -e "s/^- Kubernetes Version: .*$$/- Kubernetes Version: $(KUBECTL_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md - sed -i -e "s/^- Rust Version: .*$$/- Rust Version: $(RUST_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md - sed -i -e "s/^- Rust Version: .*$$/- Rust Version: $(RUST_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md - sed -i -e "s/^- Rust Version: .*$$/- Rust Version: $(RUST_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md + sed -i -e "s/^- Helm Version: .*$$/- Helm Version: $(HELM_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md + sed -i -e "s/^- Helm Version: .*$$/- Helm Version: $(HELM_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md + sed -i -e "s/^- Helm Version: .*$$/- Helm Version: $(HELM_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md + + sed -i -e "s/^- NGT Version: .*$$/- NGT Version: v$(NGT_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md + sed -i -e "s/^- NGT Version: .*$$/- NGT Version: v$(NGT_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md + sed -i -e "s/^- NGT Version: .*$$/- NGT Version: v$(NGT_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md + + sed -i -e "s/^- Faiss Version: .*$$/- Faiss Version: v$(FAISS_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/bug_report.md + sed -i -e "s/^- Faiss Version: .*$$/- Faiss Version: v$(FAISS_VERSION)/" $(ROOTDIR)/.github/ISSUE_TEMPLATE/security_issue_report.md + sed -i -e "s/^- Faiss Version: .*$$/- Faiss Version: v$(FAISS_VERSION)/" $(ROOTDIR)/.github/PULL_REQUEST_TEMPLATE.md + diff --git a/Makefile.d/docker.mk b/Makefile.d/docker.mk index 96d1db40db..540eca3eb4 100644 --- a/Makefile.d/docker.mk +++ b/Makefile.d/docker.mk @@ -46,10 +46,13 @@ ifeq ($(REMOTE),true) @echo "starting remote build for $(IMAGE):$(TAG)" DOCKER_BUILDKIT=1 $(DOCKER) buildx build \ $(DOCKER_OPTS) \ + --cache-to type=gha,scope=$(TAG)-buildcache,mode=max \ --cache-to type=registry,ref=$(GHCRORG)/$(IMAGE):$(TAG)-buildcache,mode=max \ + --cache-from type=gha,scope=$(TAG)-buildcache \ --cache-from type=registry,ref=$(GHCRORG)/$(IMAGE):$(TAG)-buildcache \ --build-arg BUILDKIT_INLINE_CACHE=$(BUILDKIT_INLINE_CACHE) \ --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg RUST_VERSION=$(RUST_VERSION) \ --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \ --build-arg MAINTAINER=$(MAINTAINER) \ @@ -66,6 +69,7 @@ else $(DOCKER_OPTS) \ --build-arg BUILDKIT_INLINE_CACHE=$(BUILDKIT_INLINE_CACHE) \ --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg RUST_VERSION=$(RUST_VERSION) \ --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \ --build-arg MAINTAINER=$(MAINTAINER) \ @@ -175,6 +179,17 @@ docker/build/manager-index: IMAGE=$(MANAGER_INDEX_IMAGE) \ docker/build/image +.PHONY: docker/name/buildbase +docker/name/buildbase: + @echo "$(ORG)/$(BUILDBASE_IMAGE)" + +.PHONY: docker/build/buildbase +## build buildbase image +docker/build/buildbase: + @make DOCKERFILE="$(ROOTDIR)/dockers/buildbase/Dockerfile" \ + IMAGE=$(BUILDBASE_IMAGE) \ + docker/build/image + .PHONY: docker/name/ci-container docker/name/ci-container: @echo "$(ORG)/$(CI_CONTAINER_IMAGE)" @@ -218,6 +233,7 @@ docker/name/loadtest: ## build loadtest image docker/build/loadtest: @make DOCKERFILE="$(ROOTDIR)/dockers/tools/cli/loadtest/Dockerfile" \ + DOCKER_OPTS="--build-arg ZLIB_VERSION=$(ZLIB_VERSION) --build-arg HDF5_VERSION=$(HDF5_VERSION)" \ IMAGE=$(LOADTEST_IMAGE) \ docker/build/image diff --git a/Makefile.d/e2e.mk b/Makefile.d/e2e.mk index f2745f84a4..9971b41bb4 100644 --- a/Makefile.d/e2e.mk +++ b/Makefile.d/e2e.mk @@ -99,3 +99,44 @@ e2e/maxdim: e2e/sidecar: $(call run-e2e-sidecar-test,-run TestE2EForSidecar) +.PHONY: e2e/actions/run/stream/crud +## run GitHub Actions E2E test (Stream CRUD) +e2e/actions/run/stream/crud: \ + hack/benchmark/assets/dataset/$(E2E_DATASET_NAME) \ + k3d/restart + kubectl wait -n kube-system --for=condition=Available deployment/metrics-server --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + sleep 2 + kubectl wait -n kube-system --for=condition=Ready pod -l k8s-app=metrics-server --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + kubectl wait -n kube-system --for=condition=ContainersReady pod -l k8s-app=metrics-server --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + make k8s/vald/deploy \ + HELM_VALUES=$(ROOTDIR)/.github/helm/values/values-lb.yaml + sleep 3 + kubectl wait --for=condition=Ready pod -l "app=$(LB_GATEWAY_IMAGE)" --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + kubectl wait --for=condition=ContainersReady pod -l "app=$(LB_GATEWAY_IMAGE)" --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + kubectl get pods + pod_name=$$(kubectl get pods --selector="app=$(LB_GATEWAY_IMAGE)" | tail -1 | awk '{print $$1}'); \ + echo $$pod_name; \ + make E2E_TARGET_POD_NAME=$$pod_name e2e + make k8s/vald/delete + $(MAKE) k3d/delete + +.PHONY: e2e/actions/run/job +## run GitHub Actions E2E test (jobs) +e2e/actions/run/job: \ + hack/benchmark/assets/dataset/$(E2E_DATASET_NAME) \ + k3d/restart + kubectl wait -n kube-system --for=condition=Available deployment/metrics-server --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + sleep 2 + kubectl wait -n kube-system --for=condition=Ready pod -l k8s-app=metrics-server --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + kubectl wait -n kube-system --for=condition=ContainersReady pod -l k8s-app=metrics-server --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + make k8s/vald/deploy \ + HELM_VALUES=$(ROOTDIR)/.github/helm/values/values-lb.yaml + sleep 3 + kubectl wait --for=condition=Ready pod -l "app=$(LB_GATEWAY_IMAGE)" --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + kubectl wait --for=condition=ContainersReady pod -l "app=$(LB_GATEWAY_IMAGE)" --timeout=$(E2E_WAIT_FOR_START_TIMEOUT) + kubectl get pods + pod_name=$$(kubectl get pods --selector="app=$(LB_GATEWAY_IMAGE)" | tail -1 | awk '{print $$1}'); \ + echo $$pod_name; \ + make E2E_TARGET_POD_NAME=$$pod_name e2e/index/job/correction + make k8s/vald/delete + $(MAKE) k3d/delete diff --git a/Makefile.d/functions.mk b/Makefile.d/functions.mk index 9b1aa47f8b..b797f4bd43 100644 --- a/Makefile.d/functions.mk +++ b/Makefile.d/functions.mk @@ -60,9 +60,9 @@ define go-build CFLAGS="$(CFLAGS)" \ CXXFLAGS="$(CXXFLAGS)" \ CGO_ENABLED=$(CGO_ENABLED) \ - CGO_CXXFLAGS="-g -Ofast -march=native" \ - CGO_FFLAGS="-g -Ofast -march=native" \ - CGO_LDFLAGS="-g -Ofast -march=native" \ + CGO_CXXFLAGS="$3" \ + CGO_FFLAGS="$3" \ + CGO_LDFLAGS="$3" \ GO111MODULE=on \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ @@ -106,6 +106,7 @@ define run-e2e-crud-test GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(HDF5_LDFLAGS)" \ go test \ -race \ -mod=readonly \ @@ -135,6 +136,7 @@ define run-e2e-crud-faiss-test GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(HDF5_LDFLAGS)" \ go test \ -race \ -mod=readonly \ @@ -160,6 +162,7 @@ define run-e2e-multi-crud-test GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(HDF5_LDFLAGS)" \ go test \ -race \ -mod=readonly \ @@ -189,6 +192,7 @@ define run-e2e-max-dim-test GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(HDF5_LDFLAGS)" \ go test \ -race \ -mod=readonly \ @@ -210,6 +214,7 @@ define run-e2e-sidecar-test GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(HDF5_LDFLAGS)" \ go test \ -race \ -mod=readonly \ @@ -295,6 +300,23 @@ define gen-license rm -rf $$BIN_PATH endef +define gen-dockerfile + BIN_PATH="$(TEMP_DIR)/vald-dockerfile-gen"; \ + rm -rf $$BIN_PATH; \ + MAINTAINER=$2 \ + GOPRIVATE=$(GOPRIVATE) \ + GOARCH=$(GOARCH) \ + GOOS=$(GOOS) \ + go build -modcacherw \ + -mod=readonly \ + -a \ + -tags "osusergo netgo static_build" \ + -trimpath \ + -o $$BIN_PATH $(ROOTDIR)/hack/docker/gen/main.go; \ + $$BIN_PATH $1; \ + rm -rf $$BIN_PATH +endef + define gen-vald-helm-schema BIN_PATH="$(TEMP_DIR)/vald-helm-schema-gen"; \ rm -rf $$BIN_PATH; \ @@ -333,14 +355,12 @@ define gen-vald-crd endef define update-github-actions - @for ACTION_NAME in $1; do \ + @set -e; for ACTION_NAME in $1; do \ if [ -n "$$ACTION_NAME" ] && [ "$$ACTION_NAME" != "security-and-quality" ]; then \ FILE_NAME=`echo $$ACTION_NAME | tr '/' '_' | tr '-' '_' | tr '[:lower:]' '[:upper:]'`; \ if [ -n "$$FILE_NAME" ]; then \ if [ "$$ACTION_NAME" = "aquasecurity/trivy-action" ] || [ "$$ACTION_NAME" = "machine-learning-apps/actions-chatops" ]; then \ VERSION="master"; \ - elif [ "$$ACTION_NAME" = "softprops/action-gh-release" ]; then \ - VERSION="1.0.0"; \ else \ REPO_NAME=`echo $$ACTION_NAME | cut -d'/' -f1-2`; \ VERSION=`curl -fsSL https://api.github.com/repos/$$REPO_NAME/releases/latest | grep -Po '"tag_name": "\K.*?(?=")' | sed 's/v//g' | sed -E 's/[^0-9.]+//g'`;\ diff --git a/Makefile.d/k3d.mk b/Makefile.d/k3d.mk index 4c0921a076..7449df203c 100644 --- a/Makefile.d/k3d.mk +++ b/Makefile.d/k3d.mk @@ -51,4 +51,4 @@ k3d/restart: \ .PHONY: k3d/delete ## stop k3d (kubernetes in docker) cluster k3d/delete: - $(K3D_COMMAND) cluster delete $(K3D_CLUSTER_NAME) + -$(K3D_COMMAND) cluster delete $(K3D_CLUSTER_NAME) diff --git a/Makefile.d/k8s.mk b/Makefile.d/k8s.mk index 51af5d2d14..23c6d9f77a 100644 --- a/Makefile.d/k8s.mk +++ b/Makefile.d/k8s.mk @@ -18,7 +18,7 @@ JAEGER_OPERATOR_WAIT_DURATION := 0 MIRROR01_NAMESPACE = vald-01 MIRROR02_NAMESPACE = vald-02 MIRROR03_NAMESPACE = vald-03 -MIRROR_APP_NAME = vald-mirror-gateway +MIRROR_APP_NAME = vald-mirror-gateway .PHONY: k8s/manifest/clean ## clean k8s manifests @@ -58,15 +58,15 @@ k8s/manifest/update: \ ## clean k8s manifests for helm-operator k8s/manifest/helm-operator/clean: rm -rf \ - k8s/operator/helm + k8s/operator/helm .PHONY: k8s/manifest/helm-operator/update ## update k8s manifests for helm-operatorusing helm templates k8s/manifest/helm-operator/update: \ k8s/manifest/helm-operator/clean helm template \ - --output-dir $(TEMP_DIR) \ - charts/vald-helm-operator + --output-dir $(TEMP_DIR) \ + charts/vald-helm-operator mkdir -p k8s/operator mv $(TEMP_DIR)/vald-helm-operator/templates k8s/operator/helm rm -rf $(TEMP_DIR) @@ -76,15 +76,15 @@ k8s/manifest/helm-operator/update: \ ## clean k8s manifests for benchmark-operator k8s/manifest/benchmark-operator/clean: rm -rf \ - k8s/tools/benchmark/operator + k8s/tools/benchmark/operator .PHONY: k8s/manifest/benchmark-operator/update ## update k8s manifests for benchmark-operator using helm templates k8s/manifest/benchmark-operator/update: \ k8s/manifest/benchmark-operator/clean helm template \ - --output-dir $(TEMP_DIR) \ - charts/vald-benchmark-operator + --output-dir $(TEMP_DIR) \ + charts/vald-benchmark-operator mkdir -p k8s/tools/benchmark mv $(TEMP_DIR)/vald-benchmark-operator/templates k8s/tools/benchmark/operator rm -rf $(TEMP_DIR) @@ -94,15 +94,15 @@ k8s/manifest/benchmark-operator/update: \ ## clean k8s manifests for readreplica k8s/manifest/readreplica/clean: rm -rf \ - k8s/readreplica + k8s/readreplica .PHONY: k8s/manifest/readreplica/update ## update k8s manifests for readreplica using helm templates k8s/manifest/readreplica/update: \ k8s/manifest/readreplica/clean helm template \ - --output-dir $(TEMP_DIR) \ - charts/vald-readreplica + --output-dir $(TEMP_DIR) \ + charts/vald-readreplica mv $(TEMP_DIR)/vald-readreplica/templates k8s/readreplica rm -rf $(TEMP_DIR) @@ -110,22 +110,22 @@ k8s/manifest/readreplica/update: \ ## deploy vald sample cluster to k8s k8s/vald/deploy: helm template \ - --values $(HELM_VALUES) \ - --set defaults.image.tag=$(VERSION) \ - --set agent.image.repository=$(CRORG)/$(AGENT_NGT_IMAGE) \ - --set agent.sidecar.image.repository=$(CRORG)/$(AGENT_SIDECAR_IMAGE) \ - --set discoverer.image.repository=$(CRORG)/$(DISCOVERER_IMAGE) \ - --set gateway.filter.image.repository=$(CRORG)/$(FILTER_GATEWAY_IMAGE) \ - --set gateway.lb.image.repository=$(CRORG)/$(LB_GATEWAY_IMAGE) \ - --set gateway.mirror.image.repository=$(CRORG)/$(MIRROR_GATEWAY_IMAGE) \ - --set manager.index.image.repository=$(CRORG)/$(MANAGER_INDEX_IMAGE) \ - --set manager.index.creator.image.repository=$(CRORG)/$(INDEX_CREATION_IMAGE) \ - --set manager.index.saver.image.repository=$(CRORG)/$(INDEX_SAVE_IMAGE) \ + --values $(HELM_VALUES) \ + --set defaults.image.tag=$(VERSION) \ + --set agent.image.repository=$(CRORG)/$(AGENT_NGT_IMAGE) \ + --set agent.sidecar.image.repository=$(CRORG)/$(AGENT_SIDECAR_IMAGE) \ + --set discoverer.image.repository=$(CRORG)/$(DISCOVERER_IMAGE) \ + --set gateway.filter.image.repository=$(CRORG)/$(FILTER_GATEWAY_IMAGE) \ + --set gateway.lb.image.repository=$(CRORG)/$(LB_GATEWAY_IMAGE) \ + --set gateway.mirror.image.repository=$(CRORG)/$(MIRROR_GATEWAY_IMAGE) \ + --set manager.index.image.repository=$(CRORG)/$(MANAGER_INDEX_IMAGE) \ + --set manager.index.creator.image.repository=$(CRORG)/$(INDEX_CREATION_IMAGE) \ + --set manager.index.saver.image.repository=$(CRORG)/$(INDEX_SAVE_IMAGE) \ --set manager.index.operator.image.repository=$(CRORG)/$(INDEX_OPERATOR_IMAGE) \ - $(HELM_EXTRA_OPTIONS) \ - --include-crds \ - --output-dir $(TEMP_DIR) \ - charts/vald + $(HELM_EXTRA_OPTIONS) \ + --include-crds \ + --output-dir $(TEMP_DIR) \ + charts/vald @echo "Permitting error because there's some cases nothing to apply" kubectl apply -f $(TEMP_DIR)/vald/templates/manager/index || true kubectl apply -f $(TEMP_DIR)/vald/templates/agent || true @@ -148,19 +148,19 @@ k8s/vald/deploy: ## delete vald sample cluster from k8s k8s/vald/delete: helm template \ - --values $(HELM_VALUES) \ - --set defaults.image.tag=$(VERSION) \ - --set agent.image.repository=$(CRORG)/$(AGENT_NGT_IMAGE) \ - --set agent.sidecar.image.repository=$(CRORG)/$(AGENT_SIDECAR_IMAGE) \ - --set discoverer.image.repository=$(CRORG)/$(DISCOVERER_IMAGE) \ - --set gateway.filter.image.repository=$(CRORG)/$(FILTER_GATEWAY_IMAGE) \ - --set gateway.lb.image.repository=$(CRORG)/$(LB_GATEWAY_IMAGE) \ - --set gateway.mirror.image.repository=$(CRORG)/$(MIRROR_GATEWAY_IMAGE) \ - --set manager.index.image.repository=$(CRORG)/$(MANAGER_INDEX_IMAGE) \ + --values $(HELM_VALUES) \ + --set defaults.image.tag=$(VERSION) \ + --set agent.image.repository=$(CRORG)/$(AGENT_NGT_IMAGE) \ + --set agent.sidecar.image.repository=$(CRORG)/$(AGENT_SIDECAR_IMAGE) \ + --set discoverer.image.repository=$(CRORG)/$(DISCOVERER_IMAGE) \ + --set gateway.filter.image.repository=$(CRORG)/$(FILTER_GATEWAY_IMAGE) \ + --set gateway.lb.image.repository=$(CRORG)/$(LB_GATEWAY_IMAGE) \ + --set gateway.mirror.image.repository=$(CRORG)/$(MIRROR_GATEWAY_IMAGE) \ + --set manager.index.image.repository=$(CRORG)/$(MANAGER_INDEX_IMAGE) \ --set manager.index.operator.image.repository=$(CRORG)/$(INDEX_OPERATOR_IMAGE) \ - --include-crds \ - --output-dir $(TEMP_DIR) \ - charts/vald + --include-crds \ + --output-dir $(TEMP_DIR) \ + charts/vald kubectl delete -f $(TEMP_DIR)/vald/templates/gateway/mirror || true kubectl delete -f $(TEMP_DIR)/vald/templates/index/operator || true kubectl delete -f $(TEMP_DIR)/vald/templates/index/job/readreplica/rotate || true @@ -188,11 +188,11 @@ k8s/multi/vald/deploy: helm install vald-cluster-01 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) + -n $(MIRROR01_NAMESPACE) helm install vald-cluster-02 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) + -n $(MIRROR02_NAMESPACE) helm install vald-cluster-03 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 \ @@ -215,11 +215,11 @@ k8s/multi/vald/delete: ## deploy vald-helm-operator to k8s k8s/vald-helm-operator/deploy: helm template \ - --output-dir $(TEMP_DIR) \ - --set image.tag=$(VERSION) \ - $(HELM_EXTRA_OPTIONS) \ - --include-crds \ - charts/vald-helm-operator + --output-dir $(TEMP_DIR) \ + --set image.tag=$(VERSION) \ + $(HELM_EXTRA_OPTIONS) \ + --include-crds \ + charts/vald-helm-operator kubectl create -f $(TEMP_DIR)/vald-helm-operator/crds/valdrelease.yaml kubectl create -f $(TEMP_DIR)/vald-helm-operator/crds/valdhelmoperatorrelease.yaml kubectl apply -f $(TEMP_DIR)/vald-helm-operator/templates @@ -230,10 +230,10 @@ k8s/vald-helm-operator/deploy: ## delete vald-helm-operator from k8s k8s/vald-helm-operator/delete: helm template \ - --output-dir $(TEMP_DIR) \ - --set image.tag=$(VERSION) \ - --include-crds \ - charts/vald-helm-operator + --output-dir $(TEMP_DIR) \ + --set image.tag=$(VERSION) \ + --include-crds \ + charts/vald-helm-operator kubectl delete -f $(TEMP_DIR)/vald-helm-operator/templates kubectl wait --for=delete pod -l name=vald-helm-operator --timeout=600s kubectl delete -f $(TEMP_DIR)/vald-helm-operator/crds @@ -243,19 +243,19 @@ k8s/vald-helm-operator/delete: ## deploy vald-readreplica to k8s k8s/vald-readreplica/deploy: helm template \ - --values $(HELM_VALUES) \ - --set defaults.image.tag=$(VERSION) \ - --set agent.image.repository=$(CRORG)/$(AGENT_NGT_IMAGE) \ - --set agent.sidecar.image.repository=$(CRORG)/$(AGENT_SIDECAR_IMAGE) \ - --set discoverer.image.repository=$(CRORG)/$(DISCOVERER_IMAGE) \ - --set gateway.filter.image.repository=$(CRORG)/$(FILTER_GATEWAY_IMAGE) \ - --set gateway.lb.image.repository=$(CRORG)/$(LB_GATEWAY_IMAGE) \ - --set manager.index.image.repository=$(CRORG)/$(MANAGER_INDEX_IMAGE) \ - --set manager.index.creator.image.repository=$(CRORG)/$(INDEX_CREATION_IMAGE) \ - --set manager.index.saver.image.repository=$(CRORG)/$(INDEX_SAVE_IMAGE) \ - $(HELM_EXTRA_OPTIONS) \ - --output-dir $(TEMP_DIR) \ - charts/vald-readreplica + --values $(HELM_VALUES) \ + --set defaults.image.tag=$(VERSION) \ + --set agent.image.repository=$(CRORG)/$(AGENT_NGT_IMAGE) \ + --set agent.sidecar.image.repository=$(CRORG)/$(AGENT_SIDECAR_IMAGE) \ + --set discoverer.image.repository=$(CRORG)/$(DISCOVERER_IMAGE) \ + --set gateway.filter.image.repository=$(CRORG)/$(FILTER_GATEWAY_IMAGE) \ + --set gateway.lb.image.repository=$(CRORG)/$(LB_GATEWAY_IMAGE) \ + --set manager.index.image.repository=$(CRORG)/$(MANAGER_INDEX_IMAGE) \ + --set manager.index.creator.image.repository=$(CRORG)/$(INDEX_CREATION_IMAGE) \ + --set manager.index.saver.image.repository=$(CRORG)/$(INDEX_SAVE_IMAGE) \ + $(HELM_EXTRA_OPTIONS) \ + --output-dir $(TEMP_DIR) \ + charts/vald-readreplica kubectl apply -f $(TEMP_DIR)/vald-readreplica/templates sleep 2 kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=vald-readreplica --timeout=600s @@ -264,16 +264,16 @@ k8s/vald-readreplica/deploy: ## delete vald-helm-operator from k8s k8s/vald-readreplica/delete: helm template \ - --values $(HELM_VALUES) \ - --set defaults.image.tag=$(VERSION) \ - --set agent.image.repository=$(CRORG)/$(AGENT_NGT_IMAGE) \ - --set agent.sidecar.image.repository=$(CRORG)/$(AGENT_SIDECAR_IMAGE) \ - --set discoverer.image.repository=$(CRORG)/$(DISCOVERER_IMAGE) \ - --set gateway.filter.image.repository=$(CRORG)/$(FILTER_GATEWAY_IMAGE) \ - --set gateway.lb.image.repository=$(CRORG)/$(LB_GATEWAY_IMAGE) \ - --set manager.index.image.repository=$(CRORG)/$(MANAGER_INDEX_IMAGE) \ - --output-dir $(TEMP_DIR) \ - charts/vald-readreplica + --values $(HELM_VALUES) \ + --set defaults.image.tag=$(VERSION) \ + --set agent.image.repository=$(CRORG)/$(AGENT_NGT_IMAGE) \ + --set agent.sidecar.image.repository=$(CRORG)/$(AGENT_SIDECAR_IMAGE) \ + --set discoverer.image.repository=$(CRORG)/$(DISCOVERER_IMAGE) \ + --set gateway.filter.image.repository=$(CRORG)/$(FILTER_GATEWAY_IMAGE) \ + --set gateway.lb.image.repository=$(CRORG)/$(LB_GATEWAY_IMAGE) \ + --set manager.index.image.repository=$(CRORG)/$(MANAGER_INDEX_IMAGE) \ + --output-dir $(TEMP_DIR) \ + charts/vald-readreplica kubectl delete -f $(TEMP_DIR)/vald-readreplica/templates kubectl wait --for=delete pod -l app.kubernetes.io/name=vald-readreplica --timeout=600s rm -rf $(TEMP_DIR) @@ -284,9 +284,9 @@ k8s/vr/deploy: \ yq/install \ k8s/metrics/metrics-server/deploy yq eval \ - '{"apiVersion": "vald.vdaas.org/v1", "kind": "ValdRelease", "metadata":{"name":"vald-cluster"}, "spec": .}' \ - $(HELM_VALUES) \ - | kubectl apply -f - + '{"apiVersion": "vald.vdaas.org/v1", "kind": "ValdRelease", "metadata":{"name":"vald-cluster"}, "spec": .}' \ + $(HELM_VALUES) \ + | kubectl apply -f - .PHONY: k8s/vr/delete ## delete ValdRelease resource from k8s @@ -298,10 +298,10 @@ k8s/vr/delete: \ ## deploy vald-benchmark-operator to k8s k8s/vald-benchmark-operator/deploy: helm template \ - --output-dir $(TEMP_DIR) \ - --set image.tag=${VERSION} \ - --include-crds \ - charts/vald-benchmark-operator + --output-dir $(TEMP_DIR) \ + --set image.tag=${VERSION} \ + --include-crds \ + charts/vald-benchmark-operator kubectl create -f $(TEMP_DIR)/vald-benchmark-operator/crds/valdbenchmarkjob.yaml kubectl create -f $(TEMP_DIR)/vald-benchmark-operator/crds/valdbenchmarkscenario.yaml kubectl create -f $(TEMP_DIR)/vald-benchmark-operator/crds/valdbenchmarkoperatorrelease.yaml @@ -313,10 +313,10 @@ k8s/vald-benchmark-operator/deploy: ## delete vald-benchmark-operator from k8s k8s/vald-benchmark-operator/delete: helm template \ - --output-dir $(TEMP_DIR) \ - --set image.tag=${VERSION} \ - --include-crds \ - charts/vald-benchmark-operator + --output-dir $(TEMP_DIR) \ + --set image.tag=${VERSION} \ + --include-crds \ + charts/vald-benchmark-operator kubectl delete -f $(TEMP_DIR)/vald-benchmark-operator/templates kubectl wait --for=delete pod -l name=vald-benchmark-operator --timeout=600s kubectl delete -f $(TEMP_DIR)/vald-benchmark-operator/crds @@ -357,15 +357,14 @@ k8s/external/minio/delete: .PHONY: k8s/metrics/metrics-server/deploy ## deploy metrics-serrver k8s/metrics/metrics-server/deploy: - kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml - kubectl patch deployment metrics-server -n kube-system -p '{"spec":{"template":{"spec":{"containers":[{"name":"metrics-server","args":["--cert-dir=/tmp", "--secure-port=4443", "--kubelet-insecure-tls","--kubelet-preferred-address-types=InternalIP"]}]}}}}' + helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/ + helm install metrics-server metrics-server/metrics-server -n kube-system sleep $(K8S_SLEEP_DURATION_FOR_WAIT_COMMAND) - # kubectl wait -n kube-system --for=condition=ready pod -l k8s-app=metrics-server --timeout=600s .PHONY: k8s/metrics/metrics-server/delete ## delete metrics-serrver k8s/metrics/metrics-server/delete: - kubectl delete -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml + helm uninstall metrics-server --ignore-not-found -n kube-system .PHONY: k8s/metrics/prometheus/deploy ## deploy prometheus @@ -531,8 +530,8 @@ telepresence/install: $(BINDIR)/telepresence $(BINDIR)/telepresence: mkdir -p $(BINDIR) cd $(TEMP_DIR) \ - && curl -fsSL "https://app.getambassador.io/download/tel2oss/releases/download/v$(TELEPRESENCE_VERSION)/telepresence-$(OS)-$(subst x86_64,amd64,$(shell echo $(ARCH) | tr '[:upper:]' '[:lower:]'))" -o $(BINDIR)/telepresence \ - && chmod a+x $(BINDIR)/telepresence + && curl -fsSL "https://app.getambassador.io/download/tel2oss/releases/download/v$(TELEPRESENCE_VERSION)/telepresence-$(OS)-$(subst x86_64,amd64,$(shell echo $(ARCH) | tr '[:upper:]' '[:lower:]'))" -o $(BINDIR)/telepresence \ + && chmod a+x $(BINDIR)/telepresence .PHONY: telepresence/swap/agent-ngt ## swap agent-ngt deployment using telepresence @@ -566,5 +565,5 @@ kubelinter/install: $(BINDIR)/kube-linter $(BINDIR)/kube-linter: mkdir -p $(BINDIR) cd $(TEMP_DIR) \ - && curl -fsSL https://github.com/stackrox/kube-linter/releases/download/$(KUBELINTER_VERSION)/kube-linter-$(OS) -o $(BINDIR)/kube-linter \ - && chmod a+x $(BINDIR)/kube-linter + && curl -fsSL https://github.com/stackrox/kube-linter/releases/download/$(KUBELINTER_VERSION)/kube-linter-$(OS) -o $(BINDIR)/kube-linter \ + && chmod a+x $(BINDIR)/kube-linter diff --git a/Makefile.d/proto.mk b/Makefile.d/proto.mk index 8598ef246d..50669a111f 100644 --- a/Makefile.d/proto.mk +++ b/Makefile.d/proto.mk @@ -54,8 +54,14 @@ proto/gen: \ $(PROTOS) \ proto/deps @$(call green, "generating pb.go and swagger.json files and documents for API v1...") + buf format -w buf generate + make proto/replace + +proto/replace: find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs -P$(CORES) sed -i -E "s%google.golang.org/grpc/codes%github.com/vdaas/vald/internal/net/grpc/codes%g" find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs -P$(CORES) sed -i -E "s%google.golang.org/grpc/status%github.com/vdaas/vald/internal/net/grpc/status%g" find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs -P$(CORES) sed -i -E "s%\"io\"%\"github.com/vdaas/vald/internal/io\"%g" find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs -P$(CORES) sed -i -E "s%\"sync\"%\"github.com/vdaas/vald/internal/sync\"%g" + find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs -P$(CORES) sed -i -E "s%interface\{\}%any%g" + find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs -P$(CORES) sed -i -E "s%For_%For%g" diff --git a/Makefile.d/test.mk b/Makefile.d/test.mk index 3487acde3e..2ecf16a87b 100644 --- a/Makefile.d/test.mk +++ b/Makefile.d/test.mk @@ -45,6 +45,7 @@ test: GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/cmd/... $(ROOTDIR)/internal/... $(ROOTDIR)/pkg/... .PHONY: test/tparse @@ -56,6 +57,7 @@ test/tparse: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/cmd/... $(ROOTDIR)/internal/... $(ROOTDIR)/pkg/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -69,6 +71,7 @@ test/cmd/tparse: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/cmd/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -82,6 +85,7 @@ test/internal/tparse: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/internal/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -95,6 +99,7 @@ test/pkg/tparse: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/pkg/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -110,6 +115,7 @@ test/hack/tparse: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=vendor -json -cover \ $(ROOTDIR)/hack/gorules/... \ $(ROOTDIR)/hack/helm/... \ @@ -128,6 +134,7 @@ test/all/tparse: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -141,6 +148,7 @@ test/gotestfmt: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/cmd/... $(ROOTDIR)/internal/... $(ROOTDIR)/pkg/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus @@ -154,6 +162,7 @@ test/cmd/gotestfmt: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/cmd/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus @@ -167,6 +176,7 @@ test/internal/gotestfmt: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/internal/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus @@ -180,6 +190,7 @@ test/pkg/gotestfmt: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/pkg/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus @@ -195,6 +206,7 @@ test/hack/gotestfmt: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=vendor -json -cover \ $(ROOTDIR)/hack/gorules/... \ $(ROOTDIR)/hack/helm/... \ @@ -213,6 +225,7 @@ test/all/gotestfmt: \ GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) $(ROOTDIR)/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus @@ -250,6 +263,7 @@ test/pkg: GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -cover $(ROOTDIR)/pkg/... .PHONY: test/internal @@ -258,6 +272,7 @@ test/internal: GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -cover $(ROOTDIR)/internal/... .PHONY: test/cmd @@ -266,6 +281,7 @@ test/cmd: GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -cover $(ROOTDIR)/cmd/... .PHONY: test/hack @@ -276,6 +292,7 @@ test/hack: GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=vendor -cover \ $(ROOTDIR)/hack/gorules... \ $(ROOTDIR)/hack/helm/... \ @@ -289,6 +306,7 @@ test/all: GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -cover $(ROOTDIR)/... .PHONY: coverage @@ -297,6 +315,7 @@ coverage: GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ + CGO_LDFLAGS="$(CGO_LDFLAGS)" \ go test -short -shuffle=on -race -mod=readonly -v -race -covermode=atomic -timeout=$(GOTEST_TIMEOUT) -coverprofile=coverage.out $(ROOTDIR)/... GOPRIVATE=$(GOPRIVATE) \ GOARCH=$(GOARCH) \ @@ -349,7 +368,8 @@ test/patch-placeholder: .PHONY: test/comment-unimplemented ## comment out unimplemented tests -test/comment-unimplemented: +test/comment-unimplemented: \ + format/go/test @$(call green, "comment out unimplemented test...") @for f in $(GO_ALL_TEST_SOURCES) ; do \ if [ ! -f "$$f" ] ; then continue; fi; \ diff --git a/Makefile.d/tools.mk b/Makefile.d/tools.mk index ac7838a877..59b06c60d7 100644 --- a/Makefile.d/tools.mk +++ b/Makefile.d/tools.mk @@ -46,9 +46,16 @@ golines/install: $(GOBIN)/golines $(GOBIN)/golines: $(call go-install, github.com/segmentio/golines) +.PHONY: crlfmt/install +crlfmt/install: $(GOBIN)/crlfmt + +$(GOBIN)/crlfmt: + $(call go-install, github.com/cockroachdb/crlfmt) + .PHONY: prettier/install prettier/install: $(BINDIR)/prettier $(BINDIR)/prettier: + npm config set registry http://registry.npmjs.org/ type prettier || npm install -g prettier .PHONY: reviewdog/install @@ -81,7 +88,7 @@ textlint/ci/install: cspell/install: $(NPM_GLOBAL_PREFIX)/bin/cspell $(NPM_GLOBAL_PREFIX)/bin/cspell: - npm install -g git+https://github.com/streetsidesoftware/cspell-cli + npm install -g cspell@latest .PHONY: buf/install buf/install: $(BINDIR)/buf @@ -164,3 +171,57 @@ rust/install: $(CARGO_HOME)/bin/cargo $(CARGO_HOME)/bin/cargo: curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | CARGO_HOME=${CARGO_HOME} RUSTUP_HOME=${RUSTUP_HOME} sh -s -- --default-toolchain $(RUST_VERSION) -y source "${CARGO_HOME}/env" + +.PHONY: zlib/install +zlib/install: $(LIB_PATH)/libz.a + +$(LIB_PATH)/libz.a: $(LIB_PATH) + curl -fsSL https://github.com/madler/zlib/releases/download/v$(ZLIB_VERSION)/zlib-$(ZLIB_VERSION).tar.gz -o $(TEMP_DIR)/zlib-$(ZLIB_VERSION).tar.gz \ + && mkdir -p $(TEMP_DIR)/zlib \ + && tar -xzvf $(TEMP_DIR)/zlib-$(ZLIB_VERSION).tar.gz -C $(TEMP_DIR)/zlib --strip-components 1 \ + && cd $(TEMP_DIR)/zlib \ + && mkdir -p build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release \ + -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 \ + .. \ + && make -j$(CORES) \ + && make install \ + && cd $(ROOTDIR) \ + && rm -rf $(TEMP_DIR)/zlib-$(ZLIB_VERSION).tar.gz $(TEMP_DIR)/zlib $(LIB_PATH)/libz.s* + +.PHONY: hdf5/install +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 \ + && mkdir $(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 \ + .. \ + && make -j$(CORES) \ + && make install \ + && cd $(ROOTDIR) \ + && rm -rf $(TEMP_DIR)/hdf5.tar.gz $(TEMP_DIR)/HDF5_VERSION diff --git a/apis/docs/v1/docs.md b/apis/docs/v1/docs.md index 2a4a50ecb7..2289344848 100644 --- a/apis/docs/v1/docs.md +++ b/apis/docs/v1/docs.md @@ -23,6 +23,11 @@ - [Info.IPs](#payload-v1-Info-IPs) - [Info.Index](#payload-v1-Info-Index) - [Info.Index.Count](#payload-v1-Info-Index-Count) + - [Info.Index.Detail](#payload-v1-Info-Index-Detail) + - [Info.Index.Detail.CountsEntry](#payload-v1-Info-Index-Detail-CountsEntry) + - [Info.Index.Statistics](#payload-v1-Info-Index-Statistics) + - [Info.Index.StatisticsDetail](#payload-v1-Info-Index-StatisticsDetail) + - [Info.Index.StatisticsDetail.DetailsEntry](#payload-v1-Info-Index-StatisticsDetail-DetailsEntry) - [Info.Index.UUID](#payload-v1-Info-Index-UUID) - [Info.Index.UUID.Committed](#payload-v1-Info-Index-UUID-Committed) - [Info.Index.UUID.Uncommitted](#payload-v1-Info-Index-UUID-Uncommitted) @@ -48,7 +53,6 @@ - [Object](#payload-v1-Object) - [Object.Blob](#payload-v1-Object-Blob) - [Object.Distance](#payload-v1-Object-Distance) - - [Object.GetTimestampRequest](#payload-v1-Object-GetTimestampRequest) - [Object.ID](#payload-v1-Object-ID) - [Object.IDs](#payload-v1-Object-IDs) - [Object.List](#payload-v1-Object-List) @@ -62,6 +66,7 @@ - [Object.StreamLocation](#payload-v1-Object-StreamLocation) - [Object.StreamVector](#payload-v1-Object-StreamVector) - [Object.Timestamp](#payload-v1-Object-Timestamp) + - [Object.TimestampRequest](#payload-v1-Object-TimestampRequest) - [Object.Vector](#payload-v1-Object-Vector) - [Object.VectorRequest](#payload-v1-Object-VectorRequest) - [Object.Vectors](#payload-v1-Object-Vectors) @@ -107,8 +112,6 @@ - [Filter](#filter-egress-v1-Filter) - [v1/filter/ingress/ingress_filter.proto](#v1_filter_ingress_ingress_filter-proto) - [Filter](#filter-ingress-v1-Filter) -- [v1/manager/index/index_manager.proto](#v1_manager_index_index_manager-proto) - - [Index](#manager-index-v1-Index) - [v1/mirror/mirror.proto](#v1_mirror_mirror-proto) - [Mirror](#mirror-v1-Mirror) - [v1/rpc/errdetails/error_details.proto](#v1_rpc_errdetails_error_details-proto) @@ -131,6 +134,8 @@ - [Filter](#vald-v1-Filter) - [v1/vald/flush.proto](#v1_vald_flush-proto) - [Flush](#vald-v1-Flush) +- [v1/vald/index.proto](#v1_vald_index-proto) + - [Index](#vald-v1-Index) - [v1/vald/insert.proto](#v1_vald_insert-proto) - [Insert](#vald-v1-Insert) - [v1/vald/object.proto](#v1_vald_object-proto) @@ -294,6 +299,88 @@ Represent the index count message. | indexing | [bool](#bool) | | The indexing index count. | | saving | [bool](#bool) | | The saving index count. | + + +### Info.Index.Detail + +Represent the index count for each Agents message. + +| Field | Type | Label | Description | +| ----------- | -------------------------------------------------------------------------- | -------- | ---------------------------------- | +| counts | [Info.Index.Detail.CountsEntry](#payload-v1-Info-Index-Detail-CountsEntry) | repeated | count infos for each agents | +| replica | [uint32](#uint32) | | index replica of vald cluster | +| live_agents | [uint32](#uint32) | | live agent replica of vald cluster | + + + +### Info.Index.Detail.CountsEntry + +| Field | Type | Label | Description | +| ----- | ------------------------------------------------ | ----- | ----------- | +| key | [string](#string) | | | +| value | [Info.Index.Count](#payload-v1-Info-Index-Count) | | | + + + +### Info.Index.Statistics + +Represents index Statistics + +| Field | Type | Label | Description | +| ------------------------------------ | ----------------- | -------- | ----------- | +| valid | [bool](#bool) | | | +| median_indegree | [int32](#int32) | | | +| median_outdegree | [int32](#int32) | | | +| max_number_of_indegree | [uint64](#uint64) | | | +| max_number_of_outdegree | [uint64](#uint64) | | | +| min_number_of_indegree | [uint64](#uint64) | | | +| min_number_of_outdegree | [uint64](#uint64) | | | +| mode_indegree | [uint64](#uint64) | | | +| mode_outdegree | [uint64](#uint64) | | | +| nodes_skipped_for_10_edges | [uint64](#uint64) | | | +| nodes_skipped_for_indegree_distance | [uint64](#uint64) | | | +| number_of_edges | [uint64](#uint64) | | | +| number_of_indexed_objects | [uint64](#uint64) | | | +| number_of_nodes | [uint64](#uint64) | | | +| number_of_nodes_without_edges | [uint64](#uint64) | | | +| number_of_nodes_without_indegree | [uint64](#uint64) | | | +| number_of_objects | [uint64](#uint64) | | | +| number_of_removed_objects | [uint64](#uint64) | | | +| size_of_object_repository | [uint64](#uint64) | | | +| size_of_refinement_object_repository | [uint64](#uint64) | | | +| variance_of_indegree | [double](#double) | | | +| variance_of_outdegree | [double](#double) | | | +| mean_edge_length | [double](#double) | | | +| mean_edge_length_for_10_edges | [double](#double) | | | +| mean_indegree_distance_for_10_edges | [double](#double) | | | +| mean_number_of_edges_per_node | [double](#double) | | | +| c1_indegree | [double](#double) | | | +| c5_indegree | [double](#double) | | | +| c95_outdegree | [double](#double) | | | +| c99_outdegree | [double](#double) | | | +| indegree_count | [int64](#int64) | repeated | | +| outdegree_histogram | [uint64](#uint64) | repeated | | +| indegree_histogram | [uint64](#uint64) | repeated | | + + + +### Info.Index.StatisticsDetail + +Represents index Statistics for each Agents + +| Field | Type | Label | Description | +| ------- | ------------------------------------------------------------------------------------------------ | -------- | --------------------------- | +| details | [Info.Index.StatisticsDetail.DetailsEntry](#payload-v1-Info-Index-StatisticsDetail-DetailsEntry) | repeated | count infos for each agents | + + + +### Info.Index.StatisticsDetail.DetailsEntry + +| Field | Type | Label | Description | +| ----- | ---------------------------------------------------------- | ----- | ----------- | +| key | [string](#string) | | | +| value | [Info.Index.Statistics](#payload-v1-Info-Index-Statistics) | | | + ### Info.Index.UUID @@ -554,16 +641,6 @@ Represent the ID and distance pair. | id | [string](#string) | | The vector ID. | | distance | [float](#float) | | The distance. | - - -### Object.GetTimestampRequest - -Represent a request to fetch vector meta data. - -| Field | Type | Label | Description | -| ----- | ---------------------------------- | ----- | ---------------------------- | -| id | [Object.ID](#payload-v1-Object-ID) | | The vector ID to be fetched. | - ### Object.ID @@ -691,6 +768,16 @@ Represent a vector meta data. | id | [string](#string) | | The vector ID. | | timestamp | [int64](#int64) | | timestamp represents when this vector inserted. | + + +### Object.TimestampRequest + +Represent a request to fetch vector meta data. + +| Field | Type | Label | Description | +| ----- | ---------------------------------- | ----- | ---------------------------- | +| id | [Object.ID](#payload-v1-Object-ID) | | The vector ID to be fetched. | + ### Object.Vector @@ -1069,13 +1156,11 @@ AggregationAlgorithm is enum of each aggregation algorithms Represent the agent service. -| Method Name | Request Type | Response Type | Description | -| ------------------ | -------------------------------------------------------------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | -| CreateIndex | [.payload.v1.Control.CreateIndexRequest](#payload-v1-Control-CreateIndexRequest) | [.payload.v1.Empty](#payload-v1-Empty) | Represent the creating index RPC. | -| SaveIndex | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Empty](#payload-v1-Empty) | Represent the saving index RPC. | -| CreateAndSaveIndex | [.payload.v1.Control.CreateIndexRequest](#payload-v1-Control-CreateIndexRequest) | [.payload.v1.Empty](#payload-v1-Empty) | Represent the creating and saving index RPC. | -| IndexInfo | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | Represent the RPC to get the agent index information. | -| GetTimestamp | [.payload.v1.Object.GetTimestampRequest](#payload-v1-Object-GetTimestampRequest) | [.payload.v1.Object.Timestamp](#payload-v1-Object-Timestamp) | Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process | +| Method Name | Request Type | Response Type | Description | +| ------------------ | -------------------------------------------------------------------------------- | -------------------------------------- | -------------------------------------------- | +| CreateIndex | [.payload.v1.Control.CreateIndexRequest](#payload-v1-Control-CreateIndexRequest) | [.payload.v1.Empty](#payload-v1-Empty) | Represent the creating index RPC. | +| SaveIndex | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Empty](#payload-v1-Empty) | Represent the saving index RPC. | +| CreateAndSaveIndex | [.payload.v1.Control.CreateIndexRequest](#payload-v1-Control-CreateIndexRequest) | [.payload.v1.Empty](#payload-v1-Empty) | Represent the creating and saving index RPC. | @@ -1144,22 +1229,6 @@ Represent the ingress filter service. | GenVector | [.payload.v1.Object.Blob](#payload-v1-Object-Blob) | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | Represent the RPC to generate the vector. | | FilterVector | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | Represent the RPC to filter the vector. | - - -

Top

- -## v1/manager/index/index_manager.proto - - - -### Index - -Represent the index manager service. - -| Method Name | Request Type | Response Type | Description | -| ----------- | -------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | -| IndexInfo | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | Represent the RPC to get the index information. | -

Top

@@ -1480,6 +1549,25 @@ Flush service provides ways to flush all indexed vectors. | ----------- | ------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------- | | Flush | [.payload.v1.Flush.Request](#payload-v1-Flush-Request) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | A method to flush all indexed vector. | + + +

Top

+ +## v1/vald/index.proto + + + +### Index + +Represent the index manager service. + +| Method Name | Request Type | Response Type | Description | +| --------------------- | -------------------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | +| IndexInfo | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | Represent the RPC to get the index information. | +| IndexDetail | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Detail](#payload-v1-Info-Index-Detail) | Represent the RPC to get the index information for each agents. | +| IndexStatistics | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Statistics](#payload-v1-Info-Index-Statistics) | Represent the RPC to get the index statistics. | +| IndexStatisticsDetail | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.StatisticsDetail](#payload-v1-Info-Index-StatisticsDetail) | Represent the RPC to get the index statistics for each agents. | +

Top

@@ -1510,12 +1598,13 @@ Insert service provides ways to add new vectors. Object service provides ways to fetch indexed vectors. -| Method Name | Request Type | Response Type | Description | -| ---------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | ----------------------------------------------------------- | -| Exists | [.payload.v1.Object.ID](#payload-v1-Object-ID) | [.payload.v1.Object.ID](#payload-v1-Object-ID) | A method to check whether a specified ID is indexed or not. | -| GetObject | [.payload.v1.Object.VectorRequest](#payload-v1-Object-VectorRequest) | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | A method to fetch a vector. | -| StreamGetObject | [.payload.v1.Object.VectorRequest](#payload-v1-Object-VectorRequest) stream | [.payload.v1.Object.StreamVector](#payload-v1-Object-StreamVector) stream | A method to fetch vectors by bidirectional streaming. | -| StreamListObject | [.payload.v1.Object.List.Request](#payload-v1-Object-List-Request) | [.payload.v1.Object.List.Response](#payload-v1-Object-List-Response) stream | A method to get all the vectors with server streaming | +| Method Name | Request Type | Response Type | Description | +| ---------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| Exists | [.payload.v1.Object.ID](#payload-v1-Object-ID) | [.payload.v1.Object.ID](#payload-v1-Object-ID) | A method to check whether a specified ID is indexed or not. | +| GetObject | [.payload.v1.Object.VectorRequest](#payload-v1-Object-VectorRequest) | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | A method to fetch a vector. | +| StreamGetObject | [.payload.v1.Object.VectorRequest](#payload-v1-Object-VectorRequest) stream | [.payload.v1.Object.StreamVector](#payload-v1-Object-StreamVector) stream | A method to fetch vectors by bidirectional streaming. | +| StreamListObject | [.payload.v1.Object.List.Request](#payload-v1-Object-List-Request) | [.payload.v1.Object.List.Response](#payload-v1-Object-List-Response) stream | A method to get all the vectors with server streaming | +| GetTimestamp | [.payload.v1.Object.TimestampRequest](#payload-v1-Object-TimestampRequest) | [.payload.v1.Object.Timestamp](#payload-v1-Object-Timestamp) | Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process | diff --git a/apis/grpc/v1/agent/core/agent.go b/apis/grpc/v1/agent/core/agent.go index 5714ae993a..caf77ef2a2 100644 --- a/apis/grpc/v1/agent/core/agent.go +++ b/apis/grpc/v1/agent/core/agent.go @@ -21,6 +21,4 @@ const ( CreateIndexRPCName = "CreateIndex" SaveIndexRPCName = "SaveIndex" CreateAndSaveIndexRPCName = "CreateAndSaveIndex" - IndexInfoRPCName = "IndexInfo" - GetTimestampRPCName = "GetTimestamp" ) diff --git a/apis/grpc/v1/agent/core/agent.pb.go b/apis/grpc/v1/agent/core/agent.pb.go index 7b70659a66..42f03029a9 100644 --- a/apis/grpc/v1/agent/core/agent.pb.go +++ b/apis/grpc/v1/agent/core/agent.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/agent/core/agent.proto @@ -46,66 +46,50 @@ var file_v1_agent_core_agent_proto_rawDesc = []byte{ 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2f, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xde, 0x03, 0x0a, - 0x05, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x12, 0x5f, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xb7, 0x02, 0x0a, + 0x05, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x12, 0x6b, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x26, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, - 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x46, 0x0a, 0x09, 0x53, 0x61, 0x76, 0x65, 0x49, - 0x6e, 0x64, 0x65, 0x78, 0x12, 0x11, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, - 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x0d, 0x12, 0x0b, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x73, 0x61, 0x76, 0x65, 0x12, - 0x6d, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x6e, 0x64, 0x53, 0x61, 0x76, 0x65, - 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x26, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, - 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, - 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, - 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x61, 0x6e, 0x64, 0x73, 0x61, 0x76, 0x65, 0x12, 0x51, - 0x0a, 0x09, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x11, 0x2e, 0x70, 0x61, - 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1c, - 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, - 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x0d, 0x12, 0x0b, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x69, 0x6e, 0x66, - 0x6f, 0x12, 0x6a, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x12, 0x26, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x61, 0x79, 0x6c, - 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x12, - 0x0c, 0x2f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x42, 0x63, 0x0a, - 0x20, 0x6f, 0x72, 0x67, 0x2e, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2e, 0x76, 0x61, 0x6c, 0x64, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x63, 0x6f, 0x72, - 0x65, 0x42, 0x09, 0x56, 0x61, 0x6c, 0x64, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x50, 0x01, 0x5a, 0x32, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x64, 0x61, 0x61, 0x73, - 0x2f, 0x76, 0x61, 0x6c, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, - 0x76, 0x31, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x3b, 0x63, 0x6f, - 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x12, 0x19, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x2f, 0x7b, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, 0x73, 0x69, + 0x7a, 0x65, 0x7d, 0x12, 0x46, 0x0a, 0x09, 0x53, 0x61, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, + 0x12, 0x11, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x12, 0x0b, + 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x73, 0x61, 0x76, 0x65, 0x12, 0x79, 0x0a, 0x12, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x6e, 0x64, 0x53, 0x61, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, + 0x78, 0x12, 0x26, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, + 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x28, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x22, 0x12, 0x20, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x61, 0x6e, 0x64, 0x73, 0x61, 0x76, 0x65, 0x2f, 0x7b, 0x70, 0x6f, 0x6f, 0x6c, + 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x7d, 0x42, 0x63, 0x0a, 0x20, 0x6f, 0x72, 0x67, 0x2e, 0x76, 0x64, + 0x61, 0x61, 0x73, 0x2e, 0x76, 0x61, 0x6c, 0x64, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x42, 0x09, 0x56, 0x61, 0x6c, 0x64, + 0x41, 0x67, 0x65, 0x6e, 0x74, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2f, 0x76, 0x61, 0x6c, 0x64, 0x2f, 0x61, + 0x70, 0x69, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x67, 0x65, 0x6e, + 0x74, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x3b, 0x63, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } -var file_v1_agent_core_agent_proto_goTypes = []interface{}{ +var file_v1_agent_core_agent_proto_goTypes = []any{ (*payload.Control_CreateIndexRequest)(nil), // 0: payload.v1.Control.CreateIndexRequest (*payload.Empty)(nil), // 1: payload.v1.Empty - (*payload.Object_GetTimestampRequest)(nil), // 2: payload.v1.Object.GetTimestampRequest - (*payload.Info_Index_Count)(nil), // 3: payload.v1.Info.Index.Count - (*payload.Object_Timestamp)(nil), // 4: payload.v1.Object.Timestamp } + var file_v1_agent_core_agent_proto_depIdxs = []int32{ 0, // 0: core.v1.Agent.CreateIndex:input_type -> payload.v1.Control.CreateIndexRequest 1, // 1: core.v1.Agent.SaveIndex:input_type -> payload.v1.Empty 0, // 2: core.v1.Agent.CreateAndSaveIndex:input_type -> payload.v1.Control.CreateIndexRequest - 1, // 3: core.v1.Agent.IndexInfo:input_type -> payload.v1.Empty - 2, // 4: core.v1.Agent.GetTimestamp:input_type -> payload.v1.Object.GetTimestampRequest - 1, // 5: core.v1.Agent.CreateIndex:output_type -> payload.v1.Empty - 1, // 6: core.v1.Agent.SaveIndex:output_type -> payload.v1.Empty - 1, // 7: core.v1.Agent.CreateAndSaveIndex:output_type -> payload.v1.Empty - 3, // 8: core.v1.Agent.IndexInfo:output_type -> payload.v1.Info.Index.Count - 4, // 9: core.v1.Agent.GetTimestamp:output_type -> payload.v1.Object.Timestamp - 5, // [5:10] is the sub-list for method output_type - 0, // [0:5] is the sub-list for method input_type + 1, // 3: core.v1.Agent.CreateIndex:output_type -> payload.v1.Empty + 1, // 4: core.v1.Agent.SaveIndex:output_type -> payload.v1.Empty + 1, // 5: core.v1.Agent.CreateAndSaveIndex:output_type -> payload.v1.Empty + 3, // [3:6] is the sub-list for method output_type + 0, // [0:3] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name diff --git a/apis/grpc/v1/agent/core/agent_vtproto.pb.go b/apis/grpc/v1/agent/core/agent_vtproto.pb.go index 706565bbc8..93f689fa9c 100644 --- a/apis/grpc/v1/agent/core/agent_vtproto.pb.go +++ b/apis/grpc/v1/agent/core/agent_vtproto.pb.go @@ -48,10 +48,6 @@ type AgentClient interface { SaveIndex(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Empty, error) // Represent the creating and saving index RPC. CreateAndSaveIndex(ctx context.Context, in *payload.Control_CreateIndexRequest, opts ...grpc.CallOption) (*payload.Empty, error) - // Represent the RPC to get the agent index information. - IndexInfo(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Count, error) - // Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process - GetTimestamp(ctx context.Context, in *payload.Object_GetTimestampRequest, opts ...grpc.CallOption) (*payload.Object_Timestamp, error) } type agentClient struct { @@ -62,7 +58,9 @@ func NewAgentClient(cc grpc.ClientConnInterface) AgentClient { return &agentClient{cc} } -func (c *agentClient) CreateIndex(ctx context.Context, in *payload.Control_CreateIndexRequest, opts ...grpc.CallOption) (*payload.Empty, error) { +func (c *agentClient) CreateIndex( + ctx context.Context, in *payload.Control_CreateIndexRequest, opts ...grpc.CallOption, +) (*payload.Empty, error) { out := new(payload.Empty) err := c.cc.Invoke(ctx, "/core.v1.Agent/CreateIndex", in, out, opts...) if err != nil { @@ -71,7 +69,9 @@ func (c *agentClient) CreateIndex(ctx context.Context, in *payload.Control_Creat return out, nil } -func (c *agentClient) SaveIndex(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Empty, error) { +func (c *agentClient) SaveIndex( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (*payload.Empty, error) { out := new(payload.Empty) err := c.cc.Invoke(ctx, "/core.v1.Agent/SaveIndex", in, out, opts...) if err != nil { @@ -80,7 +80,9 @@ func (c *agentClient) SaveIndex(ctx context.Context, in *payload.Empty, opts ... return out, nil } -func (c *agentClient) CreateAndSaveIndex(ctx context.Context, in *payload.Control_CreateIndexRequest, opts ...grpc.CallOption) (*payload.Empty, error) { +func (c *agentClient) CreateAndSaveIndex( + ctx context.Context, in *payload.Control_CreateIndexRequest, opts ...grpc.CallOption, +) (*payload.Empty, error) { out := new(payload.Empty) err := c.cc.Invoke(ctx, "/core.v1.Agent/CreateAndSaveIndex", in, out, opts...) if err != nil { @@ -89,24 +91,6 @@ func (c *agentClient) CreateAndSaveIndex(ctx context.Context, in *payload.Contro return out, nil } -func (c *agentClient) IndexInfo(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Count, error) { - out := new(payload.Info_Index_Count) - err := c.cc.Invoke(ctx, "/core.v1.Agent/IndexInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *agentClient) GetTimestamp(ctx context.Context, in *payload.Object_GetTimestampRequest, opts ...grpc.CallOption) (*payload.Object_Timestamp, error) { - out := new(payload.Object_Timestamp) - err := c.cc.Invoke(ctx, "/core.v1.Agent/GetTimestamp", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // AgentServer is the server API for Agent service. // All implementations must embed UnimplementedAgentServer // for forward compatibility @@ -117,32 +101,27 @@ type AgentServer interface { SaveIndex(context.Context, *payload.Empty) (*payload.Empty, error) // Represent the creating and saving index RPC. CreateAndSaveIndex(context.Context, *payload.Control_CreateIndexRequest) (*payload.Empty, error) - // Represent the RPC to get the agent index information. - IndexInfo(context.Context, *payload.Empty) (*payload.Info_Index_Count, error) - // Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process - GetTimestamp(context.Context, *payload.Object_GetTimestampRequest) (*payload.Object_Timestamp, error) mustEmbedUnimplementedAgentServer() } // UnimplementedAgentServer must be embedded to have forward compatible implementations. -type UnimplementedAgentServer struct { -} +type UnimplementedAgentServer struct{} -func (UnimplementedAgentServer) CreateIndex(context.Context, *payload.Control_CreateIndexRequest) (*payload.Empty, error) { +func (UnimplementedAgentServer) CreateIndex( + context.Context, *payload.Control_CreateIndexRequest, +) (*payload.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateIndex not implemented") } + func (UnimplementedAgentServer) SaveIndex(context.Context, *payload.Empty) (*payload.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method SaveIndex not implemented") } -func (UnimplementedAgentServer) CreateAndSaveIndex(context.Context, *payload.Control_CreateIndexRequest) (*payload.Empty, error) { + +func (UnimplementedAgentServer) CreateAndSaveIndex( + context.Context, *payload.Control_CreateIndexRequest, +) (*payload.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateAndSaveIndex not implemented") } -func (UnimplementedAgentServer) IndexInfo(context.Context, *payload.Empty) (*payload.Info_Index_Count, error) { - return nil, status.Errorf(codes.Unimplemented, "method IndexInfo not implemented") -} -func (UnimplementedAgentServer) GetTimestamp(context.Context, *payload.Object_GetTimestampRequest) (*payload.Object_Timestamp, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetTimestamp not implemented") -} func (UnimplementedAgentServer) mustEmbedUnimplementedAgentServer() {} // UnsafeAgentServer may be embedded to opt out of forward compatibility for this service. @@ -156,7 +135,9 @@ func RegisterAgentServer(s grpc.ServiceRegistrar, srv AgentServer) { s.RegisterService(&Agent_ServiceDesc, srv) } -func _Agent_CreateIndex_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Agent_CreateIndex_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Control_CreateIndexRequest) if err := dec(in); err != nil { return nil, err @@ -168,13 +149,15 @@ func _Agent_CreateIndex_Handler(srv interface{}, ctx context.Context, dec func(i Server: srv, FullMethod: "/core.v1.Agent/CreateIndex", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AgentServer).CreateIndex(ctx, req.(*payload.Control_CreateIndexRequest)) } return interceptor(ctx, in, info, handler) } -func _Agent_SaveIndex_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Agent_SaveIndex_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Empty) if err := dec(in); err != nil { return nil, err @@ -186,13 +169,15 @@ func _Agent_SaveIndex_Handler(srv interface{}, ctx context.Context, dec func(int Server: srv, FullMethod: "/core.v1.Agent/SaveIndex", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AgentServer).SaveIndex(ctx, req.(*payload.Empty)) } return interceptor(ctx, in, info, handler) } -func _Agent_CreateAndSaveIndex_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Agent_CreateAndSaveIndex_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Control_CreateIndexRequest) if err := dec(in); err != nil { return nil, err @@ -204,48 +189,12 @@ func _Agent_CreateAndSaveIndex_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/core.v1.Agent/CreateAndSaveIndex", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(AgentServer).CreateAndSaveIndex(ctx, req.(*payload.Control_CreateIndexRequest)) } return interceptor(ctx, in, info, handler) } -func _Agent_IndexInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(payload.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AgentServer).IndexInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/core.v1.Agent/IndexInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AgentServer).IndexInfo(ctx, req.(*payload.Empty)) - } - return interceptor(ctx, in, info, handler) -} - -func _Agent_GetTimestamp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(payload.Object_GetTimestampRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AgentServer).GetTimestamp(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/core.v1.Agent/GetTimestamp", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AgentServer).GetTimestamp(ctx, req.(*payload.Object_GetTimestampRequest)) - } - return interceptor(ctx, in, info, handler) -} - // Agent_ServiceDesc is the grpc.ServiceDesc for Agent service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -265,14 +214,6 @@ var Agent_ServiceDesc = grpc.ServiceDesc{ MethodName: "CreateAndSaveIndex", Handler: _Agent_CreateAndSaveIndex_Handler, }, - { - MethodName: "IndexInfo", - Handler: _Agent_IndexInfo_Handler, - }, - { - MethodName: "GetTimestamp", - Handler: _Agent_GetTimestamp_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "v1/agent/core/agent.proto", diff --git a/apis/grpc/v1/agent/sidecar/sidecar.pb.go b/apis/grpc/v1/agent/sidecar/sidecar.pb.go index ef77866a95..bcaf02c7c6 100644 --- a/apis/grpc/v1/agent/sidecar/sidecar.pb.go +++ b/apis/grpc/v1/agent/sidecar/sidecar.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/agent/sidecar/sidecar.proto @@ -52,14 +52,16 @@ var file_v1_agent_sidecar_sidecar_proto_rawDesc = []byte{ 0x65, 0x63, 0x61, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_agent_sidecar_sidecar_proto_goTypes = []interface{}{} -var file_v1_agent_sidecar_sidecar_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} +var ( + file_v1_agent_sidecar_sidecar_proto_goTypes = []any{} + file_v1_agent_sidecar_sidecar_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name + } +) func init() { file_v1_agent_sidecar_sidecar_proto_init() } func file_v1_agent_sidecar_sidecar_proto_init() { diff --git a/apis/grpc/v1/agent/sidecar/sidecar_vtproto.pb.go b/apis/grpc/v1/agent/sidecar/sidecar_vtproto.pb.go index 4bc5f1dd71..3e7fb5da06 100644 --- a/apis/grpc/v1/agent/sidecar/sidecar_vtproto.pb.go +++ b/apis/grpc/v1/agent/sidecar/sidecar_vtproto.pb.go @@ -36,8 +36,7 @@ const _ = grpc.SupportPackageIsVersion7 // SidecarClient is the client API for Sidecar service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type SidecarClient interface { -} +type SidecarClient any type sidecarClient struct { cc grpc.ClientConnInterface @@ -55,8 +54,7 @@ type SidecarServer interface { } // UnimplementedSidecarServer must be embedded to have forward compatible implementations. -type UnimplementedSidecarServer struct { -} +type UnimplementedSidecarServer struct{} func (UnimplementedSidecarServer) mustEmbedUnimplementedSidecarServer() {} diff --git a/apis/grpc/v1/discoverer/discoverer.pb.go b/apis/grpc/v1/discoverer/discoverer.pb.go index b3bb0fa376..f95d2f8cbe 100644 --- a/apis/grpc/v1/discoverer/discoverer.pb.go +++ b/apis/grpc/v1/discoverer/discoverer.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/discoverer/discoverer.proto @@ -75,12 +75,13 @@ var file_v1_discoverer_discoverer_proto_rawDesc = []byte{ 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_discoverer_discoverer_proto_goTypes = []interface{}{ +var file_v1_discoverer_discoverer_proto_goTypes = []any{ (*payload.Discoverer_Request)(nil), // 0: payload.v1.Discoverer.Request (*payload.Info_Pods)(nil), // 1: payload.v1.Info.Pods (*payload.Info_Nodes)(nil), // 2: payload.v1.Info.Nodes (*payload.Info_Services)(nil), // 3: payload.v1.Info.Services } + var file_v1_discoverer_discoverer_proto_depIdxs = []int32{ 0, // 0: discoverer.v1.Discoverer.Pods:input_type -> payload.v1.Discoverer.Request 0, // 1: discoverer.v1.Discoverer.Nodes:input_type -> payload.v1.Discoverer.Request diff --git a/apis/grpc/v1/discoverer/discoverer_vtproto.pb.go b/apis/grpc/v1/discoverer/discoverer_vtproto.pb.go index 33d582002a..a1153195c6 100644 --- a/apis/grpc/v1/discoverer/discoverer_vtproto.pb.go +++ b/apis/grpc/v1/discoverer/discoverer_vtproto.pb.go @@ -58,7 +58,9 @@ func NewDiscovererClient(cc grpc.ClientConnInterface) DiscovererClient { return &discovererClient{cc} } -func (c *discovererClient) Pods(ctx context.Context, in *payload.Discoverer_Request, opts ...grpc.CallOption) (*payload.Info_Pods, error) { +func (c *discovererClient) Pods( + ctx context.Context, in *payload.Discoverer_Request, opts ...grpc.CallOption, +) (*payload.Info_Pods, error) { out := new(payload.Info_Pods) err := c.cc.Invoke(ctx, "/discoverer.v1.Discoverer/Pods", in, out, opts...) if err != nil { @@ -67,7 +69,9 @@ func (c *discovererClient) Pods(ctx context.Context, in *payload.Discoverer_Requ return out, nil } -func (c *discovererClient) Nodes(ctx context.Context, in *payload.Discoverer_Request, opts ...grpc.CallOption) (*payload.Info_Nodes, error) { +func (c *discovererClient) Nodes( + ctx context.Context, in *payload.Discoverer_Request, opts ...grpc.CallOption, +) (*payload.Info_Nodes, error) { out := new(payload.Info_Nodes) err := c.cc.Invoke(ctx, "/discoverer.v1.Discoverer/Nodes", in, out, opts...) if err != nil { @@ -76,7 +80,9 @@ func (c *discovererClient) Nodes(ctx context.Context, in *payload.Discoverer_Req return out, nil } -func (c *discovererClient) Services(ctx context.Context, in *payload.Discoverer_Request, opts ...grpc.CallOption) (*payload.Info_Services, error) { +func (c *discovererClient) Services( + ctx context.Context, in *payload.Discoverer_Request, opts ...grpc.CallOption, +) (*payload.Info_Services, error) { out := new(payload.Info_Services) err := c.cc.Invoke(ctx, "/discoverer.v1.Discoverer/Services", in, out, opts...) if err != nil { @@ -99,16 +105,23 @@ type DiscovererServer interface { } // UnimplementedDiscovererServer must be embedded to have forward compatible implementations. -type UnimplementedDiscovererServer struct { -} +type UnimplementedDiscovererServer struct{} -func (UnimplementedDiscovererServer) Pods(context.Context, *payload.Discoverer_Request) (*payload.Info_Pods, error) { +func (UnimplementedDiscovererServer) Pods( + context.Context, *payload.Discoverer_Request, +) (*payload.Info_Pods, error) { return nil, status.Errorf(codes.Unimplemented, "method Pods not implemented") } -func (UnimplementedDiscovererServer) Nodes(context.Context, *payload.Discoverer_Request) (*payload.Info_Nodes, error) { + +func (UnimplementedDiscovererServer) Nodes( + context.Context, *payload.Discoverer_Request, +) (*payload.Info_Nodes, error) { return nil, status.Errorf(codes.Unimplemented, "method Nodes not implemented") } -func (UnimplementedDiscovererServer) Services(context.Context, *payload.Discoverer_Request) (*payload.Info_Services, error) { + +func (UnimplementedDiscovererServer) Services( + context.Context, *payload.Discoverer_Request, +) (*payload.Info_Services, error) { return nil, status.Errorf(codes.Unimplemented, "method Services not implemented") } func (UnimplementedDiscovererServer) mustEmbedUnimplementedDiscovererServer() {} @@ -124,7 +137,9 @@ func RegisterDiscovererServer(s grpc.ServiceRegistrar, srv DiscovererServer) { s.RegisterService(&Discoverer_ServiceDesc, srv) } -func _Discoverer_Pods_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Discoverer_Pods_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Discoverer_Request) if err := dec(in); err != nil { return nil, err @@ -136,13 +151,15 @@ func _Discoverer_Pods_Handler(srv interface{}, ctx context.Context, dec func(int Server: srv, FullMethod: "/discoverer.v1.Discoverer/Pods", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(DiscovererServer).Pods(ctx, req.(*payload.Discoverer_Request)) } return interceptor(ctx, in, info, handler) } -func _Discoverer_Nodes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Discoverer_Nodes_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Discoverer_Request) if err := dec(in); err != nil { return nil, err @@ -154,13 +171,15 @@ func _Discoverer_Nodes_Handler(srv interface{}, ctx context.Context, dec func(in Server: srv, FullMethod: "/discoverer.v1.Discoverer/Nodes", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(DiscovererServer).Nodes(ctx, req.(*payload.Discoverer_Request)) } return interceptor(ctx, in, info, handler) } -func _Discoverer_Services_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Discoverer_Services_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Discoverer_Request) if err := dec(in); err != nil { return nil, err @@ -172,7 +191,7 @@ func _Discoverer_Services_Handler(srv interface{}, ctx context.Context, dec func Server: srv, FullMethod: "/discoverer.v1.Discoverer/Services", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(DiscovererServer).Services(ctx, req.(*payload.Discoverer_Request)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/filter/egress/egress_filter.pb.go b/apis/grpc/v1/filter/egress/egress_filter.pb.go index 979b819852..5d60c42564 100644 --- a/apis/grpc/v1/filter/egress/egress_filter.pb.go +++ b/apis/grpc/v1/filter/egress/egress_filter.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/filter/egress/egress_filter.proto @@ -72,10 +72,11 @@ var file_v1_filter_egress_egress_filter_proto_rawDesc = []byte{ 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_filter_egress_egress_filter_proto_goTypes = []interface{}{ +var file_v1_filter_egress_egress_filter_proto_goTypes = []any{ (*payload.Object_Distance)(nil), // 0: payload.v1.Object.Distance (*payload.Object_Vector)(nil), // 1: payload.v1.Object.Vector } + var file_v1_filter_egress_egress_filter_proto_depIdxs = []int32{ 0, // 0: filter.egress.v1.Filter.FilterDistance:input_type -> payload.v1.Object.Distance 1, // 1: filter.egress.v1.Filter.FilterVector:input_type -> payload.v1.Object.Vector diff --git a/apis/grpc/v1/filter/egress/egress_filter_vtproto.pb.go b/apis/grpc/v1/filter/egress/egress_filter_vtproto.pb.go index 40879eb833..fc9d0d34e2 100644 --- a/apis/grpc/v1/filter/egress/egress_filter_vtproto.pb.go +++ b/apis/grpc/v1/filter/egress/egress_filter_vtproto.pb.go @@ -56,7 +56,9 @@ func NewFilterClient(cc grpc.ClientConnInterface) FilterClient { return &filterClient{cc} } -func (c *filterClient) FilterDistance(ctx context.Context, in *payload.Object_Distance, opts ...grpc.CallOption) (*payload.Object_Distance, error) { +func (c *filterClient) FilterDistance( + ctx context.Context, in *payload.Object_Distance, opts ...grpc.CallOption, +) (*payload.Object_Distance, error) { out := new(payload.Object_Distance) err := c.cc.Invoke(ctx, "/filter.egress.v1.Filter/FilterDistance", in, out, opts...) if err != nil { @@ -65,7 +67,9 @@ func (c *filterClient) FilterDistance(ctx context.Context, in *payload.Object_Di return out, nil } -func (c *filterClient) FilterVector(ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption) (*payload.Object_Vector, error) { +func (c *filterClient) FilterVector( + ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption, +) (*payload.Object_Vector, error) { out := new(payload.Object_Vector) err := c.cc.Invoke(ctx, "/filter.egress.v1.Filter/FilterVector", in, out, opts...) if err != nil { @@ -86,13 +90,17 @@ type FilterServer interface { } // UnimplementedFilterServer must be embedded to have forward compatible implementations. -type UnimplementedFilterServer struct { -} +type UnimplementedFilterServer struct{} -func (UnimplementedFilterServer) FilterDistance(context.Context, *payload.Object_Distance) (*payload.Object_Distance, error) { +func (UnimplementedFilterServer) FilterDistance( + context.Context, *payload.Object_Distance, +) (*payload.Object_Distance, error) { return nil, status.Errorf(codes.Unimplemented, "method FilterDistance not implemented") } -func (UnimplementedFilterServer) FilterVector(context.Context, *payload.Object_Vector) (*payload.Object_Vector, error) { + +func (UnimplementedFilterServer) FilterVector( + context.Context, *payload.Object_Vector, +) (*payload.Object_Vector, error) { return nil, status.Errorf(codes.Unimplemented, "method FilterVector not implemented") } func (UnimplementedFilterServer) mustEmbedUnimplementedFilterServer() {} @@ -108,7 +116,9 @@ func RegisterFilterServer(s grpc.ServiceRegistrar, srv FilterServer) { s.RegisterService(&Filter_ServiceDesc, srv) } -func _Filter_FilterDistance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_FilterDistance_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Object_Distance) if err := dec(in); err != nil { return nil, err @@ -120,13 +130,15 @@ func _Filter_FilterDistance_Handler(srv interface{}, ctx context.Context, dec fu Server: srv, FullMethod: "/filter.egress.v1.Filter/FilterDistance", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).FilterDistance(ctx, req.(*payload.Object_Distance)) } return interceptor(ctx, in, info, handler) } -func _Filter_FilterVector_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_FilterVector_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Object_Vector) if err := dec(in); err != nil { return nil, err @@ -138,7 +150,7 @@ func _Filter_FilterVector_Handler(srv interface{}, ctx context.Context, dec func Server: srv, FullMethod: "/filter.egress.v1.Filter/FilterVector", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).FilterVector(ctx, req.(*payload.Object_Vector)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/filter/ingress/ingress_filter.pb.go b/apis/grpc/v1/filter/ingress/ingress_filter.pb.go index e6eacd40bb..4c76d06ed6 100644 --- a/apis/grpc/v1/filter/ingress/ingress_filter.pb.go +++ b/apis/grpc/v1/filter/ingress/ingress_filter.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/filter/ingress/ingress_filter.proto @@ -72,10 +72,11 @@ var file_v1_filter_ingress_ingress_filter_proto_rawDesc = []byte{ 0x74, 0x6f, 0x33, } -var file_v1_filter_ingress_ingress_filter_proto_goTypes = []interface{}{ +var file_v1_filter_ingress_ingress_filter_proto_goTypes = []any{ (*payload.Object_Blob)(nil), // 0: payload.v1.Object.Blob (*payload.Object_Vector)(nil), // 1: payload.v1.Object.Vector } + var file_v1_filter_ingress_ingress_filter_proto_depIdxs = []int32{ 0, // 0: filter.ingress.v1.Filter.GenVector:input_type -> payload.v1.Object.Blob 1, // 1: filter.ingress.v1.Filter.FilterVector:input_type -> payload.v1.Object.Vector diff --git a/apis/grpc/v1/filter/ingress/ingress_filter_vtproto.pb.go b/apis/grpc/v1/filter/ingress/ingress_filter_vtproto.pb.go index ed24ab43b4..acea57e809 100644 --- a/apis/grpc/v1/filter/ingress/ingress_filter_vtproto.pb.go +++ b/apis/grpc/v1/filter/ingress/ingress_filter_vtproto.pb.go @@ -56,7 +56,9 @@ func NewFilterClient(cc grpc.ClientConnInterface) FilterClient { return &filterClient{cc} } -func (c *filterClient) GenVector(ctx context.Context, in *payload.Object_Blob, opts ...grpc.CallOption) (*payload.Object_Vector, error) { +func (c *filterClient) GenVector( + ctx context.Context, in *payload.Object_Blob, opts ...grpc.CallOption, +) (*payload.Object_Vector, error) { out := new(payload.Object_Vector) err := c.cc.Invoke(ctx, "/filter.ingress.v1.Filter/GenVector", in, out, opts...) if err != nil { @@ -65,7 +67,9 @@ func (c *filterClient) GenVector(ctx context.Context, in *payload.Object_Blob, o return out, nil } -func (c *filterClient) FilterVector(ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption) (*payload.Object_Vector, error) { +func (c *filterClient) FilterVector( + ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption, +) (*payload.Object_Vector, error) { out := new(payload.Object_Vector) err := c.cc.Invoke(ctx, "/filter.ingress.v1.Filter/FilterVector", in, out, opts...) if err != nil { @@ -86,13 +90,17 @@ type FilterServer interface { } // UnimplementedFilterServer must be embedded to have forward compatible implementations. -type UnimplementedFilterServer struct { -} +type UnimplementedFilterServer struct{} -func (UnimplementedFilterServer) GenVector(context.Context, *payload.Object_Blob) (*payload.Object_Vector, error) { +func (UnimplementedFilterServer) GenVector( + context.Context, *payload.Object_Blob, +) (*payload.Object_Vector, error) { return nil, status.Errorf(codes.Unimplemented, "method GenVector not implemented") } -func (UnimplementedFilterServer) FilterVector(context.Context, *payload.Object_Vector) (*payload.Object_Vector, error) { + +func (UnimplementedFilterServer) FilterVector( + context.Context, *payload.Object_Vector, +) (*payload.Object_Vector, error) { return nil, status.Errorf(codes.Unimplemented, "method FilterVector not implemented") } func (UnimplementedFilterServer) mustEmbedUnimplementedFilterServer() {} @@ -108,7 +116,9 @@ func RegisterFilterServer(s grpc.ServiceRegistrar, srv FilterServer) { s.RegisterService(&Filter_ServiceDesc, srv) } -func _Filter_GenVector_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_GenVector_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Object_Blob) if err := dec(in); err != nil { return nil, err @@ -120,13 +130,15 @@ func _Filter_GenVector_Handler(srv interface{}, ctx context.Context, dec func(in Server: srv, FullMethod: "/filter.ingress.v1.Filter/GenVector", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).GenVector(ctx, req.(*payload.Object_Blob)) } return interceptor(ctx, in, info, handler) } -func _Filter_FilterVector_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_FilterVector_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Object_Vector) if err := dec(in); err != nil { return nil, err @@ -138,7 +150,7 @@ func _Filter_FilterVector_Handler(srv interface{}, ctx context.Context, dec func Server: srv, FullMethod: "/filter.ingress.v1.Filter/FilterVector", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).FilterVector(ctx, req.(*payload.Object_Vector)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/manager/index/index_manager.pb.go b/apis/grpc/v1/manager/index/index_manager.pb.go deleted file mode 100644 index 483c3010cf..0000000000 --- a/apis/grpc/v1/manager/index/index_manager.pb.go +++ /dev/null @@ -1,103 +0,0 @@ -// -// 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. -// - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.1 -// protoc (unknown) -// source: v1/manager/index/index_manager.proto - -package index - -import ( - reflect "reflect" - - payload "github.com/vdaas/vald/apis/grpc/v1/payload" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -var File_v1_manager_index_index_manager_proto protoreflect.FileDescriptor - -var file_v1_manager_index_index_manager_proto_rawDesc = []byte{ - 0x0a, 0x24, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x69, 0x6e, 0x64, - 0x65, 0x78, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, - 0x61, 0x64, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x32, 0x5a, 0x0a, 0x05, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x51, 0x0a, 0x09, 0x49, 0x6e, 0x64, - 0x65, 0x78, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x11, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, - 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1c, 0x2e, 0x70, 0x61, 0x79, 0x6c, - 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x49, 0x6e, 0x64, 0x65, - 0x78, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x12, - 0x0b, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x42, 0x6b, 0x0a, 0x23, - 0x6f, 0x72, 0x67, 0x2e, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2e, 0x76, 0x61, 0x6c, 0x64, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x69, 0x6e, - 0x64, 0x65, 0x78, 0x42, 0x10, 0x56, 0x61, 0x6c, 0x64, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2f, 0x76, 0x61, 0x6c, 0x64, 0x2f, 0x61, - 0x70, 0x69, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var file_v1_manager_index_index_manager_proto_goTypes = []interface{}{ - (*payload.Empty)(nil), // 0: payload.v1.Empty - (*payload.Info_Index_Count)(nil), // 1: payload.v1.Info.Index.Count -} -var file_v1_manager_index_index_manager_proto_depIdxs = []int32{ - 0, // 0: manager.index.v1.Index.IndexInfo:input_type -> payload.v1.Empty - 1, // 1: manager.index.v1.Index.IndexInfo:output_type -> payload.v1.Info.Index.Count - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_v1_manager_index_index_manager_proto_init() } -func file_v1_manager_index_index_manager_proto_init() { - if File_v1_manager_index_index_manager_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_v1_manager_index_index_manager_proto_rawDesc, - NumEnums: 0, - NumMessages: 0, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_v1_manager_index_index_manager_proto_goTypes, - DependencyIndexes: file_v1_manager_index_index_manager_proto_depIdxs, - }.Build() - File_v1_manager_index_index_manager_proto = out.File - file_v1_manager_index_index_manager_proto_rawDesc = nil - file_v1_manager_index_index_manager_proto_goTypes = nil - file_v1_manager_index_index_manager_proto_depIdxs = nil -} diff --git a/apis/grpc/v1/manager/index/index_manager_vtproto.pb.go b/apis/grpc/v1/manager/index/index_manager_vtproto.pb.go deleted file mode 100644 index b88016d329..0000000000 --- a/apis/grpc/v1/manager/index/index_manager_vtproto.pb.go +++ /dev/null @@ -1,127 +0,0 @@ -// -// 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 index - -import ( - context "context" - - payload "github.com/vdaas/vald/apis/grpc/v1/payload" - codes "github.com/vdaas/vald/internal/net/grpc/codes" - status "github.com/vdaas/vald/internal/net/grpc/status" - grpc "google.golang.org/grpc" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// IndexClient is the client API for Index service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type IndexClient interface { - // Represent the RPC to get the index information. - IndexInfo(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Count, error) -} - -type indexClient struct { - cc grpc.ClientConnInterface -} - -func NewIndexClient(cc grpc.ClientConnInterface) IndexClient { - return &indexClient{cc} -} - -func (c *indexClient) IndexInfo(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Count, error) { - out := new(payload.Info_Index_Count) - err := c.cc.Invoke(ctx, "/manager.index.v1.Index/IndexInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// IndexServer is the server API for Index service. -// All implementations must embed UnimplementedIndexServer -// for forward compatibility -type IndexServer interface { - // Represent the RPC to get the index information. - IndexInfo(context.Context, *payload.Empty) (*payload.Info_Index_Count, error) - mustEmbedUnimplementedIndexServer() -} - -// UnimplementedIndexServer must be embedded to have forward compatible implementations. -type UnimplementedIndexServer struct { -} - -func (UnimplementedIndexServer) IndexInfo(context.Context, *payload.Empty) (*payload.Info_Index_Count, error) { - return nil, status.Errorf(codes.Unimplemented, "method IndexInfo not implemented") -} -func (UnimplementedIndexServer) mustEmbedUnimplementedIndexServer() {} - -// UnsafeIndexServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to IndexServer will -// result in compilation errors. -type UnsafeIndexServer interface { - mustEmbedUnimplementedIndexServer() -} - -func RegisterIndexServer(s grpc.ServiceRegistrar, srv IndexServer) { - s.RegisterService(&Index_ServiceDesc, srv) -} - -func _Index_IndexInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(payload.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(IndexServer).IndexInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/manager.index.v1.Index/IndexInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IndexServer).IndexInfo(ctx, req.(*payload.Empty)) - } - return interceptor(ctx, in, info, handler) -} - -// Index_ServiceDesc is the grpc.ServiceDesc for Index service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Index_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "manager.index.v1.Index", - HandlerType: (*IndexServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "IndexInfo", - Handler: _Index_IndexInfo_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "v1/manager/index/index_manager.proto", -} diff --git a/apis/grpc/v1/mirror/mirror.pb.go b/apis/grpc/v1/mirror/mirror.pb.go index 9f5826913e..429706e1c3 100644 --- a/apis/grpc/v1/mirror/mirror.pb.go +++ b/apis/grpc/v1/mirror/mirror.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/mirror/mirror.proto @@ -62,9 +62,10 @@ var file_v1_mirror_mirror_proto_rawDesc = []byte{ 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_mirror_mirror_proto_goTypes = []interface{}{ +var file_v1_mirror_mirror_proto_goTypes = []any{ (*payload.Mirror_Targets)(nil), // 0: payload.v1.Mirror.Targets } + var file_v1_mirror_mirror_proto_depIdxs = []int32{ 0, // 0: mirror.v1.Mirror.Register:input_type -> payload.v1.Mirror.Targets 0, // 1: mirror.v1.Mirror.Register:output_type -> payload.v1.Mirror.Targets diff --git a/apis/grpc/v1/mirror/mirror_vtproto.pb.go b/apis/grpc/v1/mirror/mirror_vtproto.pb.go index 399c385d4b..5b733bf39d 100644 --- a/apis/grpc/v1/mirror/mirror_vtproto.pb.go +++ b/apis/grpc/v1/mirror/mirror_vtproto.pb.go @@ -54,7 +54,9 @@ func NewMirrorClient(cc grpc.ClientConnInterface) MirrorClient { return &mirrorClient{cc} } -func (c *mirrorClient) Register(ctx context.Context, in *payload.Mirror_Targets, opts ...grpc.CallOption) (*payload.Mirror_Targets, error) { +func (c *mirrorClient) Register( + ctx context.Context, in *payload.Mirror_Targets, opts ...grpc.CallOption, +) (*payload.Mirror_Targets, error) { out := new(payload.Mirror_Targets) err := c.cc.Invoke(ctx, "/mirror.v1.Mirror/Register", in, out, opts...) if err != nil { @@ -73,10 +75,11 @@ type MirrorServer interface { } // UnimplementedMirrorServer must be embedded to have forward compatible implementations. -type UnimplementedMirrorServer struct { -} +type UnimplementedMirrorServer struct{} -func (UnimplementedMirrorServer) Register(context.Context, *payload.Mirror_Targets) (*payload.Mirror_Targets, error) { +func (UnimplementedMirrorServer) Register( + context.Context, *payload.Mirror_Targets, +) (*payload.Mirror_Targets, error) { return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") } func (UnimplementedMirrorServer) mustEmbedUnimplementedMirrorServer() {} @@ -92,7 +95,9 @@ func RegisterMirrorServer(s grpc.ServiceRegistrar, srv MirrorServer) { s.RegisterService(&Mirror_ServiceDesc, srv) } -func _Mirror_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Mirror_Register_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Mirror_Targets) if err := dec(in); err != nil { return nil, err @@ -104,7 +109,7 @@ func _Mirror_Register_Handler(srv interface{}, ctx context.Context, dec func(int Server: srv, FullMethod: "/mirror.v1.Mirror/Register", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(MirrorServer).Register(ctx, req.(*payload.Mirror_Targets)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/payload/payload.pb.go b/apis/grpc/v1/payload/payload.pb.go index c68b9dd9e4..1d034ff92e 100644 --- a/apis/grpc/v1/payload/payload.pb.go +++ b/apis/grpc/v1/payload/payload.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/payload/payload.proto @@ -104,11 +104,13 @@ const ( Remove_Timestamp_Eq Remove_Timestamp_Operator = 0 // The timestamp is not equal to the specified value in the request. Remove_Timestamp_Ne Remove_Timestamp_Operator = 1 - // The timestamp is greater than or equal to the specified value in the request. + // The timestamp is greater than or equal to the specified value in the + // request. Remove_Timestamp_Ge Remove_Timestamp_Operator = 2 // The timestamp is greater than the specified value in the request. Remove_Timestamp_Gt Remove_Timestamp_Operator = 3 - // The timestamp is less than or equal to the specified value in the request. + // The timestamp is less than or equal to the specified value in the + // request. Remove_Timestamp_Le Remove_Timestamp_Operator = 4 // The timestamp is less than the specified value in the request. Remove_Timestamp_Lt Remove_Timestamp_Operator = 5 @@ -677,7 +679,7 @@ type Search_Request struct { // The vector to be searched. Vector []float32 `protobuf:"fixed32,1,rep,packed,name=vector,proto3" json:"vector,omitempty"` // The configuration of the search request. - Config *Search_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` + Config *Search_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` } func (x *Search_Request) Reset() { @@ -782,7 +784,7 @@ type Search_IDRequest struct { unknownFields protoimpl.UnknownFields // The vector ID to be searched. - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // The configuration of the search request. Config *Search_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` } @@ -889,9 +891,9 @@ type Search_ObjectRequest struct { unknownFields protoimpl.UnknownFields // The binary object to be searched. - Object []byte `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` + Object []byte `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` // The configuration of the search request. - Config *Search_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` + Config *Search_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` // Filter configuration. Vectorizer *Filter_Target `protobuf:"bytes,3,opt,name=vectorizer,proto3" json:"vectorizer,omitempty"` } @@ -1005,25 +1007,25 @@ type Search_Config struct { unknownFields protoimpl.UnknownFields // Unique request ID. - RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` // Maximum number of result to be returned. - Num uint32 `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"` + Num uint32 `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"` // Search radius. - Radius float32 `protobuf:"fixed32,3,opt,name=radius,proto3" json:"radius,omitempty"` + Radius float32 `protobuf:"fixed32,3,opt,name=radius,proto3" json:"radius,omitempty"` // Search coefficient. - Epsilon float32 `protobuf:"fixed32,4,opt,name=epsilon,proto3" json:"epsilon,omitempty"` + Epsilon float32 `protobuf:"fixed32,4,opt,name=epsilon,proto3" json:"epsilon,omitempty"` // Search timeout in nanoseconds. - Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` + Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` // Ingress filter configurations. - IngressFilters *Filter_Config `protobuf:"bytes,6,opt,name=ingress_filters,json=ingressFilters,proto3" json:"ingress_filters,omitempty"` + IngressFilters *Filter_Config `protobuf:"bytes,6,opt,name=ingress_filters,json=ingressFilters,proto3" json:"ingress_filters,omitempty"` // Egress filter configurations. - EgressFilters *Filter_Config `protobuf:"bytes,7,opt,name=egress_filters,json=egressFilters,proto3" json:"egress_filters,omitempty"` + EgressFilters *Filter_Config `protobuf:"bytes,7,opt,name=egress_filters,json=egressFilters,proto3" json:"egress_filters,omitempty"` // Minimum number of result to be returned. - MinNum uint32 `protobuf:"varint,8,opt,name=min_num,json=minNum,proto3" json:"min_num,omitempty"` + MinNum uint32 `protobuf:"varint,8,opt,name=min_num,json=minNum,proto3" json:"min_num,omitempty"` // Aggregation Algorithm AggregationAlgorithm Search_AggregationAlgorithm `protobuf:"varint,9,opt,name=aggregation_algorithm,json=aggregationAlgorithm,proto3,enum=payload.v1.Search_AggregationAlgorithm" json:"aggregation_algorithm,omitempty"` // Search ratio for agent return result number. - Ratio *wrapperspb.FloatValue `protobuf:"bytes,10,opt,name=ratio,proto3" json:"ratio,omitempty"` + Ratio *wrapperspb.FloatValue `protobuf:"bytes,10,opt,name=ratio,proto3" json:"ratio,omitempty"` } func (x *Search_Config) Reset() { @@ -1137,7 +1139,7 @@ type Search_Response struct { // The unique request ID. RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` // Search results. - Results []*Object_Distance `protobuf:"bytes,2,rep,name=results,proto3" json:"results,omitempty"` + Results []*Object_Distance `protobuf:"bytes,2,rep,name=results,proto3" json:"results,omitempty"` } func (x *Search_Response) Reset() { @@ -1326,7 +1328,7 @@ type Filter_Target struct { unknownFields protoimpl.UnknownFields // The target hostname. - Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` // The target port. Port uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` } @@ -1540,9 +1542,9 @@ type Insert_ObjectRequest struct { unknownFields protoimpl.UnknownFields // The binary object to be inserted. - Object *Object_Blob `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` + Object *Object_Blob `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` // The configuration of the insert request. - Config *Insert_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` + Config *Insert_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` // Filter configurations. Vectorizer *Filter_Target `protobuf:"bytes,3,opt,name=vectorizer,proto3" json:"vectorizer,omitempty"` } @@ -1658,9 +1660,9 @@ type Insert_Config struct { // A flag to skip exist check during insert operation. SkipStrictExistCheck bool `protobuf:"varint,1,opt,name=skip_strict_exist_check,json=skipStrictExistCheck,proto3" json:"skip_strict_exist_check,omitempty"` // Filter configurations. - Filters *Filter_Config `protobuf:"bytes,2,opt,name=filters,proto3" json:"filters,omitempty"` + Filters *Filter_Config `protobuf:"bytes,2,opt,name=filters,proto3" json:"filters,omitempty"` // Insert timestamp. - Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } func (x *Insert_Config) Reset() { @@ -1830,9 +1832,9 @@ type Update_ObjectRequest struct { unknownFields protoimpl.UnknownFields // The binary object to be updated. - Object *Object_Blob `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` + Object *Object_Blob `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` // The configuration of the update request. - Config *Update_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` + Config *Update_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` // Filter target. Vectorizer *Filter_Target `protobuf:"bytes,3,opt,name=vectorizer,proto3" json:"vectorizer,omitempty"` } @@ -1946,11 +1948,11 @@ type Update_Config struct { unknownFields protoimpl.UnknownFields // A flag to skip exist check during update operation. - SkipStrictExistCheck bool `protobuf:"varint,1,opt,name=skip_strict_exist_check,json=skipStrictExistCheck,proto3" json:"skip_strict_exist_check,omitempty"` + SkipStrictExistCheck bool `protobuf:"varint,1,opt,name=skip_strict_exist_check,json=skipStrictExistCheck,proto3" json:"skip_strict_exist_check,omitempty"` // Filter configuration. - Filters *Filter_Config `protobuf:"bytes,2,opt,name=filters,proto3" json:"filters,omitempty"` + Filters *Filter_Config `protobuf:"bytes,2,opt,name=filters,proto3" json:"filters,omitempty"` // Update timestamp. - Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // A flag to disable balanced update (split remove -> insert operation) // during update operation. DisableBalancedUpdate bool `protobuf:"varint,4,opt,name=disable_balanced_update,json=disableBalancedUpdate,proto3" json:"disable_balanced_update,omitempty"` @@ -2130,9 +2132,9 @@ type Upsert_ObjectRequest struct { unknownFields protoimpl.UnknownFields // The binary object to be upserted. - Object *Object_Blob `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` + Object *Object_Blob `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` // The configuration of the upsert request. - Config *Upsert_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` + Config *Upsert_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` // Filter target. Vectorizer *Filter_Target `protobuf:"bytes,3,opt,name=vectorizer,proto3" json:"vectorizer,omitempty"` } @@ -2246,11 +2248,11 @@ type Upsert_Config struct { unknownFields protoimpl.UnknownFields // A flag to skip exist check during upsert operation. - SkipStrictExistCheck bool `protobuf:"varint,1,opt,name=skip_strict_exist_check,json=skipStrictExistCheck,proto3" json:"skip_strict_exist_check,omitempty"` + SkipStrictExistCheck bool `protobuf:"varint,1,opt,name=skip_strict_exist_check,json=skipStrictExistCheck,proto3" json:"skip_strict_exist_check,omitempty"` // Filter configuration. - Filters *Filter_Config `protobuf:"bytes,2,opt,name=filters,proto3" json:"filters,omitempty"` + Filters *Filter_Config `protobuf:"bytes,2,opt,name=filters,proto3" json:"filters,omitempty"` // Upsert timestamp. - Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // A flag to disable balanced update (split remove -> insert operation) // during update operation. DisableBalancedUpdate bool `protobuf:"varint,4,opt,name=disable_balanced_update,json=disableBalancedUpdate,proto3" json:"disable_balanced_update,omitempty"` @@ -2323,7 +2325,7 @@ type Remove_Request struct { unknownFields protoimpl.UnknownFields // The object ID to be removed. - Id *Object_ID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Id *Object_ID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // The configuration of the remove request. Config *Remove_Config `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` } @@ -2429,7 +2431,8 @@ type Remove_TimestampRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The timestamp comparison list. If more than one is specified, the `AND` search is applied. + // The timestamp comparison list. If more than one is specified, the `AND` + // search is applied. Timestamps []*Remove_Timestamp `protobuf:"bytes,1,rep,name=timestamps,proto3" json:"timestamps,omitempty"` } @@ -2479,7 +2482,7 @@ type Remove_Timestamp struct { unknownFields protoimpl.UnknownFields // The timestamp. - Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // The conditional operator. Operator Remove_Timestamp_Operator `protobuf:"varint,2,opt,name=operator,proto3,enum=payload.v1.Remove_Timestamp_Operator" json:"operator,omitempty"` } @@ -2539,7 +2542,7 @@ type Remove_Config struct { // A flag to skip exist check during upsert operation. SkipStrictExistCheck bool `protobuf:"varint,1,opt,name=skip_strict_exist_check,json=skipStrictExistCheck,proto3" json:"skip_strict_exist_check,omitempty"` // Remove timestamp. - Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } func (x *Remove_Config) Reset() { @@ -2633,7 +2636,7 @@ type Object_VectorRequest struct { unknownFields protoimpl.UnknownFields // The vector ID to be fetched. - Id *Object_ID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Id *Object_ID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Filter configurations. Filters *Filter_Config `protobuf:"bytes,2,opt,name=filters,proto3" json:"filters,omitempty"` } @@ -2691,7 +2694,7 @@ type Object_Distance struct { unknownFields protoimpl.UnknownFields // The vector ID. - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // The distance. Distance float32 `protobuf:"fixed32,2,opt,name=distance,proto3" json:"distance,omitempty"` } @@ -2929,11 +2932,11 @@ type Object_Vector struct { unknownFields protoimpl.UnknownFields // The vector ID. - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // The vector. Vector []float32 `protobuf:"fixed32,2,rep,packed,name=vector,proto3" json:"vector,omitempty"` // timestamp represents when this vector inserted. - Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } func (x *Object_Vector) Reset() { @@ -2990,7 +2993,7 @@ func (x *Object_Vector) GetTimestamp() int64 { } // Represent a request to fetch vector meta data. -type Object_GetTimestampRequest struct { +type Object_TimestampRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -2999,8 +3002,8 @@ type Object_GetTimestampRequest struct { Id *Object_ID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` } -func (x *Object_GetTimestampRequest) Reset() { - *x = Object_GetTimestampRequest{} +func (x *Object_TimestampRequest) Reset() { + *x = Object_TimestampRequest{} if protoimpl.UnsafeEnabled { mi := &file_v1_payload_payload_proto_msgTypes[52] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -3008,13 +3011,13 @@ func (x *Object_GetTimestampRequest) Reset() { } } -func (x *Object_GetTimestampRequest) String() string { +func (x *Object_TimestampRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Object_GetTimestampRequest) ProtoMessage() {} +func (*Object_TimestampRequest) ProtoMessage() {} -func (x *Object_GetTimestampRequest) ProtoReflect() protoreflect.Message { +func (x *Object_TimestampRequest) ProtoReflect() protoreflect.Message { mi := &file_v1_payload_payload_proto_msgTypes[52] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -3026,12 +3029,12 @@ func (x *Object_GetTimestampRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Object_GetTimestampRequest.ProtoReflect.Descriptor instead. -func (*Object_GetTimestampRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use Object_TimestampRequest.ProtoReflect.Descriptor instead. +func (*Object_TimestampRequest) Descriptor() ([]byte, []int) { return file_v1_payload_payload_proto_rawDescGZIP(), []int{7, 6} } -func (x *Object_GetTimestampRequest) GetId() *Object_ID { +func (x *Object_TimestampRequest) GetId() *Object_ID { if x != nil { return x.Id } @@ -3045,7 +3048,7 @@ type Object_Timestamp struct { unknownFields protoimpl.UnknownFields // The vector ID. - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // timestamp represents when this vector inserted. Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } @@ -3235,7 +3238,7 @@ type Object_ReshapeVector struct { unknownFields protoimpl.UnknownFields // The binary object. - Object []byte `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` + Object []byte `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` // The new shape. Shape []int32 `protobuf:"varint,2,rep,packed,name=shape,proto3" json:"shape,omitempty"` } @@ -3293,7 +3296,7 @@ type Object_Blob struct { unknownFields protoimpl.UnknownFields // The object ID. - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // The binary object. Object []byte `protobuf:"bytes,2,opt,name=object,proto3" json:"object,omitempty"` } @@ -3439,7 +3442,7 @@ type Object_Location struct { // The UUID of the vector. Uuid string `protobuf:"bytes,2,opt,name=uuid,proto3" json:"uuid,omitempty"` // The IP list. - Ips []string `protobuf:"bytes,3,rep,name=ips,proto3" json:"ips,omitempty"` + Ips []string `protobuf:"bytes,3,rep,name=ips,proto3" json:"ips,omitempty"` } func (x *Object_Location) Reset() { @@ -3843,11 +3846,11 @@ type Discoverer_Request struct { unknownFields protoimpl.UnknownFields // The agent name to be discovered. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // The namespace to be discovered. Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` // The node to be discovered. - Node string `protobuf:"bytes,3,opt,name=node,proto3" json:"node,omitempty"` + Node string `protobuf:"bytes,3,opt,name=node,proto3" json:"node,omitempty"` } func (x *Discoverer_Request) Reset() { @@ -3951,17 +3954,17 @@ type Info_Pod struct { // The app name of the pod on the label. AppName string `protobuf:"bytes,1,opt,name=app_name,json=appName,proto3" json:"app_name,omitempty"` // The name of the pod. - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // The namespace of the pod. - Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` + Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` // The IP of the pod. - Ip string `protobuf:"bytes,4,opt,name=ip,proto3" json:"ip,omitempty"` + Ip string `protobuf:"bytes,4,opt,name=ip,proto3" json:"ip,omitempty"` // The CPU information of the pod. - Cpu *Info_CPU `protobuf:"bytes,5,opt,name=cpu,proto3" json:"cpu,omitempty"` + Cpu *Info_CPU `protobuf:"bytes,5,opt,name=cpu,proto3" json:"cpu,omitempty"` // The memory information of the pod. - Memory *Info_Memory `protobuf:"bytes,6,opt,name=memory,proto3" json:"memory,omitempty"` + Memory *Info_Memory `protobuf:"bytes,6,opt,name=memory,proto3" json:"memory,omitempty"` // The node information of the pod. - Node *Info_Node `protobuf:"bytes,7,opt,name=node,proto3" json:"node,omitempty"` + Node *Info_Node `protobuf:"bytes,7,opt,name=node,proto3" json:"node,omitempty"` } func (x *Info_Pod) Reset() { @@ -4052,17 +4055,17 @@ type Info_Node struct { unknownFields protoimpl.UnknownFields // The name of the node. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // The internal IP address of the node. InternalAddr string `protobuf:"bytes,2,opt,name=internal_addr,json=internalAddr,proto3" json:"internal_addr,omitempty"` // The external IP address of the node. ExternalAddr string `protobuf:"bytes,3,opt,name=external_addr,json=externalAddr,proto3" json:"external_addr,omitempty"` // The CPU information of the node. - Cpu *Info_CPU `protobuf:"bytes,4,opt,name=cpu,proto3" json:"cpu,omitempty"` + Cpu *Info_CPU `protobuf:"bytes,4,opt,name=cpu,proto3" json:"cpu,omitempty"` // The memory information of the node. - Memory *Info_Memory `protobuf:"bytes,5,opt,name=memory,proto3" json:"memory,omitempty"` + Memory *Info_Memory `protobuf:"bytes,5,opt,name=memory,proto3" json:"memory,omitempty"` // The pod information of the node. - Pods *Info_Pods `protobuf:"bytes,6,opt,name=Pods,proto3" json:"Pods,omitempty"` + Pods *Info_Pods `protobuf:"bytes,6,opt,name=Pods,proto3" json:"Pods,omitempty"` } func (x *Info_Node) Reset() { @@ -4146,17 +4149,17 @@ type Info_Service struct { unknownFields protoimpl.UnknownFields // The name of the svc. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // The cluster ip of the svc. - ClusterIp string `protobuf:"bytes,2,opt,name=cluster_ip,json=clusterIp,proto3" json:"cluster_ip,omitempty"` + ClusterIp string `protobuf:"bytes,2,opt,name=cluster_ip,json=clusterIp,proto3" json:"cluster_ip,omitempty"` // The cluster ips of the svc. ClusterIps []string `protobuf:"bytes,3,rep,name=cluster_ips,json=clusterIps,proto3" json:"cluster_ips,omitempty"` // The port of the svc. - Ports []*Info_ServicePort `protobuf:"bytes,4,rep,name=ports,proto3" json:"ports,omitempty"` + Ports []*Info_ServicePort `protobuf:"bytes,4,rep,name=ports,proto3" json:"ports,omitempty"` // The labels of the service. - Labels *Info_Labels `protobuf:"bytes,5,opt,name=labels,proto3" json:"labels,omitempty"` + Labels *Info_Labels `protobuf:"bytes,5,opt,name=labels,proto3" json:"labels,omitempty"` // The annotations of the service. - Annotations *Info_Annotations `protobuf:"bytes,6,opt,name=annotations,proto3" json:"annotations,omitempty"` + Annotations *Info_Annotations `protobuf:"bytes,6,opt,name=annotations,proto3" json:"annotations,omitempty"` } func (x *Info_Service) Reset() { @@ -4240,7 +4243,7 @@ type Info_ServicePort struct { unknownFields protoimpl.UnknownFields // The name of the port. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // The port number Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` } @@ -4394,11 +4397,11 @@ type Info_CPU struct { unknownFields protoimpl.UnknownFields // The CPU resource limit. - Limit float64 `protobuf:"fixed64,1,opt,name=limit,proto3" json:"limit,omitempty"` + Limit float64 `protobuf:"fixed64,1,opt,name=limit,proto3" json:"limit,omitempty"` // The CPU resource requested. Request float64 `protobuf:"fixed64,2,opt,name=request,proto3" json:"request,omitempty"` // The CPU usage. - Usage float64 `protobuf:"fixed64,3,opt,name=usage,proto3" json:"usage,omitempty"` + Usage float64 `protobuf:"fixed64,3,opt,name=usage,proto3" json:"usage,omitempty"` } func (x *Info_CPU) Reset() { @@ -4461,11 +4464,11 @@ type Info_Memory struct { unknownFields protoimpl.UnknownFields // The memory limit. - Limit float64 `protobuf:"fixed64,1,opt,name=limit,proto3" json:"limit,omitempty"` + Limit float64 `protobuf:"fixed64,1,opt,name=limit,proto3" json:"limit,omitempty"` // The memory requested. Request float64 `protobuf:"fixed64,2,opt,name=request,proto3" json:"request,omitempty"` // The memory usage. - Usage float64 `protobuf:"fixed64,3,opt,name=usage,proto3" json:"usage,omitempty"` + Usage float64 `protobuf:"fixed64,3,opt,name=usage,proto3" json:"usage,omitempty"` } func (x *Info_Memory) Reset() { @@ -4723,13 +4726,13 @@ type Info_Index_Count struct { unknownFields protoimpl.UnknownFields // The stored index count. - Stored uint32 `protobuf:"varint,1,opt,name=stored,proto3" json:"stored,omitempty"` + Stored uint32 `protobuf:"varint,1,opt,name=stored,proto3" json:"stored,omitempty"` // The uncommitted index count. Uncommitted uint32 `protobuf:"varint,2,opt,name=uncommitted,proto3" json:"uncommitted,omitempty"` // The indexing index count. - Indexing bool `protobuf:"varint,3,opt,name=indexing,proto3" json:"indexing,omitempty"` + Indexing bool `protobuf:"varint,3,opt,name=indexing,proto3" json:"indexing,omitempty"` // The saving index count. - Saving bool `protobuf:"varint,4,opt,name=saving,proto3" json:"saving,omitempty"` + Saving bool `protobuf:"varint,4,opt,name=saving,proto3" json:"saving,omitempty"` } func (x *Info_Index_Count) Reset() { @@ -4792,6 +4795,73 @@ func (x *Info_Index_Count) GetSaving() bool { return false } +// Represent the index count for each Agents message. +type Info_Index_Detail struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // count infos for each agents + Counts map[string]*Info_Index_Count `protobuf:"bytes,1,rep,name=counts,proto3" json:"counts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // index replica of vald cluster + Replica uint32 `protobuf:"varint,2,opt,name=replica,proto3" json:"replica,omitempty"` + // live agent replica of vald cluster + LiveAgents uint32 `protobuf:"varint,3,opt,name=live_agents,json=liveAgents,proto3" json:"live_agents,omitempty"` +} + +func (x *Info_Index_Detail) Reset() { + *x = Info_Index_Detail{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_payload_payload_proto_msgTypes[81] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Info_Index_Detail) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Info_Index_Detail) ProtoMessage() {} + +func (x *Info_Index_Detail) ProtoReflect() protoreflect.Message { + mi := &file_v1_payload_payload_proto_msgTypes[81] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Info_Index_Detail.ProtoReflect.Descriptor instead. +func (*Info_Index_Detail) Descriptor() ([]byte, []int) { + return file_v1_payload_payload_proto_rawDescGZIP(), []int{10, 0, 1} +} + +func (x *Info_Index_Detail) GetCounts() map[string]*Info_Index_Count { + if x != nil { + return x.Counts + } + return nil +} + +func (x *Info_Index_Detail) GetReplica() uint32 { + if x != nil { + return x.Replica + } + return 0 +} + +func (x *Info_Index_Detail) GetLiveAgents() uint32 { + if x != nil { + return x.LiveAgents + } + return 0 +} + // Represent the UUID message. type Info_Index_UUID struct { state protoimpl.MessageState @@ -4802,7 +4872,7 @@ type Info_Index_UUID struct { func (x *Info_Index_UUID) Reset() { *x = Info_Index_UUID{} if protoimpl.UnsafeEnabled { - mi := &file_v1_payload_payload_proto_msgTypes[81] + mi := &file_v1_payload_payload_proto_msgTypes[82] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4815,7 +4885,7 @@ func (x *Info_Index_UUID) String() string { func (*Info_Index_UUID) ProtoMessage() {} func (x *Info_Index_UUID) ProtoReflect() protoreflect.Message { - mi := &file_v1_payload_payload_proto_msgTypes[81] + mi := &file_v1_payload_payload_proto_msgTypes[82] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4828,7 +4898,360 @@ func (x *Info_Index_UUID) ProtoReflect() protoreflect.Message { // Deprecated: Use Info_Index_UUID.ProtoReflect.Descriptor instead. func (*Info_Index_UUID) Descriptor() ([]byte, []int) { - return file_v1_payload_payload_proto_rawDescGZIP(), []int{10, 0, 1} + return file_v1_payload_payload_proto_rawDescGZIP(), []int{10, 0, 2} +} + +// Represents index Statistics +type Info_Index_Statistics struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Valid bool `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"` + MedianIndegree int32 `protobuf:"varint,2,opt,name=median_indegree,json=medianIndegree,proto3" json:"median_indegree,omitempty"` + MedianOutdegree int32 `protobuf:"varint,3,opt,name=median_outdegree,json=medianOutdegree,proto3" json:"median_outdegree,omitempty"` + MaxNumberOfIndegree uint64 `protobuf:"varint,4,opt,name=max_number_of_indegree,json=maxNumberOfIndegree,proto3" json:"max_number_of_indegree,omitempty"` + MaxNumberOfOutdegree uint64 `protobuf:"varint,5,opt,name=max_number_of_outdegree,json=maxNumberOfOutdegree,proto3" json:"max_number_of_outdegree,omitempty"` + MinNumberOfIndegree uint64 `protobuf:"varint,6,opt,name=min_number_of_indegree,json=minNumberOfIndegree,proto3" json:"min_number_of_indegree,omitempty"` + MinNumberOfOutdegree uint64 `protobuf:"varint,7,opt,name=min_number_of_outdegree,json=minNumberOfOutdegree,proto3" json:"min_number_of_outdegree,omitempty"` + ModeIndegree uint64 `protobuf:"varint,8,opt,name=mode_indegree,json=modeIndegree,proto3" json:"mode_indegree,omitempty"` + ModeOutdegree uint64 `protobuf:"varint,9,opt,name=mode_outdegree,json=modeOutdegree,proto3" json:"mode_outdegree,omitempty"` + NodesSkippedFor10Edges uint64 `protobuf:"varint,10,opt,name=nodes_skipped_for_10_edges,json=nodesSkippedFor10Edges,proto3" json:"nodes_skipped_for_10_edges,omitempty"` + NodesSkippedForIndegreeDistance uint64 `protobuf:"varint,11,opt,name=nodes_skipped_for_indegree_distance,json=nodesSkippedForIndegreeDistance,proto3" json:"nodes_skipped_for_indegree_distance,omitempty"` + NumberOfEdges uint64 `protobuf:"varint,12,opt,name=number_of_edges,json=numberOfEdges,proto3" json:"number_of_edges,omitempty"` + NumberOfIndexedObjects uint64 `protobuf:"varint,13,opt,name=number_of_indexed_objects,json=numberOfIndexedObjects,proto3" json:"number_of_indexed_objects,omitempty"` + NumberOfNodes uint64 `protobuf:"varint,14,opt,name=number_of_nodes,json=numberOfNodes,proto3" json:"number_of_nodes,omitempty"` + NumberOfNodesWithoutEdges uint64 `protobuf:"varint,15,opt,name=number_of_nodes_without_edges,json=numberOfNodesWithoutEdges,proto3" json:"number_of_nodes_without_edges,omitempty"` + NumberOfNodesWithoutIndegree uint64 `protobuf:"varint,16,opt,name=number_of_nodes_without_indegree,json=numberOfNodesWithoutIndegree,proto3" json:"number_of_nodes_without_indegree,omitempty"` + NumberOfObjects uint64 `protobuf:"varint,17,opt,name=number_of_objects,json=numberOfObjects,proto3" json:"number_of_objects,omitempty"` + NumberOfRemovedObjects uint64 `protobuf:"varint,18,opt,name=number_of_removed_objects,json=numberOfRemovedObjects,proto3" json:"number_of_removed_objects,omitempty"` + SizeOfObjectRepository uint64 `protobuf:"varint,19,opt,name=size_of_object_repository,json=sizeOfObjectRepository,proto3" json:"size_of_object_repository,omitempty"` + SizeOfRefinementObjectRepository uint64 `protobuf:"varint,20,opt,name=size_of_refinement_object_repository,json=sizeOfRefinementObjectRepository,proto3" json:"size_of_refinement_object_repository,omitempty"` + VarianceOfIndegree float64 `protobuf:"fixed64,21,opt,name=variance_of_indegree,json=varianceOfIndegree,proto3" json:"variance_of_indegree,omitempty"` + VarianceOfOutdegree float64 `protobuf:"fixed64,22,opt,name=variance_of_outdegree,json=varianceOfOutdegree,proto3" json:"variance_of_outdegree,omitempty"` + MeanEdgeLength float64 `protobuf:"fixed64,23,opt,name=mean_edge_length,json=meanEdgeLength,proto3" json:"mean_edge_length,omitempty"` + MeanEdgeLengthFor10Edges float64 `protobuf:"fixed64,24,opt,name=mean_edge_length_for_10_edges,json=meanEdgeLengthFor10Edges,proto3" json:"mean_edge_length_for_10_edges,omitempty"` + MeanIndegreeDistanceFor10Edges float64 `protobuf:"fixed64,25,opt,name=mean_indegree_distance_for_10_edges,json=meanIndegreeDistanceFor10Edges,proto3" json:"mean_indegree_distance_for_10_edges,omitempty"` + MeanNumberOfEdgesPerNode float64 `protobuf:"fixed64,26,opt,name=mean_number_of_edges_per_node,json=meanNumberOfEdgesPerNode,proto3" json:"mean_number_of_edges_per_node,omitempty"` + C1Indegree float64 `protobuf:"fixed64,27,opt,name=c1_indegree,json=c1Indegree,proto3" json:"c1_indegree,omitempty"` + C5Indegree float64 `protobuf:"fixed64,28,opt,name=c5_indegree,json=c5Indegree,proto3" json:"c5_indegree,omitempty"` + C95Outdegree float64 `protobuf:"fixed64,29,opt,name=c95_outdegree,json=c95Outdegree,proto3" json:"c95_outdegree,omitempty"` + C99Outdegree float64 `protobuf:"fixed64,30,opt,name=c99_outdegree,json=c99Outdegree,proto3" json:"c99_outdegree,omitempty"` + IndegreeCount []int64 `protobuf:"varint,31,rep,packed,name=indegree_count,json=indegreeCount,proto3" json:"indegree_count,omitempty"` + OutdegreeHistogram []uint64 `protobuf:"varint,32,rep,packed,name=outdegree_histogram,json=outdegreeHistogram,proto3" json:"outdegree_histogram,omitempty"` + IndegreeHistogram []uint64 `protobuf:"varint,33,rep,packed,name=indegree_histogram,json=indegreeHistogram,proto3" json:"indegree_histogram,omitempty"` +} + +func (x *Info_Index_Statistics) Reset() { + *x = Info_Index_Statistics{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_payload_payload_proto_msgTypes[83] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Info_Index_Statistics) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Info_Index_Statistics) ProtoMessage() {} + +func (x *Info_Index_Statistics) ProtoReflect() protoreflect.Message { + mi := &file_v1_payload_payload_proto_msgTypes[83] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Info_Index_Statistics.ProtoReflect.Descriptor instead. +func (*Info_Index_Statistics) Descriptor() ([]byte, []int) { + return file_v1_payload_payload_proto_rawDescGZIP(), []int{10, 0, 3} +} + +func (x *Info_Index_Statistics) GetValid() bool { + if x != nil { + return x.Valid + } + return false +} + +func (x *Info_Index_Statistics) GetMedianIndegree() int32 { + if x != nil { + return x.MedianIndegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetMedianOutdegree() int32 { + if x != nil { + return x.MedianOutdegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetMaxNumberOfIndegree() uint64 { + if x != nil { + return x.MaxNumberOfIndegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetMaxNumberOfOutdegree() uint64 { + if x != nil { + return x.MaxNumberOfOutdegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetMinNumberOfIndegree() uint64 { + if x != nil { + return x.MinNumberOfIndegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetMinNumberOfOutdegree() uint64 { + if x != nil { + return x.MinNumberOfOutdegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetModeIndegree() uint64 { + if x != nil { + return x.ModeIndegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetModeOutdegree() uint64 { + if x != nil { + return x.ModeOutdegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetNodesSkippedFor10Edges() uint64 { + if x != nil { + return x.NodesSkippedFor10Edges + } + return 0 +} + +func (x *Info_Index_Statistics) GetNodesSkippedForIndegreeDistance() uint64 { + if x != nil { + return x.NodesSkippedForIndegreeDistance + } + return 0 +} + +func (x *Info_Index_Statistics) GetNumberOfEdges() uint64 { + if x != nil { + return x.NumberOfEdges + } + return 0 +} + +func (x *Info_Index_Statistics) GetNumberOfIndexedObjects() uint64 { + if x != nil { + return x.NumberOfIndexedObjects + } + return 0 +} + +func (x *Info_Index_Statistics) GetNumberOfNodes() uint64 { + if x != nil { + return x.NumberOfNodes + } + return 0 +} + +func (x *Info_Index_Statistics) GetNumberOfNodesWithoutEdges() uint64 { + if x != nil { + return x.NumberOfNodesWithoutEdges + } + return 0 +} + +func (x *Info_Index_Statistics) GetNumberOfNodesWithoutIndegree() uint64 { + if x != nil { + return x.NumberOfNodesWithoutIndegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetNumberOfObjects() uint64 { + if x != nil { + return x.NumberOfObjects + } + return 0 +} + +func (x *Info_Index_Statistics) GetNumberOfRemovedObjects() uint64 { + if x != nil { + return x.NumberOfRemovedObjects + } + return 0 +} + +func (x *Info_Index_Statistics) GetSizeOfObjectRepository() uint64 { + if x != nil { + return x.SizeOfObjectRepository + } + return 0 +} + +func (x *Info_Index_Statistics) GetSizeOfRefinementObjectRepository() uint64 { + if x != nil { + return x.SizeOfRefinementObjectRepository + } + return 0 +} + +func (x *Info_Index_Statistics) GetVarianceOfIndegree() float64 { + if x != nil { + return x.VarianceOfIndegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetVarianceOfOutdegree() float64 { + if x != nil { + return x.VarianceOfOutdegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetMeanEdgeLength() float64 { + if x != nil { + return x.MeanEdgeLength + } + return 0 +} + +func (x *Info_Index_Statistics) GetMeanEdgeLengthFor10Edges() float64 { + if x != nil { + return x.MeanEdgeLengthFor10Edges + } + return 0 +} + +func (x *Info_Index_Statistics) GetMeanIndegreeDistanceFor10Edges() float64 { + if x != nil { + return x.MeanIndegreeDistanceFor10Edges + } + return 0 +} + +func (x *Info_Index_Statistics) GetMeanNumberOfEdgesPerNode() float64 { + if x != nil { + return x.MeanNumberOfEdgesPerNode + } + return 0 +} + +func (x *Info_Index_Statistics) GetC1Indegree() float64 { + if x != nil { + return x.C1Indegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetC5Indegree() float64 { + if x != nil { + return x.C5Indegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetC95Outdegree() float64 { + if x != nil { + return x.C95Outdegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetC99Outdegree() float64 { + if x != nil { + return x.C99Outdegree + } + return 0 +} + +func (x *Info_Index_Statistics) GetIndegreeCount() []int64 { + if x != nil { + return x.IndegreeCount + } + return nil +} + +func (x *Info_Index_Statistics) GetOutdegreeHistogram() []uint64 { + if x != nil { + return x.OutdegreeHistogram + } + return nil +} + +func (x *Info_Index_Statistics) GetIndegreeHistogram() []uint64 { + if x != nil { + return x.IndegreeHistogram + } + return nil +} + +// Represents index Statistics for each Agents +type Info_Index_StatisticsDetail struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // count infos for each agents + Details map[string]*Info_Index_Statistics `protobuf:"bytes,1,rep,name=details,proto3" json:"details,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Info_Index_StatisticsDetail) Reset() { + *x = Info_Index_StatisticsDetail{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_payload_payload_proto_msgTypes[84] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Info_Index_StatisticsDetail) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Info_Index_StatisticsDetail) ProtoMessage() {} + +func (x *Info_Index_StatisticsDetail) ProtoReflect() protoreflect.Message { + mi := &file_v1_payload_payload_proto_msgTypes[84] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Info_Index_StatisticsDetail.ProtoReflect.Descriptor instead. +func (*Info_Index_StatisticsDetail) Descriptor() ([]byte, []int) { + return file_v1_payload_payload_proto_rawDescGZIP(), []int{10, 0, 4} +} + +func (x *Info_Index_StatisticsDetail) GetDetails() map[string]*Info_Index_Statistics { + if x != nil { + return x.Details + } + return nil } // The committed UUID. @@ -4843,7 +5266,7 @@ type Info_Index_UUID_Committed struct { func (x *Info_Index_UUID_Committed) Reset() { *x = Info_Index_UUID_Committed{} if protoimpl.UnsafeEnabled { - mi := &file_v1_payload_payload_proto_msgTypes[82] + mi := &file_v1_payload_payload_proto_msgTypes[86] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4856,7 +5279,7 @@ func (x *Info_Index_UUID_Committed) String() string { func (*Info_Index_UUID_Committed) ProtoMessage() {} func (x *Info_Index_UUID_Committed) ProtoReflect() protoreflect.Message { - mi := &file_v1_payload_payload_proto_msgTypes[82] + mi := &file_v1_payload_payload_proto_msgTypes[86] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4869,7 +5292,7 @@ func (x *Info_Index_UUID_Committed) ProtoReflect() protoreflect.Message { // Deprecated: Use Info_Index_UUID_Committed.ProtoReflect.Descriptor instead. func (*Info_Index_UUID_Committed) Descriptor() ([]byte, []int) { - return file_v1_payload_payload_proto_rawDescGZIP(), []int{10, 0, 1, 0} + return file_v1_payload_payload_proto_rawDescGZIP(), []int{10, 0, 2, 0} } func (x *Info_Index_UUID_Committed) GetUuid() string { @@ -4891,7 +5314,7 @@ type Info_Index_UUID_Uncommitted struct { func (x *Info_Index_UUID_Uncommitted) Reset() { *x = Info_Index_UUID_Uncommitted{} if protoimpl.UnsafeEnabled { - mi := &file_v1_payload_payload_proto_msgTypes[83] + mi := &file_v1_payload_payload_proto_msgTypes[87] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4904,7 +5327,7 @@ func (x *Info_Index_UUID_Uncommitted) String() string { func (*Info_Index_UUID_Uncommitted) ProtoMessage() {} func (x *Info_Index_UUID_Uncommitted) ProtoReflect() protoreflect.Message { - mi := &file_v1_payload_payload_proto_msgTypes[83] + mi := &file_v1_payload_payload_proto_msgTypes[87] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4917,7 +5340,7 @@ func (x *Info_Index_UUID_Uncommitted) ProtoReflect() protoreflect.Message { // Deprecated: Use Info_Index_UUID_Uncommitted.ProtoReflect.Descriptor instead. func (*Info_Index_UUID_Uncommitted) Descriptor() ([]byte, []int) { - return file_v1_payload_payload_proto_rawDescGZIP(), []int{10, 0, 1, 1} + return file_v1_payload_payload_proto_rawDescGZIP(), []int{10, 0, 2, 1} } func (x *Info_Index_UUID_Uncommitted) GetUuid() string { @@ -4934,7 +5357,7 @@ type Mirror_Target struct { unknownFields protoimpl.UnknownFields // The target hostname. - Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` // The target port. Port uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` } @@ -4942,7 +5365,7 @@ type Mirror_Target struct { func (x *Mirror_Target) Reset() { *x = Mirror_Target{} if protoimpl.UnsafeEnabled { - mi := &file_v1_payload_payload_proto_msgTypes[86] + mi := &file_v1_payload_payload_proto_msgTypes[91] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4955,7 +5378,7 @@ func (x *Mirror_Target) String() string { func (*Mirror_Target) ProtoMessage() {} func (x *Mirror_Target) ProtoReflect() protoreflect.Message { - mi := &file_v1_payload_payload_proto_msgTypes[86] + mi := &file_v1_payload_payload_proto_msgTypes[91] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4998,7 +5421,7 @@ type Mirror_Targets struct { func (x *Mirror_Targets) Reset() { *x = Mirror_Targets{} if protoimpl.UnsafeEnabled { - mi := &file_v1_payload_payload_proto_msgTypes[87] + mi := &file_v1_payload_payload_proto_msgTypes[92] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5011,7 +5434,7 @@ func (x *Mirror_Targets) String() string { func (*Mirror_Targets) ProtoMessage() {} func (x *Mirror_Targets) ProtoReflect() protoreflect.Message { - mi := &file_v1_payload_payload_proto_msgTypes[87] + mi := &file_v1_payload_payload_proto_msgTypes[92] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -5299,7 +5722,7 @@ var file_v1_payload_payload_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x12, 0x0a, 0x05, 0x46, 0x6c, 0x75, 0x73, 0x68, 0x1a, - 0x09, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xb4, 0x0b, 0x0a, 0x06, 0x4f, + 0x09, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xb1, 0x0b, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x1a, 0x75, 0x0a, 0x0d, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, @@ -5329,200 +5752,332 @@ var file_v1_payload_payload_proto_rawDesc = []byte{ 0x18, 0x02, 0x20, 0x03, 0x28, 0x02, 0x42, 0x08, 0xba, 0x48, 0x05, 0x92, 0x01, 0x02, 0x08, 0x02, 0x52, 0x06, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, 0x46, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2f, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x61, 0x79, 0x6c, - 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x49, 0x44, - 0x42, 0x08, 0xba, 0x48, 0x05, 0x92, 0x01, 0x02, 0x08, 0x02, 0x52, 0x02, 0x69, 0x64, 0x1a, 0x42, - 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x17, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x1a, 0x3e, 0x0a, 0x07, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x33, 0x0a, - 0x07, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, - 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x07, 0x76, 0x65, 0x63, 0x74, 0x6f, - 0x72, 0x73, 0x1a, 0x7c, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x56, 0x65, 0x63, 0x74, - 0x6f, 0x72, 0x12, 0x33, 0x0a, 0x06, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, - 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x48, 0x00, 0x52, - 0x06, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, - 0x1a, 0x3d, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x68, 0x61, 0x70, 0x65, 0x56, 0x65, 0x63, 0x74, 0x6f, - 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x68, 0x61, - 0x70, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x05, 0x73, 0x68, 0x61, 0x70, 0x65, 0x1a, - 0x37, 0x0a, 0x04, 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x1a, 0x74, 0x0a, 0x0a, 0x53, 0x74, 0x72, 0x65, - 0x61, 0x6d, 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x2d, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, - 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x48, 0x00, 0x52, - 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, 0x43, 0x0a, 0x10, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x49, 0x44, 0x42, 0x08, 0xba, + 0x48, 0x05, 0x92, 0x01, 0x02, 0x08, 0x02, 0x52, 0x02, 0x69, 0x64, 0x1a, 0x42, 0x0a, 0x09, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, + 0x3e, 0x0a, 0x07, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x33, 0x0a, 0x07, 0x76, 0x65, + 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, + 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x07, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x1a, + 0x7c, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, + 0x33, 0x0a, 0x06, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x06, 0x76, 0x65, + 0x63, 0x74, 0x6f, 0x72, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x3d, 0x0a, + 0x0d, 0x52, 0x65, 0x73, 0x68, 0x61, 0x70, 0x65, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x16, + 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x68, 0x61, 0x70, 0x65, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x05, 0x73, 0x68, 0x61, 0x70, 0x65, 0x1a, 0x37, 0x0a, 0x04, + 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, + 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x1a, 0x74, 0x0a, 0x0a, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, + 0x6c, 0x6f, 0x62, 0x12, 0x2d, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x48, 0x00, 0x52, 0x04, 0x62, 0x6c, + 0x6f, 0x62, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x44, 0x0a, 0x08, 0x4c, + 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, + 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, + 0x10, 0x0a, 0x03, 0x69, 0x70, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x69, 0x70, + 0x73, 0x1a, 0x84, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x4c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x09, 0x0a, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x46, 0x0a, 0x09, 0x4c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x39, 0x0a, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x4c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x1a, 0x8b, 0x01, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x1a, 0x09, 0x0a, 0x07, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x78, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x33, 0x0a, 0x06, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x06, 0x76, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x44, - 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x74, 0x75, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x45, + 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x1a, 0x3a, 0x0a, 0x12, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x24, 0x0a, 0x09, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0d, 0x42, 0x07, 0xba, 0x48, 0x04, 0x2a, 0x02, 0x28, 0x00, 0x52, 0x08, 0x70, 0x6f, 0x6f, + 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x66, 0x0a, 0x0a, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x65, 0x72, 0x1a, 0x58, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, + 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x64, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x22, 0xd2, 0x1d, + 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x90, 0x12, 0x0a, 0x05, 0x49, 0x6e, 0x64, 0x65, 0x78, + 0x1a, 0x75, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x74, 0x65, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, + 0x16, 0x0a, 0x06, 0x73, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x06, 0x73, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x1a, 0xdf, 0x01, 0x0a, 0x06, 0x44, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x12, 0x41, 0x0a, 0x06, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, + 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x69, + 0x6c, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x12, + 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6c, 0x69, 0x76, 0x65, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x73, + 0x1a, 0x57, 0x0a, 0x0b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x32, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, + 0x66, 0x6f, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x4a, 0x0a, 0x04, 0x55, 0x55, 0x49, + 0x44, 0x1a, 0x1f, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x12, 0x12, + 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, + 0x69, 0x64, 0x1a, 0x21, 0x0a, 0x0b, 0x55, 0x6e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x75, 0x75, 0x69, 0x64, 0x1a, 0x9d, 0x0d, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, + 0x74, 0x69, 0x63, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6d, 0x65, + 0x64, 0x69, 0x61, 0x6e, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x67, + 0x72, 0x65, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x6e, 0x5f, 0x6f, 0x75, + 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x6d, + 0x65, 0x64, 0x69, 0x61, 0x6e, 0x4f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x12, 0x33, + 0x0a, 0x16, 0x6d, 0x61, 0x78, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, 0x5f, + 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x13, + 0x6d, 0x61, 0x78, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x49, 0x6e, 0x64, 0x65, 0x67, + 0x72, 0x65, 0x65, 0x12, 0x35, 0x0a, 0x17, 0x6d, 0x61, 0x78, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x6d, 0x61, 0x78, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, + 0x66, 0x4f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x12, 0x33, 0x0a, 0x16, 0x6d, 0x69, + 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x69, 0x6e, 0x64, 0x65, + 0x67, 0x72, 0x65, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x13, 0x6d, 0x69, 0x6e, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x49, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x12, + 0x35, 0x0a, 0x17, 0x6d, 0x69, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, + 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x14, 0x6d, 0x69, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x4f, 0x75, 0x74, + 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, + 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x6d, + 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x6d, + 0x6f, 0x64, 0x65, 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6d, 0x6f, 0x64, 0x65, 0x4f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, + 0x65, 0x65, 0x12, 0x3a, 0x0a, 0x1a, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x5f, 0x73, 0x6b, 0x69, 0x70, + 0x70, 0x65, 0x64, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x31, 0x30, 0x5f, 0x65, 0x64, 0x67, 0x65, 0x73, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x16, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x53, 0x6b, 0x69, + 0x70, 0x70, 0x65, 0x64, 0x46, 0x6f, 0x72, 0x31, 0x30, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x4c, + 0x0a, 0x23, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x5f, 0x73, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x5f, + 0x66, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x5f, 0x64, 0x69, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x04, 0x52, 0x1f, 0x6e, 0x6f, 0x64, + 0x65, 0x73, 0x53, 0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x46, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, + 0x67, 0x72, 0x65, 0x65, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x26, 0x0a, 0x0f, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x64, 0x67, 0x65, 0x73, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x45, + 0x64, 0x67, 0x65, 0x73, 0x12, 0x39, 0x0a, 0x19, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, + 0x66, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x64, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x16, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, + 0x66, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x64, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, + 0x26, 0x0a, 0x0f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x6e, 0x6f, 0x64, + 0x65, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x4f, 0x66, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x40, 0x0a, 0x1d, 0x6e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x6f, + 0x75, 0x74, 0x5f, 0x65, 0x64, 0x67, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x04, 0x52, 0x19, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x57, 0x69, 0x74, + 0x68, 0x6f, 0x75, 0x74, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x46, 0x0a, 0x20, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x5f, 0x77, 0x69, 0x74, + 0x68, 0x6f, 0x75, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x10, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x1c, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x4e, 0x6f, 0x64, + 0x65, 0x73, 0x57, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, + 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x39, 0x0a, + 0x19, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x72, 0x65, 0x6d, 0x6f, 0x76, + 0x65, 0x64, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x12, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x16, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x64, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x39, 0x0a, 0x19, 0x73, 0x69, 0x7a, 0x65, + 0x5f, 0x6f, 0x66, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x13, 0x20, 0x01, 0x28, 0x04, 0x52, 0x16, 0x73, 0x69, 0x7a, + 0x65, 0x4f, 0x66, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x12, 0x4e, 0x0a, 0x24, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x6f, 0x66, 0x5f, 0x72, + 0x65, 0x66, 0x69, 0x6e, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x14, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x4f, 0x66, 0x52, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x12, 0x30, 0x0a, 0x14, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x5f, + 0x6f, 0x66, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, + 0x01, 0x52, 0x12, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x4f, 0x66, 0x49, 0x6e, 0x64, + 0x65, 0x67, 0x72, 0x65, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x63, + 0x65, 0x5f, 0x6f, 0x66, 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x16, + 0x20, 0x01, 0x28, 0x01, 0x52, 0x13, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x4f, 0x66, + 0x4f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x6d, 0x65, 0x61, + 0x6e, 0x5f, 0x65, 0x64, 0x67, 0x65, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x17, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x0e, 0x6d, 0x65, 0x61, 0x6e, 0x45, 0x64, 0x67, 0x65, 0x4c, 0x65, 0x6e, + 0x67, 0x74, 0x68, 0x12, 0x3f, 0x0a, 0x1d, 0x6d, 0x65, 0x61, 0x6e, 0x5f, 0x65, 0x64, 0x67, 0x65, + 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x31, 0x30, 0x5f, 0x65, + 0x64, 0x67, 0x65, 0x73, 0x18, 0x18, 0x20, 0x01, 0x28, 0x01, 0x52, 0x18, 0x6d, 0x65, 0x61, 0x6e, + 0x45, 0x64, 0x67, 0x65, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x46, 0x6f, 0x72, 0x31, 0x30, 0x45, + 0x64, 0x67, 0x65, 0x73, 0x12, 0x4b, 0x0a, 0x23, 0x6d, 0x65, 0x61, 0x6e, 0x5f, 0x69, 0x6e, 0x64, + 0x65, 0x67, 0x72, 0x65, 0x65, 0x5f, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x66, + 0x6f, 0x72, 0x5f, 0x31, 0x30, 0x5f, 0x65, 0x64, 0x67, 0x65, 0x73, 0x18, 0x19, 0x20, 0x01, 0x28, + 0x01, 0x52, 0x1e, 0x6d, 0x65, 0x61, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x44, + 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, 0x6f, 0x72, 0x31, 0x30, 0x45, 0x64, 0x67, 0x65, + 0x73, 0x12, 0x3f, 0x0a, 0x1d, 0x6d, 0x65, 0x61, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x64, 0x67, 0x65, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x6e, 0x6f, + 0x64, 0x65, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x01, 0x52, 0x18, 0x6d, 0x65, 0x61, 0x6e, 0x4e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x45, 0x64, 0x67, 0x65, 0x73, 0x50, 0x65, 0x72, 0x4e, 0x6f, + 0x64, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x31, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, + 0x65, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, 0x63, 0x31, 0x49, 0x6e, 0x64, 0x65, 0x67, + 0x72, 0x65, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x35, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, + 0x65, 0x65, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, 0x63, 0x35, 0x49, 0x6e, 0x64, 0x65, + 0x67, 0x72, 0x65, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x39, 0x35, 0x5f, 0x6f, 0x75, 0x74, 0x64, + 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x1d, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x63, 0x39, 0x35, + 0x4f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x39, 0x39, + 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x0c, 0x63, 0x39, 0x39, 0x4f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x12, 0x25, + 0x0a, 0x0e, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x1f, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0d, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2f, 0x0a, 0x13, 0x6f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, + 0x65, 0x65, 0x5f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x18, 0x20, 0x20, 0x03, + 0x28, 0x04, 0x52, 0x12, 0x6f, 0x75, 0x74, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x48, 0x69, 0x73, + 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x2d, 0x0a, 0x12, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, + 0x65, 0x65, 0x5f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x18, 0x21, 0x20, 0x03, + 0x28, 0x04, 0x52, 0x11, 0x69, 0x6e, 0x64, 0x65, 0x67, 0x72, 0x65, 0x65, 0x48, 0x69, 0x73, 0x74, + 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x1a, 0xc1, 0x01, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, + 0x74, 0x69, 0x63, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x4e, 0x0a, 0x07, 0x64, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x1a, 0x5d, 0x0a, 0x0c, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x37, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0xef, 0x01, 0x0a, 0x03, 0x50, 0x6f, + 0x64, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, + 0x0a, 0x02, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, + 0x02, 0x78, 0x01, 0x52, 0x02, 0x69, 0x70, 0x12, 0x26, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, + 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x43, 0x50, 0x55, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, + 0x2f, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x17, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, + 0x6f, 0x2e, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, + 0x12, 0x29, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, + 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, + 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x1a, 0xe8, 0x01, 0x0a, 0x04, + 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x23, 0x0a, + 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x64, + 0x64, 0x72, 0x12, 0x26, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x14, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, + 0x6f, 0x2e, 0x43, 0x50, 0x55, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x2f, 0x0a, 0x06, 0x6d, 0x65, + 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4d, 0x65, 0x6d, + 0x6f, 0x72, 0x79, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x29, 0x0a, 0x04, 0x50, + 0x6f, 0x64, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x6f, 0x64, 0x73, + 0x52, 0x04, 0x50, 0x6f, 0x64, 0x73, 0x1a, 0x82, 0x02, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x5f, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x49, 0x70, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, + 0x5f, 0x69, 0x70, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x49, 0x70, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, + 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, + 0x6f, 0x72, 0x74, 0x52, 0x05, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x06, 0x6c, 0x61, + 0x62, 0x65, 0x6c, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x61, 0x62, + 0x65, 0x6c, 0x73, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x3e, 0x0a, 0x0b, 0x61, + 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, + 0x66, 0x6f, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x0b, + 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x35, 0x0a, 0x0b, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, - 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x70, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x03, 0x69, 0x70, 0x73, 0x1a, 0x84, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x4c, - 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x61, 0x79, 0x6c, - 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x4c, 0x6f, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x46, 0x0a, 0x09, 0x4c, - 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x39, 0x0a, 0x09, 0x6c, 0x6f, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x61, - 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, - 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x1a, 0x8b, 0x01, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x1a, 0x09, 0x0a, 0x07, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x78, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, - 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x48, 0x00, - 0x52, 0x06, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x22, 0x45, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x1a, 0x3a, 0x0a, 0x12, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x24, 0x0a, 0x09, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x07, 0xba, 0x48, 0x04, 0x2a, 0x02, 0x28, 0x00, 0x52, 0x08, - 0x70, 0x6f, 0x6f, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x66, 0x0a, 0x0a, 0x44, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x65, 0x72, 0x1a, 0x58, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, - 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, - 0x22, 0x8c, 0x0d, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0xca, 0x01, 0x0a, 0x05, 0x49, 0x6e, - 0x64, 0x65, 0x78, 0x1a, 0x75, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x74, - 0x6f, 0x72, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x75, 0x6e, 0x63, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x69, - 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x69, - 0x6e, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x06, 0x73, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x1a, 0x4a, 0x0a, 0x04, 0x55, 0x55, - 0x49, 0x44, 0x1a, 0x1f, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x12, - 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, - 0x75, 0x69, 0x64, 0x1a, 0x21, 0x0a, 0x0b, 0x55, 0x6e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, - 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x1a, 0xef, 0x01, 0x0a, 0x03, 0x50, 0x6f, 0x64, 0x12, 0x19, - 0x0a, 0x08, 0x61, 0x70, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, - 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x02, 0x69, - 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x78, 0x01, - 0x52, 0x02, 0x69, 0x70, 0x12, 0x26, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, - 0x6e, 0x66, 0x6f, 0x2e, 0x43, 0x50, 0x55, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x2f, 0x0a, 0x06, - 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4d, - 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x29, 0x0a, - 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x61, - 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4e, 0x6f, - 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x1a, 0xe8, 0x01, 0x0a, 0x04, 0x4e, 0x6f, 0x64, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x78, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, - 0x26, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x43, - 0x50, 0x55, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x2f, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, - 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, - 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x29, 0x0a, 0x04, 0x50, 0x6f, 0x64, 0x73, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, - 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x6f, 0x64, 0x73, 0x52, 0x04, 0x50, - 0x6f, 0x64, 0x73, 0x1a, 0x82, 0x02, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x69, - 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x49, 0x70, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x70, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x49, 0x70, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, - 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, - 0x52, 0x05, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, - 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, - 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x3e, 0x0a, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, + 0x72, 0x74, 0x1a, 0x80, 0x01, 0x0a, 0x06, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x3b, 0x0a, + 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, - 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x0b, 0x61, 0x6e, 0x6e, - 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x35, 0x0a, 0x0b, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, - 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x1a, - 0x80, 0x01, 0x0a, 0x06, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x3b, 0x0a, 0x06, 0x6c, 0x61, - 0x62, 0x65, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x70, 0x61, 0x79, - 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x61, 0x62, - 0x65, 0x6c, 0x73, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x1a, 0x9e, 0x01, 0x0a, 0x0b, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x12, 0x4f, 0x0a, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x1a, 0x4b, 0x0a, 0x03, 0x43, 0x50, 0x55, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, - 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, - 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x01, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x75, 0x73, 0x61, 0x67, 0x65, - 0x1a, 0x4e, 0x0a, 0x06, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, - 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, - 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x01, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x75, 0x73, 0x61, 0x67, 0x65, - 0x1a, 0x3a, 0x0a, 0x04, 0x50, 0x6f, 0x64, 0x73, 0x12, 0x32, 0x0a, 0x04, 0x70, 0x6f, 0x64, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, - 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x6f, 0x64, 0x42, 0x08, 0xba, 0x48, - 0x05, 0x92, 0x01, 0x02, 0x08, 0x01, 0x52, 0x04, 0x70, 0x6f, 0x64, 0x73, 0x1a, 0x3e, 0x0a, 0x05, - 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x35, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, - 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x42, 0x08, 0xba, 0x48, 0x05, - 0x92, 0x01, 0x02, 0x08, 0x01, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x1a, 0x4a, 0x0a, 0x08, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x61, 0x79, - 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x42, 0x08, 0xba, 0x48, 0x05, 0x92, 0x01, 0x02, 0x08, 0x01, 0x52, 0x08, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x1a, 0x15, 0x0a, 0x03, 0x49, 0x50, 0x73, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x22, - 0x7a, 0x0a, 0x06, 0x4d, 0x69, 0x72, 0x72, 0x6f, 0x72, 0x1a, 0x30, 0x0a, 0x06, 0x54, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x3e, 0x0a, 0x07, 0x54, - 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x72, 0x72, 0x6f, 0x72, 0x2e, 0x54, 0x61, 0x72, 0x67, - 0x65, 0x74, 0x52, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x22, 0x07, 0x0a, 0x05, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x42, 0x64, 0x0a, 0x1d, 0x6f, 0x72, 0x67, 0x2e, 0x76, 0x64, 0x61, 0x61, - 0x73, 0x2e, 0x76, 0x61, 0x6c, 0x64, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x61, - 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x0b, 0x56, 0x61, 0x6c, 0x64, 0x50, 0x61, 0x79, 0x6c, 0x6f, - 0x61, 0x64, 0x50, 0x01, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2f, 0x76, 0x61, 0x6c, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x73, - 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, - 0xa2, 0x02, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x4c, 0x61, + 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x9e, 0x01, 0x0a, 0x0b, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x4f, 0x0a, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, 0x6e, + 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x4b, 0x0a, 0x03, 0x43, 0x50, 0x55, 0x12, 0x14, 0x0a, + 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x6c, 0x69, + 0x6d, 0x69, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x75, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x75, 0x73, + 0x61, 0x67, 0x65, 0x1a, 0x4e, 0x0a, 0x06, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x6c, 0x69, + 0x6d, 0x69, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x75, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x75, 0x73, + 0x61, 0x67, 0x65, 0x1a, 0x3a, 0x0a, 0x04, 0x50, 0x6f, 0x64, 0x73, 0x12, 0x32, 0x0a, 0x04, 0x70, + 0x6f, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x6f, 0x64, 0x42, + 0x08, 0xba, 0x48, 0x05, 0x92, 0x01, 0x02, 0x08, 0x01, 0x52, 0x04, 0x70, 0x6f, 0x64, 0x73, 0x1a, + 0x3e, 0x0a, 0x05, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x35, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x42, 0x08, + 0xba, 0x48, 0x05, 0x92, 0x01, 0x02, 0x08, 0x01, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x1a, + 0x4a, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x08, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x08, 0xba, 0x48, 0x05, 0x92, 0x01, 0x02, 0x08, + 0x01, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x1a, 0x15, 0x0a, 0x03, 0x49, + 0x50, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x70, 0x22, 0x7a, 0x0a, 0x06, 0x4d, 0x69, 0x72, 0x72, 0x6f, 0x72, 0x1a, 0x30, 0x0a, 0x06, + 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, + 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x3e, + 0x0a, 0x07, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x72, 0x72, 0x6f, 0x72, 0x2e, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x22, 0x07, + 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x64, 0x0a, 0x1d, 0x6f, 0x72, 0x67, 0x2e, 0x76, + 0x64, 0x61, 0x61, 0x73, 0x2e, 0x76, 0x61, 0x6c, 0x64, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x0b, 0x56, 0x61, 0x6c, 0x64, 0x50, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x01, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2f, 0x76, 0x61, 0x6c, 0x64, 0x2f, 0x61, + 0x70, 0x69, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0xa2, 0x02, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -5537,102 +6092,110 @@ func file_v1_payload_payload_proto_rawDescGZIP() []byte { return file_v1_payload_payload_proto_rawDescData } -var file_v1_payload_payload_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_v1_payload_payload_proto_msgTypes = make([]protoimpl.MessageInfo, 88) -var file_v1_payload_payload_proto_goTypes = []interface{}{ - (Search_AggregationAlgorithm)(0), // 0: payload.v1.Search.AggregationAlgorithm - (Remove_Timestamp_Operator)(0), // 1: payload.v1.Remove.Timestamp.Operator - (*Search)(nil), // 2: payload.v1.Search - (*Filter)(nil), // 3: payload.v1.Filter - (*Insert)(nil), // 4: payload.v1.Insert - (*Update)(nil), // 5: payload.v1.Update - (*Upsert)(nil), // 6: payload.v1.Upsert - (*Remove)(nil), // 7: payload.v1.Remove - (*Flush)(nil), // 8: payload.v1.Flush - (*Object)(nil), // 9: payload.v1.Object - (*Control)(nil), // 10: payload.v1.Control - (*Discoverer)(nil), // 11: payload.v1.Discoverer - (*Info)(nil), // 12: payload.v1.Info - (*Mirror)(nil), // 13: payload.v1.Mirror - (*Empty)(nil), // 14: payload.v1.Empty - (*Search_Request)(nil), // 15: payload.v1.Search.Request - (*Search_MultiRequest)(nil), // 16: payload.v1.Search.MultiRequest - (*Search_IDRequest)(nil), // 17: payload.v1.Search.IDRequest - (*Search_MultiIDRequest)(nil), // 18: payload.v1.Search.MultiIDRequest - (*Search_ObjectRequest)(nil), // 19: payload.v1.Search.ObjectRequest - (*Search_MultiObjectRequest)(nil), // 20: payload.v1.Search.MultiObjectRequest - (*Search_Config)(nil), // 21: payload.v1.Search.Config - (*Search_Response)(nil), // 22: payload.v1.Search.Response - (*Search_Responses)(nil), // 23: payload.v1.Search.Responses - (*Search_StreamResponse)(nil), // 24: payload.v1.Search.StreamResponse - (*Filter_Target)(nil), // 25: payload.v1.Filter.Target - (*Filter_Config)(nil), // 26: payload.v1.Filter.Config - (*Insert_Request)(nil), // 27: payload.v1.Insert.Request - (*Insert_MultiRequest)(nil), // 28: payload.v1.Insert.MultiRequest - (*Insert_ObjectRequest)(nil), // 29: payload.v1.Insert.ObjectRequest - (*Insert_MultiObjectRequest)(nil), // 30: payload.v1.Insert.MultiObjectRequest - (*Insert_Config)(nil), // 31: payload.v1.Insert.Config - (*Update_Request)(nil), // 32: payload.v1.Update.Request - (*Update_MultiRequest)(nil), // 33: payload.v1.Update.MultiRequest - (*Update_ObjectRequest)(nil), // 34: payload.v1.Update.ObjectRequest - (*Update_MultiObjectRequest)(nil), // 35: payload.v1.Update.MultiObjectRequest - (*Update_Config)(nil), // 36: payload.v1.Update.Config - (*Upsert_Request)(nil), // 37: payload.v1.Upsert.Request - (*Upsert_MultiRequest)(nil), // 38: payload.v1.Upsert.MultiRequest - (*Upsert_ObjectRequest)(nil), // 39: payload.v1.Upsert.ObjectRequest - (*Upsert_MultiObjectRequest)(nil), // 40: payload.v1.Upsert.MultiObjectRequest - (*Upsert_Config)(nil), // 41: payload.v1.Upsert.Config - (*Remove_Request)(nil), // 42: payload.v1.Remove.Request - (*Remove_MultiRequest)(nil), // 43: payload.v1.Remove.MultiRequest - (*Remove_TimestampRequest)(nil), // 44: payload.v1.Remove.TimestampRequest - (*Remove_Timestamp)(nil), // 45: payload.v1.Remove.Timestamp - (*Remove_Config)(nil), // 46: payload.v1.Remove.Config - (*Flush_Request)(nil), // 47: payload.v1.Flush.Request - (*Object_VectorRequest)(nil), // 48: payload.v1.Object.VectorRequest - (*Object_Distance)(nil), // 49: payload.v1.Object.Distance - (*Object_StreamDistance)(nil), // 50: payload.v1.Object.StreamDistance - (*Object_ID)(nil), // 51: payload.v1.Object.ID - (*Object_IDs)(nil), // 52: payload.v1.Object.IDs - (*Object_Vector)(nil), // 53: payload.v1.Object.Vector - (*Object_GetTimestampRequest)(nil), // 54: payload.v1.Object.GetTimestampRequest - (*Object_Timestamp)(nil), // 55: payload.v1.Object.Timestamp - (*Object_Vectors)(nil), // 56: payload.v1.Object.Vectors - (*Object_StreamVector)(nil), // 57: payload.v1.Object.StreamVector - (*Object_ReshapeVector)(nil), // 58: payload.v1.Object.ReshapeVector - (*Object_Blob)(nil), // 59: payload.v1.Object.Blob - (*Object_StreamBlob)(nil), // 60: payload.v1.Object.StreamBlob - (*Object_Location)(nil), // 61: payload.v1.Object.Location - (*Object_StreamLocation)(nil), // 62: payload.v1.Object.StreamLocation - (*Object_Locations)(nil), // 63: payload.v1.Object.Locations - (*Object_List)(nil), // 64: payload.v1.Object.List - (*Object_List_Request)(nil), // 65: payload.v1.Object.List.Request - (*Object_List_Response)(nil), // 66: payload.v1.Object.List.Response - (*Control_CreateIndexRequest)(nil), // 67: payload.v1.Control.CreateIndexRequest - (*Discoverer_Request)(nil), // 68: payload.v1.Discoverer.Request - (*Info_Index)(nil), // 69: payload.v1.Info.Index - (*Info_Pod)(nil), // 70: payload.v1.Info.Pod - (*Info_Node)(nil), // 71: payload.v1.Info.Node - (*Info_Service)(nil), // 72: payload.v1.Info.Service - (*Info_ServicePort)(nil), // 73: payload.v1.Info.ServicePort - (*Info_Labels)(nil), // 74: payload.v1.Info.Labels - (*Info_Annotations)(nil), // 75: payload.v1.Info.Annotations - (*Info_CPU)(nil), // 76: payload.v1.Info.CPU - (*Info_Memory)(nil), // 77: payload.v1.Info.Memory - (*Info_Pods)(nil), // 78: payload.v1.Info.Pods - (*Info_Nodes)(nil), // 79: payload.v1.Info.Nodes - (*Info_Services)(nil), // 80: payload.v1.Info.Services - (*Info_IPs)(nil), // 81: payload.v1.Info.IPs - (*Info_Index_Count)(nil), // 82: payload.v1.Info.Index.Count - (*Info_Index_UUID)(nil), // 83: payload.v1.Info.Index.UUID - (*Info_Index_UUID_Committed)(nil), // 84: payload.v1.Info.Index.UUID.Committed - (*Info_Index_UUID_Uncommitted)(nil), // 85: payload.v1.Info.Index.UUID.Uncommitted - nil, // 86: payload.v1.Info.Labels.LabelsEntry - nil, // 87: payload.v1.Info.Annotations.AnnotationsEntry - (*Mirror_Target)(nil), // 88: payload.v1.Mirror.Target - (*Mirror_Targets)(nil), // 89: payload.v1.Mirror.Targets - (*wrapperspb.FloatValue)(nil), // 90: google.protobuf.FloatValue - (*status.Status)(nil), // 91: google.rpc.Status -} +var ( + file_v1_payload_payload_proto_enumTypes = make([]protoimpl.EnumInfo, 2) + file_v1_payload_payload_proto_msgTypes = make([]protoimpl.MessageInfo, 93) + file_v1_payload_payload_proto_goTypes = []any{ + (Search_AggregationAlgorithm)(0), // 0: payload.v1.Search.AggregationAlgorithm + (Remove_Timestamp_Operator)(0), // 1: payload.v1.Remove.Timestamp.Operator + (*Search)(nil), // 2: payload.v1.Search + (*Filter)(nil), // 3: payload.v1.Filter + (*Insert)(nil), // 4: payload.v1.Insert + (*Update)(nil), // 5: payload.v1.Update + (*Upsert)(nil), // 6: payload.v1.Upsert + (*Remove)(nil), // 7: payload.v1.Remove + (*Flush)(nil), // 8: payload.v1.Flush + (*Object)(nil), // 9: payload.v1.Object + (*Control)(nil), // 10: payload.v1.Control + (*Discoverer)(nil), // 11: payload.v1.Discoverer + (*Info)(nil), // 12: payload.v1.Info + (*Mirror)(nil), // 13: payload.v1.Mirror + (*Empty)(nil), // 14: payload.v1.Empty + (*Search_Request)(nil), // 15: payload.v1.Search.Request + (*Search_MultiRequest)(nil), // 16: payload.v1.Search.MultiRequest + (*Search_IDRequest)(nil), // 17: payload.v1.Search.IDRequest + (*Search_MultiIDRequest)(nil), // 18: payload.v1.Search.MultiIDRequest + (*Search_ObjectRequest)(nil), // 19: payload.v1.Search.ObjectRequest + (*Search_MultiObjectRequest)(nil), // 20: payload.v1.Search.MultiObjectRequest + (*Search_Config)(nil), // 21: payload.v1.Search.Config + (*Search_Response)(nil), // 22: payload.v1.Search.Response + (*Search_Responses)(nil), // 23: payload.v1.Search.Responses + (*Search_StreamResponse)(nil), // 24: payload.v1.Search.StreamResponse + (*Filter_Target)(nil), // 25: payload.v1.Filter.Target + (*Filter_Config)(nil), // 26: payload.v1.Filter.Config + (*Insert_Request)(nil), // 27: payload.v1.Insert.Request + (*Insert_MultiRequest)(nil), // 28: payload.v1.Insert.MultiRequest + (*Insert_ObjectRequest)(nil), // 29: payload.v1.Insert.ObjectRequest + (*Insert_MultiObjectRequest)(nil), // 30: payload.v1.Insert.MultiObjectRequest + (*Insert_Config)(nil), // 31: payload.v1.Insert.Config + (*Update_Request)(nil), // 32: payload.v1.Update.Request + (*Update_MultiRequest)(nil), // 33: payload.v1.Update.MultiRequest + (*Update_ObjectRequest)(nil), // 34: payload.v1.Update.ObjectRequest + (*Update_MultiObjectRequest)(nil), // 35: payload.v1.Update.MultiObjectRequest + (*Update_Config)(nil), // 36: payload.v1.Update.Config + (*Upsert_Request)(nil), // 37: payload.v1.Upsert.Request + (*Upsert_MultiRequest)(nil), // 38: payload.v1.Upsert.MultiRequest + (*Upsert_ObjectRequest)(nil), // 39: payload.v1.Upsert.ObjectRequest + (*Upsert_MultiObjectRequest)(nil), // 40: payload.v1.Upsert.MultiObjectRequest + (*Upsert_Config)(nil), // 41: payload.v1.Upsert.Config + (*Remove_Request)(nil), // 42: payload.v1.Remove.Request + (*Remove_MultiRequest)(nil), // 43: payload.v1.Remove.MultiRequest + (*Remove_TimestampRequest)(nil), // 44: payload.v1.Remove.TimestampRequest + (*Remove_Timestamp)(nil), // 45: payload.v1.Remove.Timestamp + (*Remove_Config)(nil), // 46: payload.v1.Remove.Config + (*Flush_Request)(nil), // 47: payload.v1.Flush.Request + (*Object_VectorRequest)(nil), // 48: payload.v1.Object.VectorRequest + (*Object_Distance)(nil), // 49: payload.v1.Object.Distance + (*Object_StreamDistance)(nil), // 50: payload.v1.Object.StreamDistance + (*Object_ID)(nil), // 51: payload.v1.Object.ID + (*Object_IDs)(nil), // 52: payload.v1.Object.IDs + (*Object_Vector)(nil), // 53: payload.v1.Object.Vector + (*Object_TimestampRequest)(nil), // 54: payload.v1.Object.TimestampRequest + (*Object_Timestamp)(nil), // 55: payload.v1.Object.Timestamp + (*Object_Vectors)(nil), // 56: payload.v1.Object.Vectors + (*Object_StreamVector)(nil), // 57: payload.v1.Object.StreamVector + (*Object_ReshapeVector)(nil), // 58: payload.v1.Object.ReshapeVector + (*Object_Blob)(nil), // 59: payload.v1.Object.Blob + (*Object_StreamBlob)(nil), // 60: payload.v1.Object.StreamBlob + (*Object_Location)(nil), // 61: payload.v1.Object.Location + (*Object_StreamLocation)(nil), // 62: payload.v1.Object.StreamLocation + (*Object_Locations)(nil), // 63: payload.v1.Object.Locations + (*Object_List)(nil), // 64: payload.v1.Object.List + (*Object_List_Request)(nil), // 65: payload.v1.Object.List.Request + (*Object_List_Response)(nil), // 66: payload.v1.Object.List.Response + (*Control_CreateIndexRequest)(nil), // 67: payload.v1.Control.CreateIndexRequest + (*Discoverer_Request)(nil), // 68: payload.v1.Discoverer.Request + (*Info_Index)(nil), // 69: payload.v1.Info.Index + (*Info_Pod)(nil), // 70: payload.v1.Info.Pod + (*Info_Node)(nil), // 71: payload.v1.Info.Node + (*Info_Service)(nil), // 72: payload.v1.Info.Service + (*Info_ServicePort)(nil), // 73: payload.v1.Info.ServicePort + (*Info_Labels)(nil), // 74: payload.v1.Info.Labels + (*Info_Annotations)(nil), // 75: payload.v1.Info.Annotations + (*Info_CPU)(nil), // 76: payload.v1.Info.CPU + (*Info_Memory)(nil), // 77: payload.v1.Info.Memory + (*Info_Pods)(nil), // 78: payload.v1.Info.Pods + (*Info_Nodes)(nil), // 79: payload.v1.Info.Nodes + (*Info_Services)(nil), // 80: payload.v1.Info.Services + (*Info_IPs)(nil), // 81: payload.v1.Info.IPs + (*Info_Index_Count)(nil), // 82: payload.v1.Info.Index.Count + (*Info_Index_Detail)(nil), // 83: payload.v1.Info.Index.Detail + (*Info_Index_UUID)(nil), // 84: payload.v1.Info.Index.UUID + (*Info_Index_Statistics)(nil), // 85: payload.v1.Info.Index.Statistics + (*Info_Index_StatisticsDetail)(nil), // 86: payload.v1.Info.Index.StatisticsDetail + nil, // 87: payload.v1.Info.Index.Detail.CountsEntry + (*Info_Index_UUID_Committed)(nil), // 88: payload.v1.Info.Index.UUID.Committed + (*Info_Index_UUID_Uncommitted)(nil), // 89: payload.v1.Info.Index.UUID.Uncommitted + nil, // 90: payload.v1.Info.Index.StatisticsDetail.DetailsEntry + nil, // 91: payload.v1.Info.Labels.LabelsEntry + nil, // 92: payload.v1.Info.Annotations.AnnotationsEntry + (*Mirror_Target)(nil), // 93: payload.v1.Mirror.Target + (*Mirror_Targets)(nil), // 94: payload.v1.Mirror.Targets + (*wrapperspb.FloatValue)(nil), // 95: google.protobuf.FloatValue + (*status.Status)(nil), // 96: google.rpc.Status + } +) + var file_v1_payload_payload_proto_depIdxs = []int32{ 21, // 0: payload.v1.Search.Request.config:type_name -> payload.v1.Search.Config 15, // 1: payload.v1.Search.MultiRequest.requests:type_name -> payload.v1.Search.Request @@ -5644,11 +6207,11 @@ var file_v1_payload_payload_proto_depIdxs = []int32{ 26, // 7: payload.v1.Search.Config.ingress_filters:type_name -> payload.v1.Filter.Config 26, // 8: payload.v1.Search.Config.egress_filters:type_name -> payload.v1.Filter.Config 0, // 9: payload.v1.Search.Config.aggregation_algorithm:type_name -> payload.v1.Search.AggregationAlgorithm - 90, // 10: payload.v1.Search.Config.ratio:type_name -> google.protobuf.FloatValue + 95, // 10: payload.v1.Search.Config.ratio:type_name -> google.protobuf.FloatValue 49, // 11: payload.v1.Search.Response.results:type_name -> payload.v1.Object.Distance 22, // 12: payload.v1.Search.Responses.responses:type_name -> payload.v1.Search.Response 22, // 13: payload.v1.Search.StreamResponse.response:type_name -> payload.v1.Search.Response - 91, // 14: payload.v1.Search.StreamResponse.status:type_name -> google.rpc.Status + 96, // 14: payload.v1.Search.StreamResponse.status:type_name -> google.rpc.Status 25, // 15: payload.v1.Filter.Config.targets:type_name -> payload.v1.Filter.Target 53, // 16: payload.v1.Insert.Request.vector:type_name -> payload.v1.Object.Vector 31, // 17: payload.v1.Insert.Request.config:type_name -> payload.v1.Insert.Config @@ -5682,18 +6245,18 @@ var file_v1_payload_payload_proto_depIdxs = []int32{ 51, // 45: payload.v1.Object.VectorRequest.id:type_name -> payload.v1.Object.ID 26, // 46: payload.v1.Object.VectorRequest.filters:type_name -> payload.v1.Filter.Config 49, // 47: payload.v1.Object.StreamDistance.distance:type_name -> payload.v1.Object.Distance - 91, // 48: payload.v1.Object.StreamDistance.status:type_name -> google.rpc.Status - 51, // 49: payload.v1.Object.GetTimestampRequest.id:type_name -> payload.v1.Object.ID + 96, // 48: payload.v1.Object.StreamDistance.status:type_name -> google.rpc.Status + 51, // 49: payload.v1.Object.TimestampRequest.id:type_name -> payload.v1.Object.ID 53, // 50: payload.v1.Object.Vectors.vectors:type_name -> payload.v1.Object.Vector 53, // 51: payload.v1.Object.StreamVector.vector:type_name -> payload.v1.Object.Vector - 91, // 52: payload.v1.Object.StreamVector.status:type_name -> google.rpc.Status + 96, // 52: payload.v1.Object.StreamVector.status:type_name -> google.rpc.Status 59, // 53: payload.v1.Object.StreamBlob.blob:type_name -> payload.v1.Object.Blob - 91, // 54: payload.v1.Object.StreamBlob.status:type_name -> google.rpc.Status + 96, // 54: payload.v1.Object.StreamBlob.status:type_name -> google.rpc.Status 61, // 55: payload.v1.Object.StreamLocation.location:type_name -> payload.v1.Object.Location - 91, // 56: payload.v1.Object.StreamLocation.status:type_name -> google.rpc.Status + 96, // 56: payload.v1.Object.StreamLocation.status:type_name -> google.rpc.Status 61, // 57: payload.v1.Object.Locations.locations:type_name -> payload.v1.Object.Location 53, // 58: payload.v1.Object.List.Response.vector:type_name -> payload.v1.Object.Vector - 91, // 59: payload.v1.Object.List.Response.status:type_name -> google.rpc.Status + 96, // 59: payload.v1.Object.List.Response.status:type_name -> google.rpc.Status 76, // 60: payload.v1.Info.Pod.cpu:type_name -> payload.v1.Info.CPU 77, // 61: payload.v1.Info.Pod.memory:type_name -> payload.v1.Info.Memory 71, // 62: payload.v1.Info.Pod.node:type_name -> payload.v1.Info.Node @@ -5703,17 +6266,21 @@ var file_v1_payload_payload_proto_depIdxs = []int32{ 73, // 66: payload.v1.Info.Service.ports:type_name -> payload.v1.Info.ServicePort 74, // 67: payload.v1.Info.Service.labels:type_name -> payload.v1.Info.Labels 75, // 68: payload.v1.Info.Service.annotations:type_name -> payload.v1.Info.Annotations - 86, // 69: payload.v1.Info.Labels.labels:type_name -> payload.v1.Info.Labels.LabelsEntry - 87, // 70: payload.v1.Info.Annotations.annotations:type_name -> payload.v1.Info.Annotations.AnnotationsEntry + 91, // 69: payload.v1.Info.Labels.labels:type_name -> payload.v1.Info.Labels.LabelsEntry + 92, // 70: payload.v1.Info.Annotations.annotations:type_name -> payload.v1.Info.Annotations.AnnotationsEntry 70, // 71: payload.v1.Info.Pods.pods:type_name -> payload.v1.Info.Pod 71, // 72: payload.v1.Info.Nodes.nodes:type_name -> payload.v1.Info.Node 72, // 73: payload.v1.Info.Services.services:type_name -> payload.v1.Info.Service - 88, // 74: payload.v1.Mirror.Targets.targets:type_name -> payload.v1.Mirror.Target - 75, // [75:75] is the sub-list for method output_type - 75, // [75:75] is the sub-list for method input_type - 75, // [75:75] is the sub-list for extension type_name - 75, // [75:75] is the sub-list for extension extendee - 0, // [0:75] is the sub-list for field type_name + 87, // 74: payload.v1.Info.Index.Detail.counts:type_name -> payload.v1.Info.Index.Detail.CountsEntry + 90, // 75: payload.v1.Info.Index.StatisticsDetail.details:type_name -> payload.v1.Info.Index.StatisticsDetail.DetailsEntry + 82, // 76: payload.v1.Info.Index.Detail.CountsEntry.value:type_name -> payload.v1.Info.Index.Count + 85, // 77: payload.v1.Info.Index.StatisticsDetail.DetailsEntry.value:type_name -> payload.v1.Info.Index.Statistics + 93, // 78: payload.v1.Mirror.Targets.targets:type_name -> payload.v1.Mirror.Target + 79, // [79:79] is the sub-list for method output_type + 79, // [79:79] is the sub-list for method input_type + 79, // [79:79] is the sub-list for extension type_name + 79, // [79:79] is the sub-list for extension extendee + 0, // [0:79] is the sub-list for field type_name } func init() { file_v1_payload_payload_proto_init() } @@ -5722,7 +6289,7 @@ func file_v1_payload_payload_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_v1_payload_payload_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Search); i { case 0: return &v.state @@ -5734,7 +6301,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Filter); i { case 0: return &v.state @@ -5746,7 +6313,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Insert); i { case 0: return &v.state @@ -5758,7 +6325,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Update); i { case 0: return &v.state @@ -5770,7 +6337,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Upsert); i { case 0: return &v.state @@ -5782,7 +6349,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*Remove); i { case 0: return &v.state @@ -5794,7 +6361,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*Flush); i { case 0: return &v.state @@ -5806,7 +6373,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*Object); i { case 0: return &v.state @@ -5818,7 +6385,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*Control); i { case 0: return &v.state @@ -5830,7 +6397,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*Discoverer); i { case 0: return &v.state @@ -5842,7 +6409,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*Info); i { case 0: return &v.state @@ -5854,7 +6421,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*Mirror); i { case 0: return &v.state @@ -5866,7 +6433,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*Empty); i { case 0: return &v.state @@ -5878,7 +6445,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*Search_Request); i { case 0: return &v.state @@ -5890,7 +6457,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*Search_MultiRequest); i { case 0: return &v.state @@ -5902,7 +6469,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[15].Exporter = func(v any, i int) any { switch v := v.(*Search_IDRequest); i { case 0: return &v.state @@ -5914,7 +6481,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[16].Exporter = func(v any, i int) any { switch v := v.(*Search_MultiIDRequest); i { case 0: return &v.state @@ -5926,7 +6493,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[17].Exporter = func(v any, i int) any { switch v := v.(*Search_ObjectRequest); i { case 0: return &v.state @@ -5938,7 +6505,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[18].Exporter = func(v any, i int) any { switch v := v.(*Search_MultiObjectRequest); i { case 0: return &v.state @@ -5950,7 +6517,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[19].Exporter = func(v any, i int) any { switch v := v.(*Search_Config); i { case 0: return &v.state @@ -5962,7 +6529,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[20].Exporter = func(v any, i int) any { switch v := v.(*Search_Response); i { case 0: return &v.state @@ -5974,7 +6541,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[21].Exporter = func(v any, i int) any { switch v := v.(*Search_Responses); i { case 0: return &v.state @@ -5986,7 +6553,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[22].Exporter = func(v any, i int) any { switch v := v.(*Search_StreamResponse); i { case 0: return &v.state @@ -5998,7 +6565,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[23].Exporter = func(v any, i int) any { switch v := v.(*Filter_Target); i { case 0: return &v.state @@ -6010,7 +6577,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[24].Exporter = func(v any, i int) any { switch v := v.(*Filter_Config); i { case 0: return &v.state @@ -6022,7 +6589,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[25].Exporter = func(v any, i int) any { switch v := v.(*Insert_Request); i { case 0: return &v.state @@ -6034,7 +6601,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[26].Exporter = func(v any, i int) any { switch v := v.(*Insert_MultiRequest); i { case 0: return &v.state @@ -6046,7 +6613,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[27].Exporter = func(v any, i int) any { switch v := v.(*Insert_ObjectRequest); i { case 0: return &v.state @@ -6058,7 +6625,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[28].Exporter = func(v any, i int) any { switch v := v.(*Insert_MultiObjectRequest); i { case 0: return &v.state @@ -6070,7 +6637,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[29].Exporter = func(v any, i int) any { switch v := v.(*Insert_Config); i { case 0: return &v.state @@ -6082,7 +6649,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[30].Exporter = func(v any, i int) any { switch v := v.(*Update_Request); i { case 0: return &v.state @@ -6094,7 +6661,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[31].Exporter = func(v any, i int) any { switch v := v.(*Update_MultiRequest); i { case 0: return &v.state @@ -6106,7 +6673,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[32].Exporter = func(v any, i int) any { switch v := v.(*Update_ObjectRequest); i { case 0: return &v.state @@ -6118,7 +6685,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[33].Exporter = func(v any, i int) any { switch v := v.(*Update_MultiObjectRequest); i { case 0: return &v.state @@ -6130,7 +6697,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[34].Exporter = func(v any, i int) any { switch v := v.(*Update_Config); i { case 0: return &v.state @@ -6142,7 +6709,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[35].Exporter = func(v any, i int) any { switch v := v.(*Upsert_Request); i { case 0: return &v.state @@ -6154,7 +6721,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[36].Exporter = func(v any, i int) any { switch v := v.(*Upsert_MultiRequest); i { case 0: return &v.state @@ -6166,7 +6733,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[37].Exporter = func(v any, i int) any { switch v := v.(*Upsert_ObjectRequest); i { case 0: return &v.state @@ -6178,7 +6745,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[38].Exporter = func(v any, i int) any { switch v := v.(*Upsert_MultiObjectRequest); i { case 0: return &v.state @@ -6190,7 +6757,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[39].Exporter = func(v any, i int) any { switch v := v.(*Upsert_Config); i { case 0: return &v.state @@ -6202,7 +6769,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[40].Exporter = func(v any, i int) any { switch v := v.(*Remove_Request); i { case 0: return &v.state @@ -6214,7 +6781,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[41].Exporter = func(v any, i int) any { switch v := v.(*Remove_MultiRequest); i { case 0: return &v.state @@ -6226,7 +6793,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[42].Exporter = func(v any, i int) any { switch v := v.(*Remove_TimestampRequest); i { case 0: return &v.state @@ -6238,7 +6805,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[43].Exporter = func(v any, i int) any { switch v := v.(*Remove_Timestamp); i { case 0: return &v.state @@ -6250,7 +6817,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[44].Exporter = func(v any, i int) any { switch v := v.(*Remove_Config); i { case 0: return &v.state @@ -6262,7 +6829,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[45].Exporter = func(v any, i int) any { switch v := v.(*Flush_Request); i { case 0: return &v.state @@ -6274,7 +6841,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[46].Exporter = func(v any, i int) any { switch v := v.(*Object_VectorRequest); i { case 0: return &v.state @@ -6286,7 +6853,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[47].Exporter = func(v any, i int) any { switch v := v.(*Object_Distance); i { case 0: return &v.state @@ -6298,7 +6865,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[48].Exporter = func(v any, i int) any { switch v := v.(*Object_StreamDistance); i { case 0: return &v.state @@ -6310,7 +6877,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[49].Exporter = func(v any, i int) any { switch v := v.(*Object_ID); i { case 0: return &v.state @@ -6322,7 +6889,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[50].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[50].Exporter = func(v any, i int) any { switch v := v.(*Object_IDs); i { case 0: return &v.state @@ -6334,7 +6901,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[51].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[51].Exporter = func(v any, i int) any { switch v := v.(*Object_Vector); i { case 0: return &v.state @@ -6346,8 +6913,8 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[52].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Object_GetTimestampRequest); i { + file_v1_payload_payload_proto_msgTypes[52].Exporter = func(v any, i int) any { + switch v := v.(*Object_TimestampRequest); i { case 0: return &v.state case 1: @@ -6358,7 +6925,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[53].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[53].Exporter = func(v any, i int) any { switch v := v.(*Object_Timestamp); i { case 0: return &v.state @@ -6370,7 +6937,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[54].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[54].Exporter = func(v any, i int) any { switch v := v.(*Object_Vectors); i { case 0: return &v.state @@ -6382,7 +6949,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[55].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[55].Exporter = func(v any, i int) any { switch v := v.(*Object_StreamVector); i { case 0: return &v.state @@ -6394,7 +6961,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[56].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[56].Exporter = func(v any, i int) any { switch v := v.(*Object_ReshapeVector); i { case 0: return &v.state @@ -6406,7 +6973,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[57].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[57].Exporter = func(v any, i int) any { switch v := v.(*Object_Blob); i { case 0: return &v.state @@ -6418,7 +6985,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[58].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[58].Exporter = func(v any, i int) any { switch v := v.(*Object_StreamBlob); i { case 0: return &v.state @@ -6430,7 +6997,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[59].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[59].Exporter = func(v any, i int) any { switch v := v.(*Object_Location); i { case 0: return &v.state @@ -6442,7 +7009,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[60].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[60].Exporter = func(v any, i int) any { switch v := v.(*Object_StreamLocation); i { case 0: return &v.state @@ -6454,7 +7021,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[61].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[61].Exporter = func(v any, i int) any { switch v := v.(*Object_Locations); i { case 0: return &v.state @@ -6466,7 +7033,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[62].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[62].Exporter = func(v any, i int) any { switch v := v.(*Object_List); i { case 0: return &v.state @@ -6478,7 +7045,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[63].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[63].Exporter = func(v any, i int) any { switch v := v.(*Object_List_Request); i { case 0: return &v.state @@ -6490,7 +7057,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[64].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[64].Exporter = func(v any, i int) any { switch v := v.(*Object_List_Response); i { case 0: return &v.state @@ -6502,7 +7069,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[65].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[65].Exporter = func(v any, i int) any { switch v := v.(*Control_CreateIndexRequest); i { case 0: return &v.state @@ -6514,7 +7081,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[66].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[66].Exporter = func(v any, i int) any { switch v := v.(*Discoverer_Request); i { case 0: return &v.state @@ -6526,7 +7093,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[67].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[67].Exporter = func(v any, i int) any { switch v := v.(*Info_Index); i { case 0: return &v.state @@ -6538,7 +7105,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[68].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[68].Exporter = func(v any, i int) any { switch v := v.(*Info_Pod); i { case 0: return &v.state @@ -6550,7 +7117,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[69].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[69].Exporter = func(v any, i int) any { switch v := v.(*Info_Node); i { case 0: return &v.state @@ -6562,7 +7129,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[70].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[70].Exporter = func(v any, i int) any { switch v := v.(*Info_Service); i { case 0: return &v.state @@ -6574,7 +7141,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[71].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[71].Exporter = func(v any, i int) any { switch v := v.(*Info_ServicePort); i { case 0: return &v.state @@ -6586,7 +7153,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[72].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[72].Exporter = func(v any, i int) any { switch v := v.(*Info_Labels); i { case 0: return &v.state @@ -6598,7 +7165,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[73].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[73].Exporter = func(v any, i int) any { switch v := v.(*Info_Annotations); i { case 0: return &v.state @@ -6610,7 +7177,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[74].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[74].Exporter = func(v any, i int) any { switch v := v.(*Info_CPU); i { case 0: return &v.state @@ -6622,7 +7189,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[75].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[75].Exporter = func(v any, i int) any { switch v := v.(*Info_Memory); i { case 0: return &v.state @@ -6634,7 +7201,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[76].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[76].Exporter = func(v any, i int) any { switch v := v.(*Info_Pods); i { case 0: return &v.state @@ -6646,7 +7213,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[77].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[77].Exporter = func(v any, i int) any { switch v := v.(*Info_Nodes); i { case 0: return &v.state @@ -6658,7 +7225,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[78].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[78].Exporter = func(v any, i int) any { switch v := v.(*Info_Services); i { case 0: return &v.state @@ -6670,7 +7237,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[79].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[79].Exporter = func(v any, i int) any { switch v := v.(*Info_IPs); i { case 0: return &v.state @@ -6682,7 +7249,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[80].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[80].Exporter = func(v any, i int) any { switch v := v.(*Info_Index_Count); i { case 0: return &v.state @@ -6694,7 +7261,19 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[81].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[81].Exporter = func(v any, i int) any { + switch v := v.(*Info_Index_Detail); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_payload_payload_proto_msgTypes[82].Exporter = func(v any, i int) any { switch v := v.(*Info_Index_UUID); i { case 0: return &v.state @@ -6706,7 +7285,31 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[82].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[83].Exporter = func(v any, i int) any { + switch v := v.(*Info_Index_Statistics); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_payload_payload_proto_msgTypes[84].Exporter = func(v any, i int) any { + switch v := v.(*Info_Index_StatisticsDetail); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_payload_payload_proto_msgTypes[86].Exporter = func(v any, i int) any { switch v := v.(*Info_Index_UUID_Committed); i { case 0: return &v.state @@ -6718,7 +7321,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[83].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[87].Exporter = func(v any, i int) any { switch v := v.(*Info_Index_UUID_Uncommitted); i { case 0: return &v.state @@ -6730,7 +7333,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[86].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[91].Exporter = func(v any, i int) any { switch v := v.(*Mirror_Target); i { case 0: return &v.state @@ -6742,7 +7345,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[87].Exporter = func(v interface{}, i int) interface{} { + file_v1_payload_payload_proto_msgTypes[92].Exporter = func(v any, i int) any { switch v := v.(*Mirror_Targets); i { case 0: return &v.state @@ -6755,27 +7358,27 @@ func file_v1_payload_payload_proto_init() { } } } - file_v1_payload_payload_proto_msgTypes[22].OneofWrappers = []interface{}{ + file_v1_payload_payload_proto_msgTypes[22].OneofWrappers = []any{ (*Search_StreamResponse_Response)(nil), (*Search_StreamResponse_Status)(nil), } - file_v1_payload_payload_proto_msgTypes[48].OneofWrappers = []interface{}{ + file_v1_payload_payload_proto_msgTypes[48].OneofWrappers = []any{ (*Object_StreamDistance_Distance)(nil), (*Object_StreamDistance_Status)(nil), } - file_v1_payload_payload_proto_msgTypes[55].OneofWrappers = []interface{}{ + file_v1_payload_payload_proto_msgTypes[55].OneofWrappers = []any{ (*Object_StreamVector_Vector)(nil), (*Object_StreamVector_Status)(nil), } - file_v1_payload_payload_proto_msgTypes[58].OneofWrappers = []interface{}{ + file_v1_payload_payload_proto_msgTypes[58].OneofWrappers = []any{ (*Object_StreamBlob_Blob)(nil), (*Object_StreamBlob_Status)(nil), } - file_v1_payload_payload_proto_msgTypes[60].OneofWrappers = []interface{}{ + file_v1_payload_payload_proto_msgTypes[60].OneofWrappers = []any{ (*Object_StreamLocation_Location)(nil), (*Object_StreamLocation_Status)(nil), } - file_v1_payload_payload_proto_msgTypes[64].OneofWrappers = []interface{}{ + file_v1_payload_payload_proto_msgTypes[64].OneofWrappers = []any{ (*Object_List_Response_Vector)(nil), (*Object_List_Response_Status)(nil), } @@ -6785,7 +7388,7 @@ func file_v1_payload_payload_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_v1_payload_payload_proto_rawDesc, NumEnums: 2, - NumMessages: 88, + NumMessages: 93, NumExtensions: 0, NumServices: 0, }, diff --git a/apis/grpc/v1/payload/payload.pb.json.go b/apis/grpc/v1/payload/payload.pb.json.go index cf5d15d4d5..159ebc555c 100644 --- a/apis/grpc/v1/payload/payload.pb.json.go +++ b/apis/grpc/v1/payload/payload.pb.json.go @@ -19,9 +19,7 @@ package payload -import ( - "google.golang.org/protobuf/encoding/protojson" -) +import "google.golang.org/protobuf/encoding/protojson" // MarshalJSON implements json.Marshaler func (msg *Search) MarshalJSON() ([]byte, error) { @@ -494,12 +492,12 @@ func (msg *Object_Vector) UnmarshalJSON(b []byte) error { } // MarshalJSON implements json.Marshaler -func (msg *Object_GetTimestampRequest) MarshalJSON() ([]byte, error) { +func (msg *Object_TimestampRequest) MarshalJSON() ([]byte, error) { return protojson.MarshalOptions{}.Marshal(msg) } // UnmarshalJSON implements json.Unmarshaler -func (msg *Object_GetTimestampRequest) UnmarshalJSON(b []byte) error { +func (msg *Object_TimestampRequest) UnmarshalJSON(b []byte) error { return protojson.UnmarshalOptions{}.Unmarshal(b, msg) } @@ -693,6 +691,16 @@ func (msg *Info_Index_Count) UnmarshalJSON(b []byte) error { return protojson.UnmarshalOptions{}.Unmarshal(b, msg) } +// MarshalJSON implements json.Marshaler +func (msg *Info_Index_Detail) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *Info_Index_Detail) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} + // MarshalJSON implements json.Marshaler func (msg *Info_Index_UUID) MarshalJSON() ([]byte, error) { return protojson.MarshalOptions{}.Marshal(msg) @@ -723,6 +731,26 @@ func (msg *Info_Index_UUID_Uncommitted) UnmarshalJSON(b []byte) error { return protojson.UnmarshalOptions{}.Unmarshal(b, msg) } +// MarshalJSON implements json.Marshaler +func (msg *Info_Index_Statistics) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *Info_Index_Statistics) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} + +// MarshalJSON implements json.Marshaler +func (msg *Info_Index_StatisticsDetail) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *Info_Index_StatisticsDetail) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} + // MarshalJSON implements json.Marshaler func (msg *Info_Pod) MarshalJSON() ([]byte, error) { return protojson.MarshalOptions{}.Marshal(msg) diff --git a/apis/grpc/v1/payload/payload_vtproto.pb.go b/apis/grpc/v1/payload/payload_vtproto.pb.go index 53d8e69ecc..b2a6c8d654 100644 --- a/apis/grpc/v1/payload/payload_vtproto.pb.go +++ b/apis/grpc/v1/payload/payload_vtproto.pb.go @@ -278,7 +278,7 @@ func (m *Search_StreamResponse_Status) CloneVT() isSearch_StreamResponse_Payload } r := new(Search_StreamResponse_Status) if rhs := m.Status; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *status.Status }); ok { + if vtpb, ok := any(rhs).(interface{ CloneVT() *status.Status }); ok { r.Status = vtpb.CloneVT() } else { r.Status = proto.Clone(rhs).(*status.Status) @@ -936,7 +936,7 @@ func (m *Object_StreamDistance_Status) CloneVT() isObject_StreamDistance_Payload } r := new(Object_StreamDistance_Status) if rhs := m.Status; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *status.Status }); ok { + if vtpb, ok := any(rhs).(interface{ CloneVT() *status.Status }); ok { r.Status = vtpb.CloneVT() } else { r.Status = proto.Clone(rhs).(*status.Status) @@ -1006,11 +1006,11 @@ func (m *Object_Vector) CloneMessageVT() proto.Message { return m.CloneVT() } -func (m *Object_GetTimestampRequest) CloneVT() *Object_GetTimestampRequest { +func (m *Object_TimestampRequest) CloneVT() *Object_TimestampRequest { if m == nil { - return (*Object_GetTimestampRequest)(nil) + return (*Object_TimestampRequest)(nil) } - r := new(Object_GetTimestampRequest) + r := new(Object_TimestampRequest) r.Id = m.Id.CloneVT() if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) @@ -1019,7 +1019,7 @@ func (m *Object_GetTimestampRequest) CloneVT() *Object_GetTimestampRequest { return r } -func (m *Object_GetTimestampRequest) CloneMessageVT() proto.Message { +func (m *Object_TimestampRequest) CloneMessageVT() proto.Message { return m.CloneVT() } @@ -1100,7 +1100,7 @@ func (m *Object_StreamVector_Status) CloneVT() isObject_StreamVector_Payload { } r := new(Object_StreamVector_Status) if rhs := m.Status; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *status.Status }); ok { + if vtpb, ok := any(rhs).(interface{ CloneVT() *status.Status }); ok { r.Status = vtpb.CloneVT() } else { r.Status = proto.Clone(rhs).(*status.Status) @@ -1193,7 +1193,7 @@ func (m *Object_StreamBlob_Status) CloneVT() isObject_StreamBlob_Payload { } r := new(Object_StreamBlob_Status) if rhs := m.Status; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *status.Status }); ok { + if vtpb, ok := any(rhs).(interface{ CloneVT() *status.Status }); ok { r.Status = vtpb.CloneVT() } else { r.Status = proto.Clone(rhs).(*status.Status) @@ -1261,7 +1261,7 @@ func (m *Object_StreamLocation_Status) CloneVT() isObject_StreamLocation_Payload } r := new(Object_StreamLocation_Status) if rhs := m.Status; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *status.Status }); ok { + if vtpb, ok := any(rhs).(interface{ CloneVT() *status.Status }); ok { r.Status = vtpb.CloneVT() } else { r.Status = proto.Clone(rhs).(*status.Status) @@ -1345,7 +1345,7 @@ func (m *Object_List_Response_Status) CloneVT() isObject_List_Response_Payload { } r := new(Object_List_Response_Status) if rhs := m.Status; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *status.Status }); ok { + if vtpb, ok := any(rhs).(interface{ CloneVT() *status.Status }); ok { r.Status = vtpb.CloneVT() } else { r.Status = proto.Clone(rhs).(*status.Status) @@ -1474,6 +1474,31 @@ func (m *Info_Index_Count) CloneMessageVT() proto.Message { return m.CloneVT() } +func (m *Info_Index_Detail) CloneVT() *Info_Index_Detail { + if m == nil { + return (*Info_Index_Detail)(nil) + } + r := new(Info_Index_Detail) + r.Replica = m.Replica + r.LiveAgents = m.LiveAgents + if rhs := m.Counts; rhs != nil { + tmpContainer := make(map[string]*Info_Index_Count, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Counts = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Info_Index_Detail) CloneMessageVT() proto.Message { + return m.CloneVT() +} + func (m *Info_Index_UUID_Committed) CloneVT() *Info_Index_UUID_Committed { if m == nil { return (*Info_Index_UUID_Committed)(nil) @@ -1524,6 +1549,90 @@ func (m *Info_Index_UUID) CloneMessageVT() proto.Message { return m.CloneVT() } +func (m *Info_Index_Statistics) CloneVT() *Info_Index_Statistics { + if m == nil { + return (*Info_Index_Statistics)(nil) + } + r := new(Info_Index_Statistics) + r.Valid = m.Valid + r.MedianIndegree = m.MedianIndegree + r.MedianOutdegree = m.MedianOutdegree + r.MaxNumberOfIndegree = m.MaxNumberOfIndegree + r.MaxNumberOfOutdegree = m.MaxNumberOfOutdegree + r.MinNumberOfIndegree = m.MinNumberOfIndegree + r.MinNumberOfOutdegree = m.MinNumberOfOutdegree + r.ModeIndegree = m.ModeIndegree + r.ModeOutdegree = m.ModeOutdegree + r.NodesSkippedFor10Edges = m.NodesSkippedFor10Edges + r.NodesSkippedForIndegreeDistance = m.NodesSkippedForIndegreeDistance + r.NumberOfEdges = m.NumberOfEdges + r.NumberOfIndexedObjects = m.NumberOfIndexedObjects + r.NumberOfNodes = m.NumberOfNodes + r.NumberOfNodesWithoutEdges = m.NumberOfNodesWithoutEdges + r.NumberOfNodesWithoutIndegree = m.NumberOfNodesWithoutIndegree + r.NumberOfObjects = m.NumberOfObjects + r.NumberOfRemovedObjects = m.NumberOfRemovedObjects + r.SizeOfObjectRepository = m.SizeOfObjectRepository + r.SizeOfRefinementObjectRepository = m.SizeOfRefinementObjectRepository + r.VarianceOfIndegree = m.VarianceOfIndegree + r.VarianceOfOutdegree = m.VarianceOfOutdegree + r.MeanEdgeLength = m.MeanEdgeLength + r.MeanEdgeLengthFor10Edges = m.MeanEdgeLengthFor10Edges + r.MeanIndegreeDistanceFor10Edges = m.MeanIndegreeDistanceFor10Edges + r.MeanNumberOfEdgesPerNode = m.MeanNumberOfEdgesPerNode + r.C1Indegree = m.C1Indegree + r.C5Indegree = m.C5Indegree + r.C95Outdegree = m.C95Outdegree + r.C99Outdegree = m.C99Outdegree + if rhs := m.IndegreeCount; rhs != nil { + tmpContainer := make([]int64, len(rhs)) + copy(tmpContainer, rhs) + r.IndegreeCount = tmpContainer + } + if rhs := m.OutdegreeHistogram; rhs != nil { + tmpContainer := make([]uint64, len(rhs)) + copy(tmpContainer, rhs) + r.OutdegreeHistogram = tmpContainer + } + if rhs := m.IndegreeHistogram; rhs != nil { + tmpContainer := make([]uint64, len(rhs)) + copy(tmpContainer, rhs) + r.IndegreeHistogram = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Info_Index_Statistics) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Info_Index_StatisticsDetail) CloneVT() *Info_Index_StatisticsDetail { + if m == nil { + return (*Info_Index_StatisticsDetail)(nil) + } + r := new(Info_Index_StatisticsDetail) + if rhs := m.Details; rhs != nil { + tmpContainer := make(map[string]*Info_Index_Statistics, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Details = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Info_Index_StatisticsDetail) CloneMessageVT() proto.Message { + return m.CloneVT() +} + func (m *Info_Index) CloneVT() *Info_Index { if m == nil { return (*Info_Index)(nil) @@ -1926,6 +2035,7 @@ func (this *Search_Request) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Search_MultiRequest) EqualVT(that *Search_MultiRequest) bool { if this == that { return true @@ -1959,6 +2069,7 @@ func (this *Search_MultiRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Search_IDRequest) EqualVT(that *Search_IDRequest) bool { if this == that { return true @@ -1981,6 +2092,7 @@ func (this *Search_IDRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Search_MultiIDRequest) EqualVT(that *Search_MultiIDRequest) bool { if this == that { return true @@ -2014,6 +2126,7 @@ func (this *Search_MultiIDRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Search_ObjectRequest) EqualVT(that *Search_ObjectRequest) bool { if this == that { return true @@ -2039,6 +2152,7 @@ func (this *Search_ObjectRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Search_MultiObjectRequest) EqualVT(that *Search_MultiObjectRequest) bool { if this == that { return true @@ -2072,6 +2186,7 @@ func (this *Search_MultiObjectRequest) EqualMessageVT(thatMsg proto.Message) boo } return this.EqualVT(that) } + func (this *Search_Config) EqualVT(that *Search_Config) bool { if this == that { return true @@ -2118,6 +2233,7 @@ func (this *Search_Config) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Search_Response) EqualVT(that *Search_Response) bool { if this == that { return true @@ -2154,6 +2270,7 @@ func (this *Search_Response) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Search_Responses) EqualVT(that *Search_Responses) bool { if this == that { return true @@ -2187,6 +2304,7 @@ func (this *Search_Responses) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Search_StreamResponse) EqualVT(that *Search_StreamResponse) bool { if this == that { return true @@ -2215,7 +2333,10 @@ func (this *Search_StreamResponse) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } -func (this *Search_StreamResponse_Response) EqualVT(thatIface isSearch_StreamResponse_Payload) bool { + +func (this *Search_StreamResponse_Response) EqualVT( + thatIface isSearch_StreamResponse_Payload, +) bool { that, ok := thatIface.(*Search_StreamResponse_Response) if !ok { return false @@ -2258,7 +2379,7 @@ func (this *Search_StreamResponse_Status) EqualVT(thatIface isSearch_StreamRespo if q == nil { q = &status.Status{} } - if equal, ok := interface{}(p).(interface{ EqualVT(*status.Status) bool }); ok { + if equal, ok := any(p).(interface{ EqualVT(*status.Status) bool }); ok { if !equal.EqualVT(q) { return false } @@ -2285,6 +2406,7 @@ func (this *Search) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Filter_Target) EqualVT(that *Filter_Target) bool { if this == that { return true @@ -2307,6 +2429,7 @@ func (this *Filter_Target) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Filter_Config) EqualVT(that *Filter_Config) bool { if this == that { return true @@ -2340,6 +2463,7 @@ func (this *Filter_Config) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Filter) EqualVT(that *Filter) bool { if this == that { return true @@ -2356,6 +2480,7 @@ func (this *Filter) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Insert_Request) EqualVT(that *Insert_Request) bool { if this == that { return true @@ -2378,6 +2503,7 @@ func (this *Insert_Request) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Insert_MultiRequest) EqualVT(that *Insert_MultiRequest) bool { if this == that { return true @@ -2411,6 +2537,7 @@ func (this *Insert_MultiRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Insert_ObjectRequest) EqualVT(that *Insert_ObjectRequest) bool { if this == that { return true @@ -2436,6 +2563,7 @@ func (this *Insert_ObjectRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Insert_MultiObjectRequest) EqualVT(that *Insert_MultiObjectRequest) bool { if this == that { return true @@ -2469,6 +2597,7 @@ func (this *Insert_MultiObjectRequest) EqualMessageVT(thatMsg proto.Message) boo } return this.EqualVT(that) } + func (this *Insert_Config) EqualVT(that *Insert_Config) bool { if this == that { return true @@ -2494,6 +2623,7 @@ func (this *Insert_Config) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Insert) EqualVT(that *Insert) bool { if this == that { return true @@ -2510,6 +2640,7 @@ func (this *Insert) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Update_Request) EqualVT(that *Update_Request) bool { if this == that { return true @@ -2532,6 +2663,7 @@ func (this *Update_Request) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Update_MultiRequest) EqualVT(that *Update_MultiRequest) bool { if this == that { return true @@ -2565,6 +2697,7 @@ func (this *Update_MultiRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Update_ObjectRequest) EqualVT(that *Update_ObjectRequest) bool { if this == that { return true @@ -2590,6 +2723,7 @@ func (this *Update_ObjectRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Update_MultiObjectRequest) EqualVT(that *Update_MultiObjectRequest) bool { if this == that { return true @@ -2623,6 +2757,7 @@ func (this *Update_MultiObjectRequest) EqualMessageVT(thatMsg proto.Message) boo } return this.EqualVT(that) } + func (this *Update_Config) EqualVT(that *Update_Config) bool { if this == that { return true @@ -2651,6 +2786,7 @@ func (this *Update_Config) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Update) EqualVT(that *Update) bool { if this == that { return true @@ -2667,6 +2803,7 @@ func (this *Update) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Upsert_Request) EqualVT(that *Upsert_Request) bool { if this == that { return true @@ -2689,6 +2826,7 @@ func (this *Upsert_Request) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Upsert_MultiRequest) EqualVT(that *Upsert_MultiRequest) bool { if this == that { return true @@ -2722,6 +2860,7 @@ func (this *Upsert_MultiRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Upsert_ObjectRequest) EqualVT(that *Upsert_ObjectRequest) bool { if this == that { return true @@ -2747,6 +2886,7 @@ func (this *Upsert_ObjectRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Upsert_MultiObjectRequest) EqualVT(that *Upsert_MultiObjectRequest) bool { if this == that { return true @@ -2780,6 +2920,7 @@ func (this *Upsert_MultiObjectRequest) EqualMessageVT(thatMsg proto.Message) boo } return this.EqualVT(that) } + func (this *Upsert_Config) EqualVT(that *Upsert_Config) bool { if this == that { return true @@ -2808,6 +2949,7 @@ func (this *Upsert_Config) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Upsert) EqualVT(that *Upsert) bool { if this == that { return true @@ -2824,6 +2966,7 @@ func (this *Upsert) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Remove_Request) EqualVT(that *Remove_Request) bool { if this == that { return true @@ -2846,6 +2989,7 @@ func (this *Remove_Request) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Remove_MultiRequest) EqualVT(that *Remove_MultiRequest) bool { if this == that { return true @@ -2879,6 +3023,7 @@ func (this *Remove_MultiRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Remove_TimestampRequest) EqualVT(that *Remove_TimestampRequest) bool { if this == that { return true @@ -2912,6 +3057,7 @@ func (this *Remove_TimestampRequest) EqualMessageVT(thatMsg proto.Message) bool } return this.EqualVT(that) } + func (this *Remove_Timestamp) EqualVT(that *Remove_Timestamp) bool { if this == that { return true @@ -2934,6 +3080,7 @@ func (this *Remove_Timestamp) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Remove_Config) EqualVT(that *Remove_Config) bool { if this == that { return true @@ -2956,6 +3103,7 @@ func (this *Remove_Config) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Remove) EqualVT(that *Remove) bool { if this == that { return true @@ -2972,6 +3120,7 @@ func (this *Remove) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Flush_Request) EqualVT(that *Flush_Request) bool { if this == that { return true @@ -2988,6 +3137,7 @@ func (this *Flush_Request) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Flush) EqualVT(that *Flush) bool { if this == that { return true @@ -3004,6 +3154,7 @@ func (this *Flush) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_VectorRequest) EqualVT(that *Object_VectorRequest) bool { if this == that { return true @@ -3026,6 +3177,7 @@ func (this *Object_VectorRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_Distance) EqualVT(that *Object_Distance) bool { if this == that { return true @@ -3048,6 +3200,7 @@ func (this *Object_Distance) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_StreamDistance) EqualVT(that *Object_StreamDistance) bool { if this == that { return true @@ -3076,7 +3229,10 @@ func (this *Object_StreamDistance) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } -func (this *Object_StreamDistance_Distance) EqualVT(thatIface isObject_StreamDistance_Payload) bool { + +func (this *Object_StreamDistance_Distance) EqualVT( + thatIface isObject_StreamDistance_Payload, +) bool { that, ok := thatIface.(*Object_StreamDistance_Distance) if !ok { return false @@ -3119,7 +3275,7 @@ func (this *Object_StreamDistance_Status) EqualVT(thatIface isObject_StreamDista if q == nil { q = &status.Status{} } - if equal, ok := interface{}(p).(interface{ EqualVT(*status.Status) bool }); ok { + if equal, ok := any(p).(interface{ EqualVT(*status.Status) bool }); ok { if !equal.EqualVT(q) { return false } @@ -3149,6 +3305,7 @@ func (this *Object_ID) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_IDs) EqualVT(that *Object_IDs) bool { if this == that { return true @@ -3174,6 +3331,7 @@ func (this *Object_IDs) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_Vector) EqualVT(that *Object_Vector) bool { if this == that { return true @@ -3205,7 +3363,8 @@ func (this *Object_Vector) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } -func (this *Object_GetTimestampRequest) EqualVT(that *Object_GetTimestampRequest) bool { + +func (this *Object_TimestampRequest) EqualVT(that *Object_TimestampRequest) bool { if this == that { return true } else if this == nil || that == nil { @@ -3217,13 +3376,14 @@ func (this *Object_GetTimestampRequest) EqualVT(that *Object_GetTimestampRequest return string(this.unknownFields) == string(that.unknownFields) } -func (this *Object_GetTimestampRequest) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*Object_GetTimestampRequest) +func (this *Object_TimestampRequest) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Object_TimestampRequest) if !ok { return false } return this.EqualVT(that) } + func (this *Object_Timestamp) EqualVT(that *Object_Timestamp) bool { if this == that { return true @@ -3246,6 +3406,7 @@ func (this *Object_Timestamp) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_Vectors) EqualVT(that *Object_Vectors) bool { if this == that { return true @@ -3279,6 +3440,7 @@ func (this *Object_Vectors) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_StreamVector) EqualVT(that *Object_StreamVector) bool { if this == that { return true @@ -3307,6 +3469,7 @@ func (this *Object_StreamVector) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_StreamVector_Vector) EqualVT(thatIface isObject_StreamVector_Payload) bool { that, ok := thatIface.(*Object_StreamVector_Vector) if !ok { @@ -3350,7 +3513,7 @@ func (this *Object_StreamVector_Status) EqualVT(thatIface isObject_StreamVector_ if q == nil { q = &status.Status{} } - if equal, ok := interface{}(p).(interface{ EqualVT(*status.Status) bool }); ok { + if equal, ok := any(p).(interface{ EqualVT(*status.Status) bool }); ok { if !equal.EqualVT(q) { return false } @@ -3389,6 +3552,7 @@ func (this *Object_ReshapeVector) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_Blob) EqualVT(that *Object_Blob) bool { if this == that { return true @@ -3411,6 +3575,7 @@ func (this *Object_Blob) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_StreamBlob) EqualVT(that *Object_StreamBlob) bool { if this == that { return true @@ -3439,6 +3604,7 @@ func (this *Object_StreamBlob) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_StreamBlob_Blob) EqualVT(thatIface isObject_StreamBlob_Payload) bool { that, ok := thatIface.(*Object_StreamBlob_Blob) if !ok { @@ -3482,7 +3648,7 @@ func (this *Object_StreamBlob_Status) EqualVT(thatIface isObject_StreamBlob_Payl if q == nil { q = &status.Status{} } - if equal, ok := interface{}(p).(interface{ EqualVT(*status.Status) bool }); ok { + if equal, ok := any(p).(interface{ EqualVT(*status.Status) bool }); ok { if !equal.EqualVT(q) { return false } @@ -3524,6 +3690,7 @@ func (this *Object_Location) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_StreamLocation) EqualVT(that *Object_StreamLocation) bool { if this == that { return true @@ -3552,7 +3719,10 @@ func (this *Object_StreamLocation) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } -func (this *Object_StreamLocation_Location) EqualVT(thatIface isObject_StreamLocation_Payload) bool { + +func (this *Object_StreamLocation_Location) EqualVT( + thatIface isObject_StreamLocation_Payload, +) bool { that, ok := thatIface.(*Object_StreamLocation_Location) if !ok { return false @@ -3595,7 +3765,7 @@ func (this *Object_StreamLocation_Status) EqualVT(thatIface isObject_StreamLocat if q == nil { q = &status.Status{} } - if equal, ok := interface{}(p).(interface{ EqualVT(*status.Status) bool }); ok { + if equal, ok := any(p).(interface{ EqualVT(*status.Status) bool }); ok { if !equal.EqualVT(q) { return false } @@ -3639,6 +3809,7 @@ func (this *Object_Locations) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_List_Request) EqualVT(that *Object_List_Request) bool { if this == that { return true @@ -3655,6 +3826,7 @@ func (this *Object_List_Request) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_List_Response) EqualVT(that *Object_List_Response) bool { if this == that { return true @@ -3683,6 +3855,7 @@ func (this *Object_List_Response) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_List_Response_Vector) EqualVT(thatIface isObject_List_Response_Payload) bool { that, ok := thatIface.(*Object_List_Response_Vector) if !ok { @@ -3726,7 +3899,7 @@ func (this *Object_List_Response_Status) EqualVT(thatIface isObject_List_Respons if q == nil { q = &status.Status{} } - if equal, ok := interface{}(p).(interface{ EqualVT(*status.Status) bool }); ok { + if equal, ok := any(p).(interface{ EqualVT(*status.Status) bool }); ok { if !equal.EqualVT(q) { return false } @@ -3753,6 +3926,7 @@ func (this *Object_List) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object) EqualVT(that *Object) bool { if this == that { return true @@ -3769,6 +3943,7 @@ func (this *Object) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Control_CreateIndexRequest) EqualVT(that *Control_CreateIndexRequest) bool { if this == that { return true @@ -3788,6 +3963,7 @@ func (this *Control_CreateIndexRequest) EqualMessageVT(thatMsg proto.Message) bo } return this.EqualVT(that) } + func (this *Control) EqualVT(that *Control) bool { if this == that { return true @@ -3804,6 +3980,7 @@ func (this *Control) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Discoverer_Request) EqualVT(that *Discoverer_Request) bool { if this == that { return true @@ -3829,6 +4006,7 @@ func (this *Discoverer_Request) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Discoverer) EqualVT(that *Discoverer) bool { if this == that { return true @@ -3845,6 +4023,7 @@ func (this *Discoverer) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Index_Count) EqualVT(that *Info_Index_Count) bool { if this == that { return true @@ -3873,6 +4052,50 @@ func (this *Info_Index_Count) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + +func (this *Info_Index_Detail) EqualVT(that *Info_Index_Detail) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Counts) != len(that.Counts) { + return false + } + for i, vx := range this.Counts { + vy, ok := that.Counts[i] + if !ok { + return false + } + if p, q := vx, vy; p != q { + if p == nil { + p = &Info_Index_Count{} + } + if q == nil { + q = &Info_Index_Count{} + } + if !p.EqualVT(q) { + return false + } + } + } + if this.Replica != that.Replica { + return false + } + if this.LiveAgents != that.LiveAgents { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Info_Index_Detail) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Info_Index_Detail) + if !ok { + return false + } + return this.EqualVT(that) +} + func (this *Info_Index_UUID_Committed) EqualVT(that *Info_Index_UUID_Committed) bool { if this == that { return true @@ -3892,6 +4115,7 @@ func (this *Info_Index_UUID_Committed) EqualMessageVT(thatMsg proto.Message) boo } return this.EqualVT(that) } + func (this *Info_Index_UUID_Uncommitted) EqualVT(that *Info_Index_UUID_Uncommitted) bool { if this == that { return true @@ -3911,6 +4135,7 @@ func (this *Info_Index_UUID_Uncommitted) EqualMessageVT(thatMsg proto.Message) b } return this.EqualVT(that) } + func (this *Info_Index_UUID) EqualVT(that *Info_Index_UUID) bool { if this == that { return true @@ -3927,169 +4152,346 @@ func (this *Info_Index_UUID) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } -func (this *Info_Index) EqualVT(that *Info_Index) bool { + +func (this *Info_Index_Statistics) EqualVT(that *Info_Index_Statistics) bool { if this == that { return true } else if this == nil || that == nil { return false } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *Info_Index) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*Info_Index) - if !ok { + if this.Valid != that.Valid { return false } - return this.EqualVT(that) -} -func (this *Info_Pod) EqualVT(that *Info_Pod) bool { - if this == that { - return true - } else if this == nil || that == nil { + if this.MedianIndegree != that.MedianIndegree { return false } - if this.AppName != that.AppName { + if this.MedianOutdegree != that.MedianOutdegree { return false } - if this.Name != that.Name { + if this.MaxNumberOfIndegree != that.MaxNumberOfIndegree { return false } - if this.Namespace != that.Namespace { + if this.MaxNumberOfOutdegree != that.MaxNumberOfOutdegree { return false } - if this.Ip != that.Ip { + if this.MinNumberOfIndegree != that.MinNumberOfIndegree { return false } - if !this.Cpu.EqualVT(that.Cpu) { + if this.MinNumberOfOutdegree != that.MinNumberOfOutdegree { return false } - if !this.Memory.EqualVT(that.Memory) { + if this.ModeIndegree != that.ModeIndegree { return false } - if !this.Node.EqualVT(that.Node) { + if this.ModeOutdegree != that.ModeOutdegree { return false } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *Info_Pod) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*Info_Pod) - if !ok { + if this.NodesSkippedFor10Edges != that.NodesSkippedFor10Edges { return false } - return this.EqualVT(that) -} -func (this *Info_Node) EqualVT(that *Info_Node) bool { - if this == that { - return true - } else if this == nil || that == nil { + if this.NodesSkippedForIndegreeDistance != that.NodesSkippedForIndegreeDistance { return false } - if this.Name != that.Name { + if this.NumberOfEdges != that.NumberOfEdges { return false } - if this.InternalAddr != that.InternalAddr { + if this.NumberOfIndexedObjects != that.NumberOfIndexedObjects { return false } - if this.ExternalAddr != that.ExternalAddr { + if this.NumberOfNodes != that.NumberOfNodes { return false } - if !this.Cpu.EqualVT(that.Cpu) { + if this.NumberOfNodesWithoutEdges != that.NumberOfNodesWithoutEdges { return false } - if !this.Memory.EqualVT(that.Memory) { + if this.NumberOfNodesWithoutIndegree != that.NumberOfNodesWithoutIndegree { return false } - if !this.Pods.EqualVT(that.Pods) { + if this.NumberOfObjects != that.NumberOfObjects { return false } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *Info_Node) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*Info_Node) - if !ok { + if this.NumberOfRemovedObjects != that.NumberOfRemovedObjects { return false } - return this.EqualVT(that) -} -func (this *Info_Service) EqualVT(that *Info_Service) bool { - if this == that { - return true - } else if this == nil || that == nil { + if this.SizeOfObjectRepository != that.SizeOfObjectRepository { return false } - if this.Name != that.Name { + if this.SizeOfRefinementObjectRepository != that.SizeOfRefinementObjectRepository { return false } - if this.ClusterIp != that.ClusterIp { + if this.VarianceOfIndegree != that.VarianceOfIndegree { return false } - if len(this.ClusterIps) != len(that.ClusterIps) { + if this.VarianceOfOutdegree != that.VarianceOfOutdegree { return false } - for i, vx := range this.ClusterIps { - vy := that.ClusterIps[i] + if this.MeanEdgeLength != that.MeanEdgeLength { + return false + } + if this.MeanEdgeLengthFor10Edges != that.MeanEdgeLengthFor10Edges { + return false + } + if this.MeanIndegreeDistanceFor10Edges != that.MeanIndegreeDistanceFor10Edges { + return false + } + if this.MeanNumberOfEdgesPerNode != that.MeanNumberOfEdgesPerNode { + return false + } + if this.C1Indegree != that.C1Indegree { + return false + } + if this.C5Indegree != that.C5Indegree { + return false + } + if this.C95Outdegree != that.C95Outdegree { + return false + } + if this.C99Outdegree != that.C99Outdegree { + return false + } + if len(this.IndegreeCount) != len(that.IndegreeCount) { + return false + } + for i, vx := range this.IndegreeCount { + vy := that.IndegreeCount[i] if vx != vy { return false } } - if len(this.Ports) != len(that.Ports) { + if len(this.OutdegreeHistogram) != len(that.OutdegreeHistogram) { return false } - for i, vx := range this.Ports { - vy := that.Ports[i] - if p, q := vx, vy; p != q { - if p == nil { - p = &Info_ServicePort{} - } - if q == nil { - q = &Info_ServicePort{} - } - if !p.EqualVT(q) { - return false - } + for i, vx := range this.OutdegreeHistogram { + vy := that.OutdegreeHistogram[i] + if vx != vy { + return false } } - if !this.Labels.EqualVT(that.Labels) { + if len(this.IndegreeHistogram) != len(that.IndegreeHistogram) { return false } - if !this.Annotations.EqualVT(that.Annotations) { - return false + for i, vx := range this.IndegreeHistogram { + vy := that.IndegreeHistogram[i] + if vx != vy { + return false + } } return string(this.unknownFields) == string(that.unknownFields) } -func (this *Info_Service) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*Info_Service) +func (this *Info_Index_Statistics) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Info_Index_Statistics) if !ok { return false } return this.EqualVT(that) } -func (this *Info_ServicePort) EqualVT(that *Info_ServicePort) bool { + +func (this *Info_Index_StatisticsDetail) EqualVT(that *Info_Index_StatisticsDetail) bool { if this == that { return true } else if this == nil || that == nil { return false } - if this.Name != that.Name { - return false - } - if this.Port != that.Port { + if len(this.Details) != len(that.Details) { return false } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *Info_ServicePort) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*Info_ServicePort) + for i, vx := range this.Details { + vy, ok := that.Details[i] + if !ok { + return false + } + if p, q := vx, vy; p != q { + if p == nil { + p = &Info_Index_Statistics{} + } + if q == nil { + q = &Info_Index_Statistics{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Info_Index_StatisticsDetail) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Info_Index_StatisticsDetail) + if !ok { + return false + } + return this.EqualVT(that) +} + +func (this *Info_Index) EqualVT(that *Info_Index) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Info_Index) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Info_Index) + if !ok { + return false + } + return this.EqualVT(that) +} + +func (this *Info_Pod) EqualVT(that *Info_Pod) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.AppName != that.AppName { + return false + } + if this.Name != that.Name { + return false + } + if this.Namespace != that.Namespace { + return false + } + if this.Ip != that.Ip { + return false + } + if !this.Cpu.EqualVT(that.Cpu) { + return false + } + if !this.Memory.EqualVT(that.Memory) { + return false + } + if !this.Node.EqualVT(that.Node) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Info_Pod) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Info_Pod) + if !ok { + return false + } + return this.EqualVT(that) +} + +func (this *Info_Node) EqualVT(that *Info_Node) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if this.InternalAddr != that.InternalAddr { + return false + } + if this.ExternalAddr != that.ExternalAddr { + return false + } + if !this.Cpu.EqualVT(that.Cpu) { + return false + } + if !this.Memory.EqualVT(that.Memory) { + return false + } + if !this.Pods.EqualVT(that.Pods) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Info_Node) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Info_Node) + if !ok { + return false + } + return this.EqualVT(that) +} + +func (this *Info_Service) EqualVT(that *Info_Service) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if this.ClusterIp != that.ClusterIp { + return false + } + if len(this.ClusterIps) != len(that.ClusterIps) { + return false + } + for i, vx := range this.ClusterIps { + vy := that.ClusterIps[i] + if vx != vy { + return false + } + } + if len(this.Ports) != len(that.Ports) { + return false + } + for i, vx := range this.Ports { + vy := that.Ports[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &Info_ServicePort{} + } + if q == nil { + q = &Info_ServicePort{} + } + if !p.EqualVT(q) { + return false + } + } + } + if !this.Labels.EqualVT(that.Labels) { + return false + } + if !this.Annotations.EqualVT(that.Annotations) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Info_Service) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Info_Service) + if !ok { + return false + } + return this.EqualVT(that) +} + +func (this *Info_ServicePort) EqualVT(that *Info_ServicePort) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if this.Port != that.Port { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Info_ServicePort) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Info_ServicePort) if !ok { return false } return this.EqualVT(that) } + func (this *Info_Labels) EqualVT(that *Info_Labels) bool { if this == that { return true @@ -4118,6 +4520,7 @@ func (this *Info_Labels) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Annotations) EqualVT(that *Info_Annotations) bool { if this == that { return true @@ -4146,6 +4549,7 @@ func (this *Info_Annotations) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_CPU) EqualVT(that *Info_CPU) bool { if this == that { return true @@ -4171,6 +4575,7 @@ func (this *Info_CPU) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Memory) EqualVT(that *Info_Memory) bool { if this == that { return true @@ -4196,6 +4601,7 @@ func (this *Info_Memory) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Pods) EqualVT(that *Info_Pods) bool { if this == that { return true @@ -4229,6 +4635,7 @@ func (this *Info_Pods) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Nodes) EqualVT(that *Info_Nodes) bool { if this == that { return true @@ -4262,6 +4669,7 @@ func (this *Info_Nodes) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Services) EqualVT(that *Info_Services) bool { if this == that { return true @@ -4295,6 +4703,7 @@ func (this *Info_Services) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_IPs) EqualVT(that *Info_IPs) bool { if this == that { return true @@ -4320,6 +4729,7 @@ func (this *Info_IPs) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info) EqualVT(that *Info) bool { if this == that { return true @@ -4336,6 +4746,7 @@ func (this *Info) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Mirror_Target) EqualVT(that *Mirror_Target) bool { if this == that { return true @@ -4358,6 +4769,7 @@ func (this *Mirror_Target) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Mirror_Targets) EqualVT(that *Mirror_Targets) bool { if this == that { return true @@ -4391,6 +4803,7 @@ func (this *Mirror_Targets) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Mirror) EqualVT(that *Mirror) bool { if this == that { return true @@ -4407,6 +4820,7 @@ func (this *Mirror) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Empty) EqualVT(that *Empty) bool { if this == that { return true @@ -4423,6 +4837,7 @@ func (this *Empty) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (m *Search_Request) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -4981,6 +5396,7 @@ func (m *Search_StreamResponse_Response) MarshalToSizedBufferVT(dAtA []byte) (in } return len(dAtA) - i, nil } + func (m *Search_StreamResponse_Status) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) @@ -4989,7 +5405,7 @@ func (m *Search_StreamResponse_Status) MarshalToVT(dAtA []byte) (int, error) { func (m *Search_StreamResponse_Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i := len(dAtA) if m.Status != nil { - if vtmsg, ok := interface{}(m.Status).(interface { + if vtmsg, ok := any(m.Status).(interface { MarshalToSizedBufferVT([]byte) (int, error) }); ok { size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) @@ -5012,6 +5428,7 @@ func (m *Search_StreamResponse_Status) MarshalToSizedBufferVT(dAtA []byte) (int, } return len(dAtA) - i, nil } + func (m *Search) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -6572,6 +6989,7 @@ func (m *Object_StreamDistance_Distance) MarshalToSizedBufferVT(dAtA []byte) (in } return len(dAtA) - i, nil } + func (m *Object_StreamDistance_Status) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) @@ -6580,7 +6998,7 @@ func (m *Object_StreamDistance_Status) MarshalToVT(dAtA []byte) (int, error) { func (m *Object_StreamDistance_Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i := len(dAtA) if m.Status != nil { - if vtmsg, ok := interface{}(m.Status).(interface { + if vtmsg, ok := any(m.Status).(interface { MarshalToSizedBufferVT([]byte) (int, error) }); ok { size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) @@ -6603,6 +7021,7 @@ func (m *Object_StreamDistance_Status) MarshalToSizedBufferVT(dAtA []byte) (int, } return len(dAtA) - i, nil } + func (m *Object_ID) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -6740,7 +7159,7 @@ func (m *Object_Vector) MarshalToSizedBufferVT(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Object_GetTimestampRequest) MarshalVT() (dAtA []byte, err error) { +func (m *Object_TimestampRequest) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -6753,12 +7172,12 @@ func (m *Object_GetTimestampRequest) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Object_GetTimestampRequest) MarshalToVT(dAtA []byte) (int, error) { +func (m *Object_TimestampRequest) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *Object_GetTimestampRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *Object_TimestampRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -6934,6 +7353,7 @@ func (m *Object_StreamVector_Vector) MarshalToSizedBufferVT(dAtA []byte) (int, e } return len(dAtA) - i, nil } + func (m *Object_StreamVector_Status) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) @@ -6942,7 +7362,7 @@ func (m *Object_StreamVector_Status) MarshalToVT(dAtA []byte) (int, error) { func (m *Object_StreamVector_Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i := len(dAtA) if m.Status != nil { - if vtmsg, ok := interface{}(m.Status).(interface { + if vtmsg, ok := any(m.Status).(interface { MarshalToSizedBufferVT([]byte) (int, error) }); ok { size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) @@ -6965,6 +7385,7 @@ func (m *Object_StreamVector_Status) MarshalToSizedBufferVT(dAtA []byte) (int, e } return len(dAtA) - i, nil } + func (m *Object_ReshapeVector) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -7134,6 +7555,7 @@ func (m *Object_StreamBlob_Blob) MarshalToSizedBufferVT(dAtA []byte) (int, error } return len(dAtA) - i, nil } + func (m *Object_StreamBlob_Status) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) @@ -7142,7 +7564,7 @@ func (m *Object_StreamBlob_Status) MarshalToVT(dAtA []byte) (int, error) { func (m *Object_StreamBlob_Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i := len(dAtA) if m.Status != nil { - if vtmsg, ok := interface{}(m.Status).(interface { + if vtmsg, ok := any(m.Status).(interface { MarshalToSizedBufferVT([]byte) (int, error) }); ok { size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) @@ -7165,6 +7587,7 @@ func (m *Object_StreamBlob_Status) MarshalToSizedBufferVT(dAtA []byte) (int, err } return len(dAtA) - i, nil } + func (m *Object_Location) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -7282,6 +7705,7 @@ func (m *Object_StreamLocation_Location) MarshalToSizedBufferVT(dAtA []byte) (in } return len(dAtA) - i, nil } + func (m *Object_StreamLocation_Status) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) @@ -7290,7 +7714,7 @@ func (m *Object_StreamLocation_Status) MarshalToVT(dAtA []byte) (int, error) { func (m *Object_StreamLocation_Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i := len(dAtA) if m.Status != nil { - if vtmsg, ok := interface{}(m.Status).(interface { + if vtmsg, ok := any(m.Status).(interface { MarshalToSizedBufferVT([]byte) (int, error) }); ok { size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) @@ -7313,6 +7737,7 @@ func (m *Object_StreamLocation_Status) MarshalToSizedBufferVT(dAtA []byte) (int, } return len(dAtA) - i, nil } + func (m *Object_Locations) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -7452,6 +7877,7 @@ func (m *Object_List_Response_Vector) MarshalToSizedBufferVT(dAtA []byte) (int, } return len(dAtA) - i, nil } + func (m *Object_List_Response_Status) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) @@ -7460,7 +7886,7 @@ func (m *Object_List_Response_Status) MarshalToVT(dAtA []byte) (int, error) { func (m *Object_List_Response_Status) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i := len(dAtA) if m.Status != nil { - if vtmsg, ok := interface{}(m.Status).(interface { + if vtmsg, ok := any(m.Status).(interface { MarshalToSizedBufferVT([]byte) (int, error) }); ok { size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) @@ -7483,6 +7909,7 @@ func (m *Object_List_Response_Status) MarshalToSizedBufferVT(dAtA []byte) (int, } return len(dAtA) - i, nil } + func (m *Object_List) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -7770,7 +8197,7 @@ func (m *Info_Index_Count) MarshalToSizedBufferVT(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Info_Index_UUID_Committed) MarshalVT() (dAtA []byte, err error) { +func (m *Info_Index_Detail) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -7783,12 +8210,12 @@ func (m *Info_Index_UUID_Committed) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Info_Index_UUID_Committed) MarshalToVT(dAtA []byte) (int, error) { +func (m *Info_Index_Detail) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *Info_Index_UUID_Committed) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *Info_Index_Detail) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -7800,17 +8227,42 @@ func (m *Info_Index_UUID_Committed) MarshalToSizedBufferVT(dAtA []byte) (int, er i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if len(m.Uuid) > 0 { - i -= len(m.Uuid) - copy(dAtA[i:], m.Uuid) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Uuid))) + if m.LiveAgents != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LiveAgents)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x18 + } + if m.Replica != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Replica)) + i-- + dAtA[i] = 0x10 + } + if len(m.Counts) > 0 { + for k := range m.Counts { + v := m.Counts[k] + baseI := i + size, err := v.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } } return len(dAtA) - i, nil } -func (m *Info_Index_UUID_Uncommitted) MarshalVT() (dAtA []byte, err error) { +func (m *Info_Index_UUID_Committed) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -7823,12 +8275,12 @@ func (m *Info_Index_UUID_Uncommitted) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Info_Index_UUID_Uncommitted) MarshalToVT(dAtA []byte) (int, error) { +func (m *Info_Index_UUID_Committed) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *Info_Index_UUID_Uncommitted) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *Info_Index_UUID_Committed) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -7850,7 +8302,7 @@ func (m *Info_Index_UUID_Uncommitted) MarshalToSizedBufferVT(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *Info_Index_UUID) MarshalVT() (dAtA []byte, err error) { +func (m *Info_Index_UUID_Uncommitted) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -7863,12 +8315,12 @@ func (m *Info_Index_UUID) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Info_Index_UUID) MarshalToVT(dAtA []byte) (int, error) { +func (m *Info_Index_UUID_Uncommitted) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *Info_Index_UUID) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *Info_Index_UUID_Uncommitted) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -7880,10 +8332,400 @@ func (m *Info_Index_UUID) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - return len(dAtA) - i, nil -} - -func (m *Info_Index) MarshalVT() (dAtA []byte, err error) { + if len(m.Uuid) > 0 { + i -= len(m.Uuid) + copy(dAtA[i:], m.Uuid) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Uuid))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Info_Index_UUID) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Info_Index_UUID) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Info_Index_UUID) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *Info_Index_Statistics) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Info_Index_Statistics) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Info_Index_Statistics) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.IndegreeHistogram) > 0 { + var pksize2 int + for _, num := range m.IndegreeHistogram { + pksize2 += protohelpers.SizeOfVarint(uint64(num)) + } + i -= pksize2 + j1 := i + for _, num := range m.IndegreeHistogram { + for num >= 1<<7 { + dAtA[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA[j1] = uint8(num) + j1++ + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(pksize2)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0x8a + } + if len(m.OutdegreeHistogram) > 0 { + var pksize4 int + for _, num := range m.OutdegreeHistogram { + pksize4 += protohelpers.SizeOfVarint(uint64(num)) + } + i -= pksize4 + j3 := i + for _, num := range m.OutdegreeHistogram { + for num >= 1<<7 { + dAtA[j3] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j3++ + } + dAtA[j3] = uint8(num) + j3++ + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(pksize4)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0x82 + } + if len(m.IndegreeCount) > 0 { + var pksize6 int + for _, num := range m.IndegreeCount { + pksize6 += protohelpers.SizeOfVarint(uint64(num)) + } + i -= pksize6 + j5 := i + for _, num1 := range m.IndegreeCount { + num := uint64(num1) + for num >= 1<<7 { + dAtA[j5] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j5++ + } + dAtA[j5] = uint8(num) + j5++ + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(pksize6)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xfa + } + if m.C99Outdegree != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.C99Outdegree)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xf1 + } + if m.C95Outdegree != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.C95Outdegree)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xe9 + } + if m.C5Indegree != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.C5Indegree)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xe1 + } + if m.C1Indegree != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.C1Indegree)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xd9 + } + if m.MeanNumberOfEdgesPerNode != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.MeanNumberOfEdgesPerNode)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xd1 + } + if m.MeanIndegreeDistanceFor10Edges != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.MeanIndegreeDistanceFor10Edges)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc9 + } + if m.MeanEdgeLengthFor10Edges != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.MeanEdgeLengthFor10Edges)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc1 + } + if m.MeanEdgeLength != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.MeanEdgeLength)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb9 + } + if m.VarianceOfOutdegree != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.VarianceOfOutdegree)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb1 + } + if m.VarianceOfIndegree != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.VarianceOfIndegree)))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa9 + } + if m.SizeOfRefinementObjectRepository != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.SizeOfRefinementObjectRepository)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa0 + } + if m.SizeOfObjectRepository != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.SizeOfObjectRepository)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x98 + } + if m.NumberOfRemovedObjects != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NumberOfRemovedObjects)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x90 + } + if m.NumberOfObjects != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NumberOfObjects)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + if m.NumberOfNodesWithoutIndegree != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NumberOfNodesWithoutIndegree)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 + } + if m.NumberOfNodesWithoutEdges != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NumberOfNodesWithoutEdges)) + i-- + dAtA[i] = 0x78 + } + if m.NumberOfNodes != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NumberOfNodes)) + i-- + dAtA[i] = 0x70 + } + if m.NumberOfIndexedObjects != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NumberOfIndexedObjects)) + i-- + dAtA[i] = 0x68 + } + if m.NumberOfEdges != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NumberOfEdges)) + i-- + dAtA[i] = 0x60 + } + if m.NodesSkippedForIndegreeDistance != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NodesSkippedForIndegreeDistance)) + i-- + dAtA[i] = 0x58 + } + if m.NodesSkippedFor10Edges != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NodesSkippedFor10Edges)) + i-- + dAtA[i] = 0x50 + } + if m.ModeOutdegree != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ModeOutdegree)) + i-- + dAtA[i] = 0x48 + } + if m.ModeIndegree != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ModeIndegree)) + i-- + dAtA[i] = 0x40 + } + if m.MinNumberOfOutdegree != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MinNumberOfOutdegree)) + i-- + dAtA[i] = 0x38 + } + if m.MinNumberOfIndegree != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MinNumberOfIndegree)) + i-- + dAtA[i] = 0x30 + } + if m.MaxNumberOfOutdegree != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MaxNumberOfOutdegree)) + i-- + dAtA[i] = 0x28 + } + if m.MaxNumberOfIndegree != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MaxNumberOfIndegree)) + i-- + dAtA[i] = 0x20 + } + if m.MedianOutdegree != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MedianOutdegree)) + i-- + dAtA[i] = 0x18 + } + if m.MedianIndegree != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MedianIndegree)) + i-- + dAtA[i] = 0x10 + } + if m.Valid { + i-- + if m.Valid { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Info_Index_StatisticsDetail) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Info_Index_StatisticsDetail) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Info_Index_StatisticsDetail) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Details) > 0 { + for k := range m.Details { + v := m.Details[k] + baseI := i + size, err := v.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Info_Index) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -9006,6 +9848,7 @@ func (m *Search_StreamResponse_Response) SizeVT() (n int) { } return n } + func (m *Search_StreamResponse_Status) SizeVT() (n int) { if m == nil { return 0 @@ -9013,7 +9856,7 @@ func (m *Search_StreamResponse_Status) SizeVT() (n int) { var l int _ = l if m.Status != nil { - if size, ok := interface{}(m.Status).(interface { + if size, ok := any(m.Status).(interface { SizeVT() int }); ok { l = size.SizeVT() @@ -9024,6 +9867,7 @@ func (m *Search_StreamResponse_Status) SizeVT() (n int) { } return n } + func (m *Search) SizeVT() (n int) { if m == nil { return 0 @@ -9561,6 +10405,7 @@ func (m *Object_StreamDistance_Distance) SizeVT() (n int) { } return n } + func (m *Object_StreamDistance_Status) SizeVT() (n int) { if m == nil { return 0 @@ -9568,7 +10413,7 @@ func (m *Object_StreamDistance_Status) SizeVT() (n int) { var l int _ = l if m.Status != nil { - if size, ok := interface{}(m.Status).(interface { + if size, ok := any(m.Status).(interface { SizeVT() int }); ok { l = size.SizeVT() @@ -9579,6 +10424,7 @@ func (m *Object_StreamDistance_Status) SizeVT() (n int) { } return n } + func (m *Object_ID) SizeVT() (n int) { if m == nil { return 0 @@ -9629,7 +10475,7 @@ func (m *Object_Vector) SizeVT() (n int) { return n } -func (m *Object_GetTimestampRequest) SizeVT() (n int) { +func (m *Object_TimestampRequest) SizeVT() (n int) { if m == nil { return 0 } @@ -9701,6 +10547,7 @@ func (m *Object_StreamVector_Vector) SizeVT() (n int) { } return n } + func (m *Object_StreamVector_Status) SizeVT() (n int) { if m == nil { return 0 @@ -9708,7 +10555,7 @@ func (m *Object_StreamVector_Status) SizeVT() (n int) { var l int _ = l if m.Status != nil { - if size, ok := interface{}(m.Status).(interface { + if size, ok := any(m.Status).(interface { SizeVT() int }); ok { l = size.SizeVT() @@ -9719,6 +10566,7 @@ func (m *Object_StreamVector_Status) SizeVT() (n int) { } return n } + func (m *Object_ReshapeVector) SizeVT() (n int) { if m == nil { return 0 @@ -9783,6 +10631,7 @@ func (m *Object_StreamBlob_Blob) SizeVT() (n int) { } return n } + func (m *Object_StreamBlob_Status) SizeVT() (n int) { if m == nil { return 0 @@ -9790,7 +10639,7 @@ func (m *Object_StreamBlob_Status) SizeVT() (n int) { var l int _ = l if m.Status != nil { - if size, ok := interface{}(m.Status).(interface { + if size, ok := any(m.Status).(interface { SizeVT() int }); ok { l = size.SizeVT() @@ -9801,6 +10650,7 @@ func (m *Object_StreamBlob_Status) SizeVT() (n int) { } return n } + func (m *Object_Location) SizeVT() (n int) { if m == nil { return 0 @@ -9850,6 +10700,7 @@ func (m *Object_StreamLocation_Location) SizeVT() (n int) { } return n } + func (m *Object_StreamLocation_Status) SizeVT() (n int) { if m == nil { return 0 @@ -9857,7 +10708,7 @@ func (m *Object_StreamLocation_Status) SizeVT() (n int) { var l int _ = l if m.Status != nil { - if size, ok := interface{}(m.Status).(interface { + if size, ok := any(m.Status).(interface { SizeVT() int }); ok { l = size.SizeVT() @@ -9868,6 +10719,7 @@ func (m *Object_StreamLocation_Status) SizeVT() (n int) { } return n } + func (m *Object_Locations) SizeVT() (n int) { if m == nil { return 0 @@ -9919,6 +10771,7 @@ func (m *Object_List_Response_Vector) SizeVT() (n int) { } return n } + func (m *Object_List_Response_Status) SizeVT() (n int) { if m == nil { return 0 @@ -9926,7 +10779,7 @@ func (m *Object_List_Response_Status) SizeVT() (n int) { var l int _ = l if m.Status != nil { - if size, ok := interface{}(m.Status).(interface { + if size, ok := any(m.Status).(interface { SizeVT() int }); ok { l = size.SizeVT() @@ -9937,6 +10790,7 @@ func (m *Object_List_Response_Status) SizeVT() (n int) { } return n } + func (m *Object_List) SizeVT() (n int) { if m == nil { return 0 @@ -10034,6 +10888,35 @@ func (m *Info_Index_Count) SizeVT() (n int) { return n } +func (m *Info_Index_Detail) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Counts) > 0 { + for k, v := range m.Counts { + _ = k + _ = v + l = 0 + if v != nil { + l = v.SizeVT() + } + l += 1 + protohelpers.SizeOfVarint(uint64(l)) + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + if m.Replica != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Replica)) + } + if m.LiveAgents != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LiveAgents)) + } + n += len(m.unknownFields) + return n +} + func (m *Info_Index_UUID_Committed) SizeVT() (n int) { if m == nil { return 0 @@ -10072,6 +10955,150 @@ func (m *Info_Index_UUID) SizeVT() (n int) { return n } +func (m *Info_Index_Statistics) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Valid { + n += 2 + } + if m.MedianIndegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MedianIndegree)) + } + if m.MedianOutdegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MedianOutdegree)) + } + if m.MaxNumberOfIndegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MaxNumberOfIndegree)) + } + if m.MaxNumberOfOutdegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MaxNumberOfOutdegree)) + } + if m.MinNumberOfIndegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MinNumberOfIndegree)) + } + if m.MinNumberOfOutdegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MinNumberOfOutdegree)) + } + if m.ModeIndegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.ModeIndegree)) + } + if m.ModeOutdegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.ModeOutdegree)) + } + if m.NodesSkippedFor10Edges != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.NodesSkippedFor10Edges)) + } + if m.NodesSkippedForIndegreeDistance != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.NodesSkippedForIndegreeDistance)) + } + if m.NumberOfEdges != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.NumberOfEdges)) + } + if m.NumberOfIndexedObjects != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.NumberOfIndexedObjects)) + } + if m.NumberOfNodes != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.NumberOfNodes)) + } + if m.NumberOfNodesWithoutEdges != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.NumberOfNodesWithoutEdges)) + } + if m.NumberOfNodesWithoutIndegree != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.NumberOfNodesWithoutIndegree)) + } + if m.NumberOfObjects != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.NumberOfObjects)) + } + if m.NumberOfRemovedObjects != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.NumberOfRemovedObjects)) + } + if m.SizeOfObjectRepository != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.SizeOfObjectRepository)) + } + if m.SizeOfRefinementObjectRepository != 0 { + n += 2 + protohelpers.SizeOfVarint(uint64(m.SizeOfRefinementObjectRepository)) + } + if m.VarianceOfIndegree != 0 { + n += 10 + } + if m.VarianceOfOutdegree != 0 { + n += 10 + } + if m.MeanEdgeLength != 0 { + n += 10 + } + if m.MeanEdgeLengthFor10Edges != 0 { + n += 10 + } + if m.MeanIndegreeDistanceFor10Edges != 0 { + n += 10 + } + if m.MeanNumberOfEdgesPerNode != 0 { + n += 10 + } + if m.C1Indegree != 0 { + n += 10 + } + if m.C5Indegree != 0 { + n += 10 + } + if m.C95Outdegree != 0 { + n += 10 + } + if m.C99Outdegree != 0 { + n += 10 + } + if len(m.IndegreeCount) > 0 { + l = 0 + for _, e := range m.IndegreeCount { + l += protohelpers.SizeOfVarint(uint64(e)) + } + n += 2 + protohelpers.SizeOfVarint(uint64(l)) + l + } + if len(m.OutdegreeHistogram) > 0 { + l = 0 + for _, e := range m.OutdegreeHistogram { + l += protohelpers.SizeOfVarint(uint64(e)) + } + n += 2 + protohelpers.SizeOfVarint(uint64(l)) + l + } + if len(m.IndegreeHistogram) > 0 { + l = 0 + for _, e := range m.IndegreeHistogram { + l += protohelpers.SizeOfVarint(uint64(e)) + } + n += 2 + protohelpers.SizeOfVarint(uint64(l)) + l + } + n += len(m.unknownFields) + return n +} + +func (m *Info_Index_StatisticsDetail) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Details) > 0 { + for k, v := range m.Details { + _ = k + _ = v + l = 0 + if v != nil { + l = v.SizeVT() + } + l += 1 + protohelpers.SizeOfVarint(uint64(l)) + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + n += len(m.unknownFields) + return n +} + func (m *Info_Index) SizeVT() (n int) { if m == nil { return 0 @@ -10551,6 +11578,7 @@ func (m *Search_Request) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search_MultiRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -10636,6 +11664,7 @@ func (m *Search_MultiRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search_IDRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -10755,6 +11784,7 @@ func (m *Search_IDRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search_MultiIDRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -10840,6 +11870,7 @@ func (m *Search_MultiIDRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search_ObjectRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -10997,6 +12028,7 @@ func (m *Search_ObjectRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search_MultiObjectRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -11082,6 +12114,7 @@ func (m *Search_MultiObjectRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search_Config) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -11371,6 +12404,7 @@ func (m *Search_Config) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search_Response) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -11488,6 +12522,7 @@ func (m *Search_Response) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search_Responses) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -11573,6 +12608,7 @@ func (m *Search_Responses) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search_StreamResponse) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -11673,7 +12709,7 @@ func (m *Search_StreamResponse) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } if oneof, ok := m.Payload.(*Search_StreamResponse_Status); ok { - if unmarshal, ok := interface{}(oneof.Status).(interface { + if unmarshal, ok := any(oneof.Status).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -11686,7 +12722,7 @@ func (m *Search_StreamResponse) UnmarshalVT(dAtA []byte) error { } } else { v := &status.Status{} - if unmarshal, ok := interface{}(v).(interface { + if unmarshal, ok := any(v).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -11722,6 +12758,7 @@ func (m *Search_StreamResponse) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Search) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -11773,6 +12810,7 @@ func (m *Search) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Filter_Target) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -11875,6 +12913,7 @@ func (m *Filter_Target) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Filter_Config) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -11960,6 +12999,7 @@ func (m *Filter_Config) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Filter) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -12011,6 +13051,7 @@ func (m *Filter) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Insert_Request) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -12134,6 +13175,7 @@ func (m *Insert_Request) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Insert_MultiRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -12219,6 +13261,7 @@ func (m *Insert_MultiRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Insert_ObjectRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -12378,6 +13421,7 @@ func (m *Insert_ObjectRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Insert_MultiObjectRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -12463,6 +13507,7 @@ func (m *Insert_MultiObjectRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Insert_Config) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -12589,6 +13634,7 @@ func (m *Insert_Config) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Insert) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -12640,6 +13686,7 @@ func (m *Insert) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Update_Request) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -12763,6 +13810,7 @@ func (m *Update_Request) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Update_MultiRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -12848,6 +13896,7 @@ func (m *Update_MultiRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Update_ObjectRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13007,6 +14056,7 @@ func (m *Update_ObjectRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Update_MultiObjectRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13092,6 +14142,7 @@ func (m *Update_MultiObjectRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Update_Config) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13238,6 +14289,7 @@ func (m *Update_Config) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Update) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13289,6 +14341,7 @@ func (m *Update) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Upsert_Request) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13412,6 +14465,7 @@ func (m *Upsert_Request) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Upsert_MultiRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13497,6 +14551,7 @@ func (m *Upsert_MultiRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Upsert_ObjectRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13656,6 +14711,7 @@ func (m *Upsert_ObjectRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Upsert_MultiObjectRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13741,6 +14797,7 @@ func (m *Upsert_MultiObjectRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Upsert_Config) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13887,6 +14944,7 @@ func (m *Upsert_Config) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Upsert) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -13938,6 +14996,7 @@ func (m *Upsert) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Remove_Request) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14061,6 +15120,7 @@ func (m *Remove_Request) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Remove_MultiRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14146,6 +15206,7 @@ func (m *Remove_MultiRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Remove_TimestampRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14231,6 +15292,7 @@ func (m *Remove_TimestampRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Remove_Timestamp) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14320,6 +15382,7 @@ func (m *Remove_Timestamp) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Remove_Config) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14410,6 +15473,7 @@ func (m *Remove_Config) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Remove) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14461,6 +15525,7 @@ func (m *Remove) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Flush_Request) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14512,6 +15577,7 @@ func (m *Flush_Request) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Flush) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14563,6 +15629,7 @@ func (m *Flush) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_VectorRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14686,6 +15753,7 @@ func (m *Object_VectorRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_Distance) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14780,6 +15848,7 @@ func (m *Object_Distance) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_StreamDistance) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14880,7 +15949,7 @@ func (m *Object_StreamDistance) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } if oneof, ok := m.Payload.(*Object_StreamDistance_Status); ok { - if unmarshal, ok := interface{}(oneof.Status).(interface { + if unmarshal, ok := any(oneof.Status).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -14893,7 +15962,7 @@ func (m *Object_StreamDistance) UnmarshalVT(dAtA []byte) error { } } else { v := &status.Status{} - if unmarshal, ok := interface{}(v).(interface { + if unmarshal, ok := any(v).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -14929,6 +15998,7 @@ func (m *Object_StreamDistance) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_ID) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15012,6 +16082,7 @@ func (m *Object_ID) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_IDs) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15095,6 +16166,7 @@ func (m *Object_IDs) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_Vector) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15251,7 +16323,8 @@ func (m *Object_Vector) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *Object_GetTimestampRequest) UnmarshalVT(dAtA []byte) error { + +func (m *Object_TimestampRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -15274,10 +16347,10 @@ func (m *Object_GetTimestampRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Object_GetTimestampRequest: wiretype end group for non-group") + return fmt.Errorf("proto: Object_TimestampRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Object_GetTimestampRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Object_TimestampRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -15338,6 +16411,7 @@ func (m *Object_GetTimestampRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_Timestamp) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15440,6 +16514,7 @@ func (m *Object_Timestamp) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_Vectors) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15525,6 +16600,7 @@ func (m *Object_Vectors) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_StreamVector) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15625,7 +16701,7 @@ func (m *Object_StreamVector) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } if oneof, ok := m.Payload.(*Object_StreamVector_Status); ok { - if unmarshal, ok := interface{}(oneof.Status).(interface { + if unmarshal, ok := any(oneof.Status).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -15638,7 +16714,7 @@ func (m *Object_StreamVector) UnmarshalVT(dAtA []byte) error { } } else { v := &status.Status{} - if unmarshal, ok := interface{}(v).(interface { + if unmarshal, ok := any(v).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -15674,6 +16750,7 @@ func (m *Object_StreamVector) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_ReshapeVector) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15835,6 +16912,7 @@ func (m *Object_ReshapeVector) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_Blob) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15952,6 +17030,7 @@ func (m *Object_Blob) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_StreamBlob) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16052,7 +17131,7 @@ func (m *Object_StreamBlob) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } if oneof, ok := m.Payload.(*Object_StreamBlob_Status); ok { - if unmarshal, ok := interface{}(oneof.Status).(interface { + if unmarshal, ok := any(oneof.Status).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -16065,7 +17144,7 @@ func (m *Object_StreamBlob) UnmarshalVT(dAtA []byte) error { } } else { v := &status.Status{} - if unmarshal, ok := interface{}(v).(interface { + if unmarshal, ok := any(v).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -16101,6 +17180,7 @@ func (m *Object_StreamBlob) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_Location) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16248,6 +17328,7 @@ func (m *Object_Location) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_StreamLocation) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16348,7 +17429,7 @@ func (m *Object_StreamLocation) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } if oneof, ok := m.Payload.(*Object_StreamLocation_Status); ok { - if unmarshal, ok := interface{}(oneof.Status).(interface { + if unmarshal, ok := any(oneof.Status).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -16361,7 +17442,7 @@ func (m *Object_StreamLocation) UnmarshalVT(dAtA []byte) error { } } else { v := &status.Status{} - if unmarshal, ok := interface{}(v).(interface { + if unmarshal, ok := any(v).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -16397,6 +17478,7 @@ func (m *Object_StreamLocation) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_Locations) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16482,6 +17564,7 @@ func (m *Object_Locations) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_List_Request) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16533,6 +17616,7 @@ func (m *Object_List_Request) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_List_Response) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16633,7 +17717,7 @@ func (m *Object_List_Response) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } if oneof, ok := m.Payload.(*Object_List_Response_Status); ok { - if unmarshal, ok := interface{}(oneof.Status).(interface { + if unmarshal, ok := any(oneof.Status).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -16646,7 +17730,7 @@ func (m *Object_List_Response) UnmarshalVT(dAtA []byte) error { } } else { v := &status.Status{} - if unmarshal, ok := interface{}(v).(interface { + if unmarshal, ok := any(v).(interface { UnmarshalVT([]byte) error }); ok { if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { @@ -16682,6 +17766,7 @@ func (m *Object_List_Response) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_List) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16733,6 +17818,7 @@ func (m *Object_List) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16784,6 +17870,7 @@ func (m *Object) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Control_CreateIndexRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16854,6 +17941,7 @@ func (m *Control_CreateIndexRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Control) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16905,6 +17993,7 @@ func (m *Control) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Discoverer_Request) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -17052,6 +18141,7 @@ func (m *Discoverer_Request) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Discoverer) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -17103,6 +18193,7 @@ func (m *Discoverer) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Index_Count) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -17232,7 +18323,8 @@ func (m *Info_Index_Count) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *Info_Index_UUID_Committed) UnmarshalVT(dAtA []byte) error { + +func (m *Info_Index_Detail) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -17255,44 +18347,1170 @@ func (m *Info_Index_UUID_Committed) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Info_Index_UUID_Committed: wiretype end group for non-group") + return fmt.Errorf("proto: Info_Index_Detail: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Info_Index_UUID_Committed: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Info_Index_Detail: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Uuid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Counts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Counts == nil { + m.Counts = make(map[string]*Info_Index_Count) + } + var mapkey string + var mapvalue *Info_Index_Count + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protohelpers.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Info_Index_Count{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Counts[mapkey] = mapvalue + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Replica", wireType) + } + m.Replica = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Replica |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LiveAgents", wireType) + } + m.LiveAgents = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LiveAgents |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *Info_Index_UUID_Committed) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Info_Index_UUID_Committed: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Info_Index_UUID_Committed: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uuid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uuid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *Info_Index_UUID_Uncommitted) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Info_Index_UUID_Uncommitted: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Info_Index_UUID_Uncommitted: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uuid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uuid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *Info_Index_UUID) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Info_Index_UUID: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Info_Index_UUID: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *Info_Index_Statistics) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Info_Index_Statistics: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Info_Index_Statistics: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Valid", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Valid = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MedianIndegree", wireType) + } + m.MedianIndegree = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MedianIndegree |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MedianOutdegree", wireType) + } + m.MedianOutdegree = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MedianOutdegree |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxNumberOfIndegree", wireType) + } + m.MaxNumberOfIndegree = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxNumberOfIndegree |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxNumberOfOutdegree", wireType) + } + m.MaxNumberOfOutdegree = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxNumberOfOutdegree |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinNumberOfIndegree", wireType) + } + m.MinNumberOfIndegree = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinNumberOfIndegree |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinNumberOfOutdegree", wireType) + } + m.MinNumberOfOutdegree = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinNumberOfOutdegree |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ModeIndegree", wireType) + } + m.ModeIndegree = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ModeIndegree |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ModeOutdegree", wireType) + } + m.ModeOutdegree = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ModeOutdegree |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NodesSkippedFor10Edges", wireType) + } + m.NodesSkippedFor10Edges = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NodesSkippedFor10Edges |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NodesSkippedForIndegreeDistance", wireType) + } + m.NodesSkippedForIndegreeDistance = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NodesSkippedForIndegreeDistance |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfEdges", wireType) + } + m.NumberOfEdges = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberOfEdges |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfIndexedObjects", wireType) + } + m.NumberOfIndexedObjects = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberOfIndexedObjects |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfNodes", wireType) + } + m.NumberOfNodes = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberOfNodes |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfNodesWithoutEdges", wireType) + } + m.NumberOfNodesWithoutEdges = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberOfNodesWithoutEdges |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 16: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfNodesWithoutIndegree", wireType) + } + m.NumberOfNodesWithoutIndegree = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberOfNodesWithoutIndegree |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfObjects", wireType) + } + m.NumberOfObjects = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberOfObjects |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 18: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfRemovedObjects", wireType) + } + m.NumberOfRemovedObjects = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberOfRemovedObjects |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 19: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SizeOfObjectRepository", wireType) + } + m.SizeOfObjectRepository = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SizeOfObjectRepository |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 20: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SizeOfRefinementObjectRepository", wireType) + } + m.SizeOfRefinementObjectRepository = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SizeOfRefinementObjectRepository |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 21: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field VarianceOfIndegree", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.VarianceOfIndegree = float64(math.Float64frombits(v)) + case 22: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field VarianceOfOutdegree", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.VarianceOfOutdegree = float64(math.Float64frombits(v)) + case 23: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field MeanEdgeLength", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.MeanEdgeLength = float64(math.Float64frombits(v)) + case 24: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field MeanEdgeLengthFor10Edges", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.MeanEdgeLengthFor10Edges = float64(math.Float64frombits(v)) + case 25: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field MeanIndegreeDistanceFor10Edges", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.MeanIndegreeDistanceFor10Edges = float64(math.Float64frombits(v)) + case 26: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field MeanNumberOfEdgesPerNode", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.MeanNumberOfEdgesPerNode = float64(math.Float64frombits(v)) + case 27: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field C1Indegree", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.C1Indegree = float64(math.Float64frombits(v)) + case 28: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field C5Indegree", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.C5Indegree = float64(math.Float64frombits(v)) + case 29: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field C95Outdegree", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.C95Outdegree = float64(math.Float64frombits(v)) + case 30: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field C99Outdegree", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.C99Outdegree = float64(math.Float64frombits(v)) + case 31: + if wireType == 0 { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IndegreeCount = append(m.IndegreeCount, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.IndegreeCount) == 0 { + m.IndegreeCount = make([]int64, 0, elementCount) + } + for iNdEx < postIndex { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IndegreeCount = append(m.IndegreeCount, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field IndegreeCount", wireType) + } + case 32: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.OutdegreeHistogram = append(m.OutdegreeHistogram, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.OutdegreeHistogram) == 0 { + m.OutdegreeHistogram = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.OutdegreeHistogram = append(m.OutdegreeHistogram, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field OutdegreeHistogram", wireType) } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow + case 33: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - if iNdEx >= l { + m.IndegreeHistogram = append(m.IndegreeHistogram, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } } + elementCount = count + if elementCount != 0 && len(m.IndegreeHistogram) == 0 { + m.IndegreeHistogram = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IndegreeHistogram = append(m.IndegreeHistogram, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field IndegreeHistogram", wireType) } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Uuid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := protohelpers.Skip(dAtA[iNdEx:]) @@ -17315,7 +19533,8 @@ func (m *Info_Index_UUID_Committed) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *Info_Index_UUID_Uncommitted) UnmarshalVT(dAtA []byte) error { + +func (m *Info_Index_StatisticsDetail) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -17338,17 +19557,17 @@ func (m *Info_Index_UUID_Uncommitted) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Info_Index_UUID_Uncommitted: wiretype end group for non-group") + return fmt.Errorf("proto: Info_Index_StatisticsDetail: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Info_Index_UUID_Uncommitted: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Info_Index_StatisticsDetail: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Uuid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Details", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -17358,75 +19577,121 @@ func (m *Info_Index_UUID_Uncommitted) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Uuid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Info_Index_UUID) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF + if m.Details == nil { + m.Details = make(map[string]*Info_Index_Statistics) } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + var mapkey string + var mapvalue *Info_Index_Statistics + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protohelpers.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Info_Index_Statistics{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Info_Index_UUID: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Info_Index_UUID: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { + m.Details[mapkey] = mapvalue + iNdEx = postIndex default: iNdEx = preIndex skippy, err := protohelpers.Skip(dAtA[iNdEx:]) @@ -17449,6 +19714,7 @@ func (m *Info_Index_UUID) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Index) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -17500,6 +19766,7 @@ func (m *Info_Index) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Pod) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -17787,6 +20054,7 @@ func (m *Info_Pod) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Node) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -18042,6 +20310,7 @@ func (m *Info_Node) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Service) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -18295,6 +20564,7 @@ func (m *Info_Service) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_ServicePort) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -18397,6 +20667,7 @@ func (m *Info_ServicePort) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Labels) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -18575,6 +20846,7 @@ func (m *Info_Labels) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Annotations) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -18753,6 +21025,7 @@ func (m *Info_Annotations) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_CPU) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -18837,6 +21110,7 @@ func (m *Info_CPU) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Memory) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -18921,6 +21195,7 @@ func (m *Info_Memory) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Pods) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -19006,6 +21281,7 @@ func (m *Info_Pods) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Nodes) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -19091,6 +21367,7 @@ func (m *Info_Nodes) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Services) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -19176,6 +21453,7 @@ func (m *Info_Services) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_IPs) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -19259,6 +21537,7 @@ func (m *Info_IPs) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -19310,6 +21589,7 @@ func (m *Info) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Mirror_Target) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -19412,6 +21692,7 @@ func (m *Mirror_Target) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Mirror_Targets) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -19497,6 +21778,7 @@ func (m *Mirror_Targets) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Mirror) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -19548,6 +21830,7 @@ func (m *Mirror) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Empty) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/apis/grpc/v1/rpc/errdetails/error_details.pb.go b/apis/grpc/v1/rpc/errdetails/error_details.pb.go index c126c47fa8..ff9e1c42cf 100644 --- a/apis/grpc/v1/rpc/errdetails/error_details.pb.go +++ b/apis/grpc/v1/rpc/errdetails/error_details.pb.go @@ -1,5 +1,6 @@ // -// Copyright (C) 2019-2024 vdaas.org vald team +// Copyright (C) 2024 Google LLC +// Modified by 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. @@ -16,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/rpc/errdetails/error_details.proto @@ -72,14 +73,14 @@ type ErrorInfo struct { // domain of errors. This should be at most 63 characters and match a // regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, which represents // UPPER_SNAKE_CASE. - Reason string `protobuf:"bytes,1,opt,name=reason,proto3" json:"reason,omitempty"` + Reason string `protobuf:"bytes,1,opt,name=reason,proto3" json:"reason,omitempty"` // The logical grouping to which the "reason" belongs. The error domain // is typically the registered service name of the tool or product that // generates the error. Example: "pubsub.googleapis.com". If the error is // generated by some common infrastructure, the error domain must be a // globally unique value that identifies the infrastructure. For Google API // infrastructure, the error domain is "googleapis.com". - Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"` + Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"` // Additional structured details about this error. // // Keys should match /[a-zA-Z0-9-_]/ and be limited to 64 characters in @@ -214,7 +215,7 @@ type DebugInfo struct { // The stack trace entries indicating where the error occurred. StackEntries []string `protobuf:"bytes,1,rep,name=stack_entries,json=stackEntries,proto3" json:"stack_entries,omitempty"` // Additional debugging information provided by the server. - Detail string `protobuf:"bytes,2,opt,name=detail,proto3" json:"detail,omitempty"` + Detail string `protobuf:"bytes,2,opt,name=detail,proto3" json:"detail,omitempty"` } func (x *DebugInfo) Reset() { @@ -434,7 +435,7 @@ type RequestInfo struct { // An opaque string that should only be interpreted by the service generating // it. For example, it can be used to identify requests in the service's logs. - RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` // Any data that was used to serve this request. For example, an encrypted // stack trace that can be sent back to the service provider for debugging. ServingData string `protobuf:"bytes,2,opt,name=serving_data,json=servingData,proto3" json:"serving_data,omitempty"` @@ -504,11 +505,11 @@ type ResourceInfo struct { // The owner of the resource (optional). // For example, "user:" or "project:". - Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"` + Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"` // Describes what error is encountered when accessing this resource. // For example, updating a cloud project may require the `writer` permission // on the developer console project. - Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` } func (x *ResourceInfo) Reset() { @@ -634,7 +635,7 @@ type LocalizedMessage struct { // The locale used following the specification defined at // https://www.rfc-editor.org/rfc/bcp/bcp47.txt. // Examples are: "en-US", "fr-CH", "es-MX" - Locale string `protobuf:"bytes,1,opt,name=locale,proto3" json:"locale,omitempty"` + Locale string `protobuf:"bytes,1,opt,name=locale,proto3" json:"locale,omitempty"` // The localized error message in the above locale. Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` } @@ -695,7 +696,7 @@ type QuotaFailure_Violation struct { // The subject on which the quota check failed. // For example, "clientip:" or "project:". - Subject string `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"` + Subject string `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"` // A description of how the quota check failed. Clients can use this // description to find more about the quota configuration in the service's // public documentation, or find the relevant quota limit to adjust through @@ -761,11 +762,11 @@ type PreconditionFailure_Violation struct { // The type of PreconditionFailure. We recommend using a service-specific // enum type to define the supported precondition violation subjects. For // example, "TOS" for "Terms of Service violation". - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // The subject, relative to the type, that failed. // For example, "google.com/cloud" relative to the "TOS" type would indicate // which terms of service is being referenced. - Subject string `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"` + Subject string `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"` // A description of how the precondition failed. Developers can use this // description to understand how to fix the failure. // @@ -869,7 +870,7 @@ type BadRequest_FieldViolation struct { // first `emailAddresses` message // - `emailAddresses[3].type[2]` for a violation in the second `type` // value in the third `emailAddresses` message. - Field string `protobuf:"bytes,1,opt,name=field,proto3" json:"field,omitempty"` + Field string `protobuf:"bytes,1,opt,name=field,proto3" json:"field,omitempty"` // A description of why the request element is bad. Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` } @@ -929,7 +930,7 @@ type Help_Link struct { // Describes what the link offers. Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` // The URL of the link. - Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` } func (x *Help_Link) Reset() { @@ -1086,25 +1087,28 @@ func file_v1_rpc_errdetails_error_details_proto_rawDescGZIP() []byte { return file_v1_rpc_errdetails_error_details_proto_rawDescData } -var file_v1_rpc_errdetails_error_details_proto_msgTypes = make([]protoimpl.MessageInfo, 15) -var file_v1_rpc_errdetails_error_details_proto_goTypes = []interface{}{ - (*ErrorInfo)(nil), // 0: rpc.v1.ErrorInfo - (*RetryInfo)(nil), // 1: rpc.v1.RetryInfo - (*DebugInfo)(nil), // 2: rpc.v1.DebugInfo - (*QuotaFailure)(nil), // 3: rpc.v1.QuotaFailure - (*PreconditionFailure)(nil), // 4: rpc.v1.PreconditionFailure - (*BadRequest)(nil), // 5: rpc.v1.BadRequest - (*RequestInfo)(nil), // 6: rpc.v1.RequestInfo - (*ResourceInfo)(nil), // 7: rpc.v1.ResourceInfo - (*Help)(nil), // 8: rpc.v1.Help - (*LocalizedMessage)(nil), // 9: rpc.v1.LocalizedMessage - nil, // 10: rpc.v1.ErrorInfo.MetadataEntry - (*QuotaFailure_Violation)(nil), // 11: rpc.v1.QuotaFailure.Violation - (*PreconditionFailure_Violation)(nil), // 12: rpc.v1.PreconditionFailure.Violation - (*BadRequest_FieldViolation)(nil), // 13: rpc.v1.BadRequest.FieldViolation - (*Help_Link)(nil), // 14: rpc.v1.Help.Link - (*durationpb.Duration)(nil), // 15: google.protobuf.Duration -} +var ( + file_v1_rpc_errdetails_error_details_proto_msgTypes = make([]protoimpl.MessageInfo, 15) + file_v1_rpc_errdetails_error_details_proto_goTypes = []any{ + (*ErrorInfo)(nil), // 0: rpc.v1.ErrorInfo + (*RetryInfo)(nil), // 1: rpc.v1.RetryInfo + (*DebugInfo)(nil), // 2: rpc.v1.DebugInfo + (*QuotaFailure)(nil), // 3: rpc.v1.QuotaFailure + (*PreconditionFailure)(nil), // 4: rpc.v1.PreconditionFailure + (*BadRequest)(nil), // 5: rpc.v1.BadRequest + (*RequestInfo)(nil), // 6: rpc.v1.RequestInfo + (*ResourceInfo)(nil), // 7: rpc.v1.ResourceInfo + (*Help)(nil), // 8: rpc.v1.Help + (*LocalizedMessage)(nil), // 9: rpc.v1.LocalizedMessage + nil, // 10: rpc.v1.ErrorInfo.MetadataEntry + (*QuotaFailure_Violation)(nil), // 11: rpc.v1.QuotaFailure.Violation + (*PreconditionFailure_Violation)(nil), // 12: rpc.v1.PreconditionFailure.Violation + (*BadRequest_FieldViolation)(nil), // 13: rpc.v1.BadRequest.FieldViolation + (*Help_Link)(nil), // 14: rpc.v1.Help.Link + (*durationpb.Duration)(nil), // 15: google.protobuf.Duration + } +) + var file_v1_rpc_errdetails_error_details_proto_depIdxs = []int32{ 10, // 0: rpc.v1.ErrorInfo.metadata:type_name -> rpc.v1.ErrorInfo.MetadataEntry 15, // 1: rpc.v1.RetryInfo.retry_delay:type_name -> google.protobuf.Duration @@ -1125,7 +1129,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_v1_rpc_errdetails_error_details_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ErrorInfo); i { case 0: return &v.state @@ -1137,7 +1141,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*RetryInfo); i { case 0: return &v.state @@ -1149,7 +1153,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*DebugInfo); i { case 0: return &v.state @@ -1161,7 +1165,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*QuotaFailure); i { case 0: return &v.state @@ -1173,7 +1177,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*PreconditionFailure); i { case 0: return &v.state @@ -1185,7 +1189,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*BadRequest); i { case 0: return &v.state @@ -1197,7 +1201,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*RequestInfo); i { case 0: return &v.state @@ -1209,7 +1213,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*ResourceInfo); i { case 0: return &v.state @@ -1221,7 +1225,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*Help); i { case 0: return &v.state @@ -1233,7 +1237,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*LocalizedMessage); i { case 0: return &v.state @@ -1245,7 +1249,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*QuotaFailure_Violation); i { case 0: return &v.state @@ -1257,7 +1261,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*PreconditionFailure_Violation); i { case 0: return &v.state @@ -1269,7 +1273,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*BadRequest_FieldViolation); i { case 0: return &v.state @@ -1281,7 +1285,7 @@ func file_v1_rpc_errdetails_error_details_proto_init() { return nil } } - file_v1_rpc_errdetails_error_details_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_v1_rpc_errdetails_error_details_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*Help_Link); i { case 0: return &v.state diff --git a/apis/grpc/v1/rpc/errdetails/error_details.pb.json.go b/apis/grpc/v1/rpc/errdetails/error_details.pb.json.go index 1829998e8b..8aad832ca9 100644 --- a/apis/grpc/v1/rpc/errdetails/error_details.pb.json.go +++ b/apis/grpc/v1/rpc/errdetails/error_details.pb.json.go @@ -1,5 +1,6 @@ // -// Copyright (C) 2019-2024 vdaas.org vald team +// Copyright (C) 2024 Google LLC +// Modified by 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. @@ -19,9 +20,7 @@ package errdetails -import ( - "google.golang.org/protobuf/encoding/protojson" -) +import "google.golang.org/protobuf/encoding/protojson" // MarshalJSON implements json.Marshaler func (msg *ErrorInfo) MarshalJSON() ([]byte, error) { diff --git a/apis/grpc/v1/rpc/errdetails/error_details_vtproto.pb.go b/apis/grpc/v1/rpc/errdetails/error_details_vtproto.pb.go index 27e9c07ef9..580f165e44 100644 --- a/apis/grpc/v1/rpc/errdetails/error_details_vtproto.pb.go +++ b/apis/grpc/v1/rpc/errdetails/error_details_vtproto.pb.go @@ -1,5 +1,6 @@ // -// Copyright (C) 2019-2024 vdaas.org vald team +// Copyright (C) 2024 Google LLC +// Modified by 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. @@ -353,6 +354,7 @@ func (this *ErrorInfo) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *RetryInfo) EqualVT(that *RetryInfo) bool { if this == that { return true @@ -372,6 +374,7 @@ func (this *RetryInfo) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *DebugInfo) EqualVT(that *DebugInfo) bool { if this == that { return true @@ -400,6 +403,7 @@ func (this *DebugInfo) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *QuotaFailure_Violation) EqualVT(that *QuotaFailure_Violation) bool { if this == that { return true @@ -422,6 +426,7 @@ func (this *QuotaFailure_Violation) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *QuotaFailure) EqualVT(that *QuotaFailure) bool { if this == that { return true @@ -455,6 +460,7 @@ func (this *QuotaFailure) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *PreconditionFailure_Violation) EqualVT(that *PreconditionFailure_Violation) bool { if this == that { return true @@ -480,6 +486,7 @@ func (this *PreconditionFailure_Violation) EqualMessageVT(thatMsg proto.Message) } return this.EqualVT(that) } + func (this *PreconditionFailure) EqualVT(that *PreconditionFailure) bool { if this == that { return true @@ -513,6 +520,7 @@ func (this *PreconditionFailure) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *BadRequest_FieldViolation) EqualVT(that *BadRequest_FieldViolation) bool { if this == that { return true @@ -535,6 +543,7 @@ func (this *BadRequest_FieldViolation) EqualMessageVT(thatMsg proto.Message) boo } return this.EqualVT(that) } + func (this *BadRequest) EqualVT(that *BadRequest) bool { if this == that { return true @@ -568,6 +577,7 @@ func (this *BadRequest) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *RequestInfo) EqualVT(that *RequestInfo) bool { if this == that { return true @@ -590,6 +600,7 @@ func (this *RequestInfo) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *ResourceInfo) EqualVT(that *ResourceInfo) bool { if this == that { return true @@ -618,6 +629,7 @@ func (this *ResourceInfo) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Help_Link) EqualVT(that *Help_Link) bool { if this == that { return true @@ -640,6 +652,7 @@ func (this *Help_Link) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Help) EqualVT(that *Help) bool { if this == that { return true @@ -673,6 +686,7 @@ func (this *Help) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *LocalizedMessage) EqualVT(that *LocalizedMessage) bool { if this == that { return true @@ -695,6 +709,7 @@ func (this *LocalizedMessage) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (m *ErrorInfo) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -1887,6 +1902,7 @@ func (m *ErrorInfo) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *RetryInfo) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1974,6 +1990,7 @@ func (m *RetryInfo) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *DebugInfo) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2089,6 +2106,7 @@ func (m *DebugInfo) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *QuotaFailure_Violation) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2204,6 +2222,7 @@ func (m *QuotaFailure_Violation) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *QuotaFailure) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2289,6 +2308,7 @@ func (m *QuotaFailure) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *PreconditionFailure_Violation) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2436,6 +2456,7 @@ func (m *PreconditionFailure_Violation) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *PreconditionFailure) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2521,6 +2542,7 @@ func (m *PreconditionFailure) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *BadRequest_FieldViolation) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2636,6 +2658,7 @@ func (m *BadRequest_FieldViolation) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *BadRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2721,6 +2744,7 @@ func (m *BadRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *RequestInfo) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2836,6 +2860,7 @@ func (m *RequestInfo) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *ResourceInfo) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3015,6 +3040,7 @@ func (m *ResourceInfo) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Help_Link) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3130,6 +3156,7 @@ func (m *Help_Link) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Help) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3215,6 +3242,7 @@ func (m *Help) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *LocalizedMessage) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/apis/grpc/v1/vald/filter.pb.go b/apis/grpc/v1/vald/filter.pb.go index 162881bc5e..8309d71f5b 100644 --- a/apis/grpc/v1/vald/filter.pb.go +++ b/apis/grpc/v1/vald/filter.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/vald/filter.proto @@ -138,7 +138,7 @@ var file_v1_vald_filter_proto_rawDesc = []byte{ 0x74, 0x6f, 0x33, } -var file_v1_vald_filter_proto_goTypes = []interface{}{ +var file_v1_vald_filter_proto_goTypes = []any{ (*payload.Search_ObjectRequest)(nil), // 0: payload.v1.Search.ObjectRequest (*payload.Search_MultiObjectRequest)(nil), // 1: payload.v1.Search.MultiObjectRequest (*payload.Insert_ObjectRequest)(nil), // 2: payload.v1.Insert.ObjectRequest @@ -154,6 +154,7 @@ var file_v1_vald_filter_proto_goTypes = []interface{}{ (*payload.Object_StreamLocation)(nil), // 12: payload.v1.Object.StreamLocation (*payload.Object_Locations)(nil), // 13: payload.v1.Object.Locations } + var file_v1_vald_filter_proto_depIdxs = []int32{ 0, // 0: vald.v1.Filter.SearchObject:input_type -> payload.v1.Search.ObjectRequest 1, // 1: vald.v1.Filter.MultiSearchObject:input_type -> payload.v1.Search.MultiObjectRequest diff --git a/apis/grpc/v1/vald/filter_vtproto.pb.go b/apis/grpc/v1/vald/filter_vtproto.pb.go index 7c8afdeb3a..54963521a7 100644 --- a/apis/grpc/v1/vald/filter_vtproto.pb.go +++ b/apis/grpc/v1/vald/filter_vtproto.pb.go @@ -76,7 +76,9 @@ func NewFilterClient(cc grpc.ClientConnInterface) FilterClient { return &filterClient{cc} } -func (c *filterClient) SearchObject(ctx context.Context, in *payload.Search_ObjectRequest, opts ...grpc.CallOption) (*payload.Search_Response, error) { +func (c *filterClient) SearchObject( + ctx context.Context, in *payload.Search_ObjectRequest, opts ...grpc.CallOption, +) (*payload.Search_Response, error) { out := new(payload.Search_Response) err := c.cc.Invoke(ctx, "/vald.v1.Filter/SearchObject", in, out, opts...) if err != nil { @@ -85,7 +87,9 @@ func (c *filterClient) SearchObject(ctx context.Context, in *payload.Search_Obje return out, nil } -func (c *filterClient) MultiSearchObject(ctx context.Context, in *payload.Search_MultiObjectRequest, opts ...grpc.CallOption) (*payload.Search_Responses, error) { +func (c *filterClient) MultiSearchObject( + ctx context.Context, in *payload.Search_MultiObjectRequest, opts ...grpc.CallOption, +) (*payload.Search_Responses, error) { out := new(payload.Search_Responses) err := c.cc.Invoke(ctx, "/vald.v1.Filter/MultiSearchObject", in, out, opts...) if err != nil { @@ -94,7 +98,9 @@ func (c *filterClient) MultiSearchObject(ctx context.Context, in *payload.Search return out, nil } -func (c *filterClient) StreamSearchObject(ctx context.Context, opts ...grpc.CallOption) (Filter_StreamSearchObjectClient, error) { +func (c *filterClient) StreamSearchObject( + ctx context.Context, opts ...grpc.CallOption, +) (Filter_StreamSearchObjectClient, error) { stream, err := c.cc.NewStream(ctx, &Filter_ServiceDesc.Streams[0], "/vald.v1.Filter/StreamSearchObject", opts...) if err != nil { return nil, err @@ -125,7 +131,9 @@ func (x *filterStreamSearchObjectClient) Recv() (*payload.Search_StreamResponse, return m, nil } -func (c *filterClient) InsertObject(ctx context.Context, in *payload.Insert_ObjectRequest, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (c *filterClient) InsertObject( + ctx context.Context, in *payload.Insert_ObjectRequest, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { out := new(payload.Object_Location) err := c.cc.Invoke(ctx, "/vald.v1.Filter/InsertObject", in, out, opts...) if err != nil { @@ -134,7 +142,9 @@ func (c *filterClient) InsertObject(ctx context.Context, in *payload.Insert_Obje return out, nil } -func (c *filterClient) StreamInsertObject(ctx context.Context, opts ...grpc.CallOption) (Filter_StreamInsertObjectClient, error) { +func (c *filterClient) StreamInsertObject( + ctx context.Context, opts ...grpc.CallOption, +) (Filter_StreamInsertObjectClient, error) { stream, err := c.cc.NewStream(ctx, &Filter_ServiceDesc.Streams[1], "/vald.v1.Filter/StreamInsertObject", opts...) if err != nil { return nil, err @@ -165,7 +175,9 @@ func (x *filterStreamInsertObjectClient) Recv() (*payload.Object_StreamLocation, return m, nil } -func (c *filterClient) MultiInsertObject(ctx context.Context, in *payload.Insert_MultiObjectRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) { +func (c *filterClient) MultiInsertObject( + ctx context.Context, in *payload.Insert_MultiObjectRequest, opts ...grpc.CallOption, +) (*payload.Object_Locations, error) { out := new(payload.Object_Locations) err := c.cc.Invoke(ctx, "/vald.v1.Filter/MultiInsertObject", in, out, opts...) if err != nil { @@ -174,7 +186,9 @@ func (c *filterClient) MultiInsertObject(ctx context.Context, in *payload.Insert return out, nil } -func (c *filterClient) UpdateObject(ctx context.Context, in *payload.Update_ObjectRequest, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (c *filterClient) UpdateObject( + ctx context.Context, in *payload.Update_ObjectRequest, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { out := new(payload.Object_Location) err := c.cc.Invoke(ctx, "/vald.v1.Filter/UpdateObject", in, out, opts...) if err != nil { @@ -183,7 +197,9 @@ func (c *filterClient) UpdateObject(ctx context.Context, in *payload.Update_Obje return out, nil } -func (c *filterClient) StreamUpdateObject(ctx context.Context, opts ...grpc.CallOption) (Filter_StreamUpdateObjectClient, error) { +func (c *filterClient) StreamUpdateObject( + ctx context.Context, opts ...grpc.CallOption, +) (Filter_StreamUpdateObjectClient, error) { stream, err := c.cc.NewStream(ctx, &Filter_ServiceDesc.Streams[2], "/vald.v1.Filter/StreamUpdateObject", opts...) if err != nil { return nil, err @@ -214,7 +230,9 @@ func (x *filterStreamUpdateObjectClient) Recv() (*payload.Object_StreamLocation, return m, nil } -func (c *filterClient) MultiUpdateObject(ctx context.Context, in *payload.Update_MultiObjectRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) { +func (c *filterClient) MultiUpdateObject( + ctx context.Context, in *payload.Update_MultiObjectRequest, opts ...grpc.CallOption, +) (*payload.Object_Locations, error) { out := new(payload.Object_Locations) err := c.cc.Invoke(ctx, "/vald.v1.Filter/MultiUpdateObject", in, out, opts...) if err != nil { @@ -223,7 +241,9 @@ func (c *filterClient) MultiUpdateObject(ctx context.Context, in *payload.Update return out, nil } -func (c *filterClient) UpsertObject(ctx context.Context, in *payload.Upsert_ObjectRequest, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (c *filterClient) UpsertObject( + ctx context.Context, in *payload.Upsert_ObjectRequest, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { out := new(payload.Object_Location) err := c.cc.Invoke(ctx, "/vald.v1.Filter/UpsertObject", in, out, opts...) if err != nil { @@ -232,7 +252,9 @@ func (c *filterClient) UpsertObject(ctx context.Context, in *payload.Upsert_Obje return out, nil } -func (c *filterClient) StreamUpsertObject(ctx context.Context, opts ...grpc.CallOption) (Filter_StreamUpsertObjectClient, error) { +func (c *filterClient) StreamUpsertObject( + ctx context.Context, opts ...grpc.CallOption, +) (Filter_StreamUpsertObjectClient, error) { stream, err := c.cc.NewStream(ctx, &Filter_ServiceDesc.Streams[3], "/vald.v1.Filter/StreamUpsertObject", opts...) if err != nil { return nil, err @@ -263,7 +285,9 @@ func (x *filterStreamUpsertObjectClient) Recv() (*payload.Object_StreamLocation, return m, nil } -func (c *filterClient) MultiUpsertObject(ctx context.Context, in *payload.Upsert_MultiObjectRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) { +func (c *filterClient) MultiUpsertObject( + ctx context.Context, in *payload.Upsert_MultiObjectRequest, opts ...grpc.CallOption, +) (*payload.Object_Locations, error) { out := new(payload.Object_Locations) err := c.cc.Invoke(ctx, "/vald.v1.Filter/MultiUpsertObject", in, out, opts...) if err != nil { @@ -304,43 +328,69 @@ type FilterServer interface { } // UnimplementedFilterServer must be embedded to have forward compatible implementations. -type UnimplementedFilterServer struct { -} +type UnimplementedFilterServer struct{} -func (UnimplementedFilterServer) SearchObject(context.Context, *payload.Search_ObjectRequest) (*payload.Search_Response, error) { +func (UnimplementedFilterServer) SearchObject( + context.Context, *payload.Search_ObjectRequest, +) (*payload.Search_Response, error) { return nil, status.Errorf(codes.Unimplemented, "method SearchObject not implemented") } -func (UnimplementedFilterServer) MultiSearchObject(context.Context, *payload.Search_MultiObjectRequest) (*payload.Search_Responses, error) { + +func (UnimplementedFilterServer) MultiSearchObject( + context.Context, *payload.Search_MultiObjectRequest, +) (*payload.Search_Responses, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiSearchObject not implemented") } + func (UnimplementedFilterServer) StreamSearchObject(Filter_StreamSearchObjectServer) error { return status.Errorf(codes.Unimplemented, "method StreamSearchObject not implemented") } -func (UnimplementedFilterServer) InsertObject(context.Context, *payload.Insert_ObjectRequest) (*payload.Object_Location, error) { + +func (UnimplementedFilterServer) InsertObject( + context.Context, *payload.Insert_ObjectRequest, +) (*payload.Object_Location, error) { return nil, status.Errorf(codes.Unimplemented, "method InsertObject not implemented") } + func (UnimplementedFilterServer) StreamInsertObject(Filter_StreamInsertObjectServer) error { return status.Errorf(codes.Unimplemented, "method StreamInsertObject not implemented") } -func (UnimplementedFilterServer) MultiInsertObject(context.Context, *payload.Insert_MultiObjectRequest) (*payload.Object_Locations, error) { + +func (UnimplementedFilterServer) MultiInsertObject( + context.Context, *payload.Insert_MultiObjectRequest, +) (*payload.Object_Locations, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiInsertObject not implemented") } -func (UnimplementedFilterServer) UpdateObject(context.Context, *payload.Update_ObjectRequest) (*payload.Object_Location, error) { + +func (UnimplementedFilterServer) UpdateObject( + context.Context, *payload.Update_ObjectRequest, +) (*payload.Object_Location, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateObject not implemented") } + func (UnimplementedFilterServer) StreamUpdateObject(Filter_StreamUpdateObjectServer) error { return status.Errorf(codes.Unimplemented, "method StreamUpdateObject not implemented") } -func (UnimplementedFilterServer) MultiUpdateObject(context.Context, *payload.Update_MultiObjectRequest) (*payload.Object_Locations, error) { + +func (UnimplementedFilterServer) MultiUpdateObject( + context.Context, *payload.Update_MultiObjectRequest, +) (*payload.Object_Locations, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiUpdateObject not implemented") } -func (UnimplementedFilterServer) UpsertObject(context.Context, *payload.Upsert_ObjectRequest) (*payload.Object_Location, error) { + +func (UnimplementedFilterServer) UpsertObject( + context.Context, *payload.Upsert_ObjectRequest, +) (*payload.Object_Location, error) { return nil, status.Errorf(codes.Unimplemented, "method UpsertObject not implemented") } + func (UnimplementedFilterServer) StreamUpsertObject(Filter_StreamUpsertObjectServer) error { return status.Errorf(codes.Unimplemented, "method StreamUpsertObject not implemented") } -func (UnimplementedFilterServer) MultiUpsertObject(context.Context, *payload.Upsert_MultiObjectRequest) (*payload.Object_Locations, error) { + +func (UnimplementedFilterServer) MultiUpsertObject( + context.Context, *payload.Upsert_MultiObjectRequest, +) (*payload.Object_Locations, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiUpsertObject not implemented") } func (UnimplementedFilterServer) mustEmbedUnimplementedFilterServer() {} @@ -356,7 +406,9 @@ func RegisterFilterServer(s grpc.ServiceRegistrar, srv FilterServer) { s.RegisterService(&Filter_ServiceDesc, srv) } -func _Filter_SearchObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_SearchObject_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_ObjectRequest) if err := dec(in); err != nil { return nil, err @@ -368,13 +420,15 @@ func _Filter_SearchObject_Handler(srv interface{}, ctx context.Context, dec func Server: srv, FullMethod: "/vald.v1.Filter/SearchObject", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).SearchObject(ctx, req.(*payload.Search_ObjectRequest)) } return interceptor(ctx, in, info, handler) } -func _Filter_MultiSearchObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_MultiSearchObject_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_MultiObjectRequest) if err := dec(in); err != nil { return nil, err @@ -386,13 +440,13 @@ func _Filter_MultiSearchObject_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/vald.v1.Filter/MultiSearchObject", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).MultiSearchObject(ctx, req.(*payload.Search_MultiObjectRequest)) } return interceptor(ctx, in, info, handler) } -func _Filter_StreamSearchObject_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Filter_StreamSearchObject_Handler(srv any, stream grpc.ServerStream) error { return srv.(FilterServer).StreamSearchObject(&filterStreamSearchObjectServer{stream}) } @@ -418,7 +472,9 @@ func (x *filterStreamSearchObjectServer) Recv() (*payload.Search_ObjectRequest, return m, nil } -func _Filter_InsertObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_InsertObject_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Insert_ObjectRequest) if err := dec(in); err != nil { return nil, err @@ -430,13 +486,13 @@ func _Filter_InsertObject_Handler(srv interface{}, ctx context.Context, dec func Server: srv, FullMethod: "/vald.v1.Filter/InsertObject", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).InsertObject(ctx, req.(*payload.Insert_ObjectRequest)) } return interceptor(ctx, in, info, handler) } -func _Filter_StreamInsertObject_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Filter_StreamInsertObject_Handler(srv any, stream grpc.ServerStream) error { return srv.(FilterServer).StreamInsertObject(&filterStreamInsertObjectServer{stream}) } @@ -462,7 +518,9 @@ func (x *filterStreamInsertObjectServer) Recv() (*payload.Insert_ObjectRequest, return m, nil } -func _Filter_MultiInsertObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_MultiInsertObject_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Insert_MultiObjectRequest) if err := dec(in); err != nil { return nil, err @@ -474,13 +532,15 @@ func _Filter_MultiInsertObject_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/vald.v1.Filter/MultiInsertObject", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).MultiInsertObject(ctx, req.(*payload.Insert_MultiObjectRequest)) } return interceptor(ctx, in, info, handler) } -func _Filter_UpdateObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_UpdateObject_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Update_ObjectRequest) if err := dec(in); err != nil { return nil, err @@ -492,13 +552,13 @@ func _Filter_UpdateObject_Handler(srv interface{}, ctx context.Context, dec func Server: srv, FullMethod: "/vald.v1.Filter/UpdateObject", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).UpdateObject(ctx, req.(*payload.Update_ObjectRequest)) } return interceptor(ctx, in, info, handler) } -func _Filter_StreamUpdateObject_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Filter_StreamUpdateObject_Handler(srv any, stream grpc.ServerStream) error { return srv.(FilterServer).StreamUpdateObject(&filterStreamUpdateObjectServer{stream}) } @@ -524,7 +584,9 @@ func (x *filterStreamUpdateObjectServer) Recv() (*payload.Update_ObjectRequest, return m, nil } -func _Filter_MultiUpdateObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_MultiUpdateObject_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Update_MultiObjectRequest) if err := dec(in); err != nil { return nil, err @@ -536,13 +598,15 @@ func _Filter_MultiUpdateObject_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/vald.v1.Filter/MultiUpdateObject", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).MultiUpdateObject(ctx, req.(*payload.Update_MultiObjectRequest)) } return interceptor(ctx, in, info, handler) } -func _Filter_UpsertObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_UpsertObject_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Upsert_ObjectRequest) if err := dec(in); err != nil { return nil, err @@ -554,13 +618,13 @@ func _Filter_UpsertObject_Handler(srv interface{}, ctx context.Context, dec func Server: srv, FullMethod: "/vald.v1.Filter/UpsertObject", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).UpsertObject(ctx, req.(*payload.Upsert_ObjectRequest)) } return interceptor(ctx, in, info, handler) } -func _Filter_StreamUpsertObject_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Filter_StreamUpsertObject_Handler(srv any, stream grpc.ServerStream) error { return srv.(FilterServer).StreamUpsertObject(&filterStreamUpsertObjectServer{stream}) } @@ -586,7 +650,9 @@ func (x *filterStreamUpsertObjectServer) Recv() (*payload.Upsert_ObjectRequest, return m, nil } -func _Filter_MultiUpsertObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Filter_MultiUpsertObject_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Upsert_MultiObjectRequest) if err := dec(in); err != nil { return nil, err @@ -598,7 +664,7 @@ func _Filter_MultiUpsertObject_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/vald.v1.Filter/MultiUpsertObject", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FilterServer).MultiUpsertObject(ctx, req.(*payload.Upsert_MultiObjectRequest)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/vald/flush.pb.go b/apis/grpc/v1/vald/flush.pb.go index a2afd36491..282dbd0590 100644 --- a/apis/grpc/v1/vald/flush.pb.go +++ b/apis/grpc/v1/vald/flush.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/vald/flush.proto @@ -60,10 +60,11 @@ var file_v1_vald_flush_proto_rawDesc = []byte{ 0x2f, 0x76, 0x61, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_vald_flush_proto_goTypes = []interface{}{ +var file_v1_vald_flush_proto_goTypes = []any{ (*payload.Flush_Request)(nil), // 0: payload.v1.Flush.Request (*payload.Info_Index_Count)(nil), // 1: payload.v1.Info.Index.Count } + var file_v1_vald_flush_proto_depIdxs = []int32{ 0, // 0: vald.v1.Flush.Flush:input_type -> payload.v1.Flush.Request 1, // 1: vald.v1.Flush.Flush:output_type -> payload.v1.Info.Index.Count diff --git a/apis/grpc/v1/vald/flush_vtproto.pb.go b/apis/grpc/v1/vald/flush_vtproto.pb.go index e4ed9aeffc..fd1978bec8 100644 --- a/apis/grpc/v1/vald/flush_vtproto.pb.go +++ b/apis/grpc/v1/vald/flush_vtproto.pb.go @@ -54,7 +54,9 @@ func NewFlushClient(cc grpc.ClientConnInterface) FlushClient { return &flushClient{cc} } -func (c *flushClient) Flush(ctx context.Context, in *payload.Flush_Request, opts ...grpc.CallOption) (*payload.Info_Index_Count, error) { +func (c *flushClient) Flush( + ctx context.Context, in *payload.Flush_Request, opts ...grpc.CallOption, +) (*payload.Info_Index_Count, error) { out := new(payload.Info_Index_Count) err := c.cc.Invoke(ctx, "/vald.v1.Flush/Flush", in, out, opts...) if err != nil { @@ -73,10 +75,11 @@ type FlushServer interface { } // UnimplementedFlushServer must be embedded to have forward compatible implementations. -type UnimplementedFlushServer struct { -} +type UnimplementedFlushServer struct{} -func (UnimplementedFlushServer) Flush(context.Context, *payload.Flush_Request) (*payload.Info_Index_Count, error) { +func (UnimplementedFlushServer) Flush( + context.Context, *payload.Flush_Request, +) (*payload.Info_Index_Count, error) { return nil, status.Errorf(codes.Unimplemented, "method Flush not implemented") } func (UnimplementedFlushServer) mustEmbedUnimplementedFlushServer() {} @@ -92,7 +95,9 @@ func RegisterFlushServer(s grpc.ServiceRegistrar, srv FlushServer) { s.RegisterService(&Flush_ServiceDesc, srv) } -func _Flush_Flush_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Flush_Flush_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Flush_Request) if err := dec(in); err != nil { return nil, err @@ -104,7 +109,7 @@ func _Flush_Flush_Handler(srv interface{}, ctx context.Context, dec func(interfa Server: srv, FullMethod: "/vald.v1.Flush/Flush", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(FlushServer).Flush(ctx, req.(*payload.Flush_Request)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/vald/index.pb.go b/apis/grpc/v1/vald/index.pb.go new file mode 100644 index 0000000000..46cef675f7 --- /dev/null +++ b/apis/grpc/v1/vald/index.pb.go @@ -0,0 +1,129 @@ +// +// 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. +// + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: v1/vald/index.proto + +package vald + +import ( + reflect "reflect" + + payload "github.com/vdaas/vald/apis/grpc/v1/payload" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var File_v1_vald_index_proto protoreflect.FileDescriptor + +var file_v1_vald_index_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x76, 0x31, 0x2f, 0x76, 0x61, 0x6c, 0x64, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x76, 0x61, 0x6c, 0x64, 0x2e, 0x76, 0x31, 0x1a, 0x1c, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x76, 0x31, + 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x8d, 0x03, 0x0a, 0x05, 0x49, 0x6e, 0x64, 0x65, 0x78, + 0x12, 0x51, 0x0a, 0x09, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x11, 0x2e, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x1a, 0x1c, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, + 0x66, 0x6f, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x12, 0x0b, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x69, + 0x6e, 0x66, 0x6f, 0x12, 0x56, 0x0a, 0x0b, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x44, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x12, 0x11, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1d, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, + 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x62, 0x0a, 0x0f, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x12, 0x11, + 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x1a, 0x21, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, + 0x6e, 0x66, 0x6f, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, + 0x74, 0x69, 0x63, 0x73, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x12, + 0x75, 0x0a, 0x15, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, + 0x63, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x11, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x27, 0x2e, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x12, 0x18, 0x2f, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x2f, + 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x42, 0x52, 0x0a, 0x1a, 0x6f, 0x72, 0x67, 0x2e, 0x76, 0x64, + 0x61, 0x61, 0x73, 0x2e, 0x76, 0x61, 0x6c, 0x64, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x76, 0x61, 0x6c, 0x64, 0x42, 0x09, 0x56, 0x61, 0x6c, 0x64, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x50, + 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x64, + 0x61, 0x61, 0x73, 0x2f, 0x76, 0x61, 0x6c, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x61, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var file_v1_vald_index_proto_goTypes = []any{ + (*payload.Empty)(nil), // 0: payload.v1.Empty + (*payload.Info_Index_Count)(nil), // 1: payload.v1.Info.Index.Count + (*payload.Info_Index_Detail)(nil), // 2: payload.v1.Info.Index.Detail + (*payload.Info_Index_Statistics)(nil), // 3: payload.v1.Info.Index.Statistics + (*payload.Info_Index_StatisticsDetail)(nil), // 4: payload.v1.Info.Index.StatisticsDetail +} + +var file_v1_vald_index_proto_depIdxs = []int32{ + 0, // 0: vald.v1.Index.IndexInfo:input_type -> payload.v1.Empty + 0, // 1: vald.v1.Index.IndexDetail:input_type -> payload.v1.Empty + 0, // 2: vald.v1.Index.IndexStatistics:input_type -> payload.v1.Empty + 0, // 3: vald.v1.Index.IndexStatisticsDetail:input_type -> payload.v1.Empty + 1, // 4: vald.v1.Index.IndexInfo:output_type -> payload.v1.Info.Index.Count + 2, // 5: vald.v1.Index.IndexDetail:output_type -> payload.v1.Info.Index.Detail + 3, // 6: vald.v1.Index.IndexStatistics:output_type -> payload.v1.Info.Index.Statistics + 4, // 7: vald.v1.Index.IndexStatisticsDetail:output_type -> payload.v1.Info.Index.StatisticsDetail + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_v1_vald_index_proto_init() } +func file_v1_vald_index_proto_init() { + if File_v1_vald_index_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_v1_vald_index_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_v1_vald_index_proto_goTypes, + DependencyIndexes: file_v1_vald_index_proto_depIdxs, + }.Build() + File_v1_vald_index_proto = out.File + file_v1_vald_index_proto_rawDesc = nil + file_v1_vald_index_proto_goTypes = nil + file_v1_vald_index_proto_depIdxs = nil +} diff --git a/apis/grpc/v1/vald/index_vtproto.pb.go b/apis/grpc/v1/vald/index_vtproto.pb.go new file mode 100644 index 0000000000..cda0a74ab3 --- /dev/null +++ b/apis/grpc/v1/vald/index_vtproto.pb.go @@ -0,0 +1,267 @@ +// +// 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 vald + +import ( + context "context" + + payload "github.com/vdaas/vald/apis/grpc/v1/payload" + codes "github.com/vdaas/vald/internal/net/grpc/codes" + status "github.com/vdaas/vald/internal/net/grpc/status" + grpc "google.golang.org/grpc" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// IndexClient is the client API for Index service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type IndexClient interface { + // Represent the RPC to get the index information. + IndexInfo(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Count, error) + // Represent the RPC to get the index information for each agents. + IndexDetail(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Detail, error) + // Represent the RPC to get the index statistics. + IndexStatistics(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Statistics, error) + // Represent the RPC to get the index statistics for each agents. + IndexStatisticsDetail(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_StatisticsDetail, error) +} + +type indexClient struct { + cc grpc.ClientConnInterface +} + +func NewIndexClient(cc grpc.ClientConnInterface) IndexClient { + return &indexClient{cc} +} + +func (c *indexClient) IndexInfo( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (*payload.Info_Index_Count, error) { + out := new(payload.Info_Index_Count) + err := c.cc.Invoke(ctx, "/vald.v1.Index/IndexInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *indexClient) IndexDetail( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (*payload.Info_Index_Detail, error) { + out := new(payload.Info_Index_Detail) + err := c.cc.Invoke(ctx, "/vald.v1.Index/IndexDetail", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *indexClient) IndexStatistics( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (*payload.Info_Index_Statistics, error) { + out := new(payload.Info_Index_Statistics) + err := c.cc.Invoke(ctx, "/vald.v1.Index/IndexStatistics", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *indexClient) IndexStatisticsDetail( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (*payload.Info_Index_StatisticsDetail, error) { + out := new(payload.Info_Index_StatisticsDetail) + err := c.cc.Invoke(ctx, "/vald.v1.Index/IndexStatisticsDetail", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// IndexServer is the server API for Index service. +// All implementations must embed UnimplementedIndexServer +// for forward compatibility +type IndexServer interface { + // Represent the RPC to get the index information. + IndexInfo(context.Context, *payload.Empty) (*payload.Info_Index_Count, error) + // Represent the RPC to get the index information for each agents. + IndexDetail(context.Context, *payload.Empty) (*payload.Info_Index_Detail, error) + // Represent the RPC to get the index statistics. + IndexStatistics(context.Context, *payload.Empty) (*payload.Info_Index_Statistics, error) + // Represent the RPC to get the index statistics for each agents. + IndexStatisticsDetail(context.Context, *payload.Empty) (*payload.Info_Index_StatisticsDetail, error) + mustEmbedUnimplementedIndexServer() +} + +// UnimplementedIndexServer must be embedded to have forward compatible implementations. +type UnimplementedIndexServer struct{} + +func (UnimplementedIndexServer) IndexInfo( + context.Context, *payload.Empty, +) (*payload.Info_Index_Count, error) { + return nil, status.Errorf(codes.Unimplemented, "method IndexInfo not implemented") +} + +func (UnimplementedIndexServer) IndexDetail( + context.Context, *payload.Empty, +) (*payload.Info_Index_Detail, error) { + return nil, status.Errorf(codes.Unimplemented, "method IndexDetail not implemented") +} + +func (UnimplementedIndexServer) IndexStatistics( + context.Context, *payload.Empty, +) (*payload.Info_Index_Statistics, error) { + return nil, status.Errorf(codes.Unimplemented, "method IndexStatistics not implemented") +} + +func (UnimplementedIndexServer) IndexStatisticsDetail( + context.Context, *payload.Empty, +) (*payload.Info_Index_StatisticsDetail, error) { + return nil, status.Errorf(codes.Unimplemented, "method IndexStatisticsDetail not implemented") +} +func (UnimplementedIndexServer) mustEmbedUnimplementedIndexServer() {} + +// UnsafeIndexServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to IndexServer will +// result in compilation errors. +type UnsafeIndexServer interface { + mustEmbedUnimplementedIndexServer() +} + +func RegisterIndexServer(s grpc.ServiceRegistrar, srv IndexServer) { + s.RegisterService(&Index_ServiceDesc, srv) +} + +func _Index_IndexInfo_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { + in := new(payload.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IndexServer).IndexInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vald.v1.Index/IndexInfo", + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(IndexServer).IndexInfo(ctx, req.(*payload.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _Index_IndexDetail_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { + in := new(payload.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IndexServer).IndexDetail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vald.v1.Index/IndexDetail", + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(IndexServer).IndexDetail(ctx, req.(*payload.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _Index_IndexStatistics_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { + in := new(payload.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IndexServer).IndexStatistics(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vald.v1.Index/IndexStatistics", + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(IndexServer).IndexStatistics(ctx, req.(*payload.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _Index_IndexStatisticsDetail_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { + in := new(payload.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IndexServer).IndexStatisticsDetail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vald.v1.Index/IndexStatisticsDetail", + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(IndexServer).IndexStatisticsDetail(ctx, req.(*payload.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +// Index_ServiceDesc is the grpc.ServiceDesc for Index service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Index_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "vald.v1.Index", + HandlerType: (*IndexServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "IndexInfo", + Handler: _Index_IndexInfo_Handler, + }, + { + MethodName: "IndexDetail", + Handler: _Index_IndexDetail_Handler, + }, + { + MethodName: "IndexStatistics", + Handler: _Index_IndexStatistics_Handler, + }, + { + MethodName: "IndexStatisticsDetail", + Handler: _Index_IndexStatisticsDetail_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "v1/vald/index.proto", +} diff --git a/apis/grpc/v1/vald/insert.pb.go b/apis/grpc/v1/vald/insert.pb.go index 8a5f6997f6..26f4a05fe7 100644 --- a/apis/grpc/v1/vald/insert.pb.go +++ b/apis/grpc/v1/vald/insert.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/vald/insert.proto @@ -73,13 +73,14 @@ var file_v1_vald_insert_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_vald_insert_proto_goTypes = []interface{}{ +var file_v1_vald_insert_proto_goTypes = []any{ (*payload.Insert_Request)(nil), // 0: payload.v1.Insert.Request (*payload.Insert_MultiRequest)(nil), // 1: payload.v1.Insert.MultiRequest (*payload.Object_Location)(nil), // 2: payload.v1.Object.Location (*payload.Object_StreamLocation)(nil), // 3: payload.v1.Object.StreamLocation (*payload.Object_Locations)(nil), // 4: payload.v1.Object.Locations } + var file_v1_vald_insert_proto_depIdxs = []int32{ 0, // 0: vald.v1.Insert.Insert:input_type -> payload.v1.Insert.Request 0, // 1: vald.v1.Insert.StreamInsert:input_type -> payload.v1.Insert.Request diff --git a/apis/grpc/v1/vald/insert_vtproto.pb.go b/apis/grpc/v1/vald/insert_vtproto.pb.go index e24279f226..4adde0acb5 100644 --- a/apis/grpc/v1/vald/insert_vtproto.pb.go +++ b/apis/grpc/v1/vald/insert_vtproto.pb.go @@ -58,7 +58,9 @@ func NewInsertClient(cc grpc.ClientConnInterface) InsertClient { return &insertClient{cc} } -func (c *insertClient) Insert(ctx context.Context, in *payload.Insert_Request, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (c *insertClient) Insert( + ctx context.Context, in *payload.Insert_Request, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { out := new(payload.Object_Location) err := c.cc.Invoke(ctx, "/vald.v1.Insert/Insert", in, out, opts...) if err != nil { @@ -67,7 +69,9 @@ func (c *insertClient) Insert(ctx context.Context, in *payload.Insert_Request, o return out, nil } -func (c *insertClient) StreamInsert(ctx context.Context, opts ...grpc.CallOption) (Insert_StreamInsertClient, error) { +func (c *insertClient) StreamInsert( + ctx context.Context, opts ...grpc.CallOption, +) (Insert_StreamInsertClient, error) { stream, err := c.cc.NewStream(ctx, &Insert_ServiceDesc.Streams[0], "/vald.v1.Insert/StreamInsert", opts...) if err != nil { return nil, err @@ -98,7 +102,9 @@ func (x *insertStreamInsertClient) Recv() (*payload.Object_StreamLocation, error return m, nil } -func (c *insertClient) MultiInsert(ctx context.Context, in *payload.Insert_MultiRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) { +func (c *insertClient) MultiInsert( + ctx context.Context, in *payload.Insert_MultiRequest, opts ...grpc.CallOption, +) (*payload.Object_Locations, error) { out := new(payload.Object_Locations) err := c.cc.Invoke(ctx, "/vald.v1.Insert/MultiInsert", in, out, opts...) if err != nil { @@ -121,16 +127,21 @@ type InsertServer interface { } // UnimplementedInsertServer must be embedded to have forward compatible implementations. -type UnimplementedInsertServer struct { -} +type UnimplementedInsertServer struct{} -func (UnimplementedInsertServer) Insert(context.Context, *payload.Insert_Request) (*payload.Object_Location, error) { +func (UnimplementedInsertServer) Insert( + context.Context, *payload.Insert_Request, +) (*payload.Object_Location, error) { return nil, status.Errorf(codes.Unimplemented, "method Insert not implemented") } + func (UnimplementedInsertServer) StreamInsert(Insert_StreamInsertServer) error { return status.Errorf(codes.Unimplemented, "method StreamInsert not implemented") } -func (UnimplementedInsertServer) MultiInsert(context.Context, *payload.Insert_MultiRequest) (*payload.Object_Locations, error) { + +func (UnimplementedInsertServer) MultiInsert( + context.Context, *payload.Insert_MultiRequest, +) (*payload.Object_Locations, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiInsert not implemented") } func (UnimplementedInsertServer) mustEmbedUnimplementedInsertServer() {} @@ -146,7 +157,9 @@ func RegisterInsertServer(s grpc.ServiceRegistrar, srv InsertServer) { s.RegisterService(&Insert_ServiceDesc, srv) } -func _Insert_Insert_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Insert_Insert_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Insert_Request) if err := dec(in); err != nil { return nil, err @@ -158,13 +171,13 @@ func _Insert_Insert_Handler(srv interface{}, ctx context.Context, dec func(inter Server: srv, FullMethod: "/vald.v1.Insert/Insert", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(InsertServer).Insert(ctx, req.(*payload.Insert_Request)) } return interceptor(ctx, in, info, handler) } -func _Insert_StreamInsert_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Insert_StreamInsert_Handler(srv any, stream grpc.ServerStream) error { return srv.(InsertServer).StreamInsert(&insertStreamInsertServer{stream}) } @@ -190,7 +203,9 @@ func (x *insertStreamInsertServer) Recv() (*payload.Insert_Request, error) { return m, nil } -func _Insert_MultiInsert_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Insert_MultiInsert_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Insert_MultiRequest) if err := dec(in); err != nil { return nil, err @@ -202,7 +217,7 @@ func _Insert_MultiInsert_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/vald.v1.Insert/MultiInsert", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(InsertServer).MultiInsert(ctx, req.(*payload.Insert_MultiRequest)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/vald/object.pb.go b/apis/grpc/v1/vald/object.pb.go index 9730bfff6a..f911467104 100644 --- a/apis/grpc/v1/vald/object.pb.go +++ b/apis/grpc/v1/vald/object.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/vald/object.proto @@ -46,7 +46,7 @@ var file_v1_vald_object_proto_rawDesc = []byte{ 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x84, 0x03, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, + 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xf5, 0x03, 0x0a, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x4c, 0x0a, 0x06, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x12, 0x15, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x49, 0x44, 0x1a, 0x15, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, @@ -70,34 +70,46 @@ var file_v1_vald_object_proto_rawDesc = []byte{ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x12, 0x0c, - 0x2f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x01, 0x42, 0x53, - 0x0a, 0x1a, 0x6f, 0x72, 0x67, 0x2e, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2e, 0x76, 0x61, 0x6c, 0x64, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x76, 0x61, 0x6c, 0x64, 0x42, 0x0a, 0x56, 0x61, - 0x6c, 0x64, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2f, 0x76, 0x61, 0x6c, - 0x64, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x76, - 0x61, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x01, 0x12, 0x6f, + 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x23, + 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x76, 0x31, + 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x6f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x2f, 0x7b, 0x69, 0x64, 0x2e, 0x69, 0x64, 0x7d, 0x42, + 0x53, 0x0a, 0x1a, 0x6f, 0x72, 0x67, 0x2e, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2e, 0x76, 0x61, 0x6c, + 0x64, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x76, 0x61, 0x6c, 0x64, 0x42, 0x0a, 0x56, + 0x61, 0x6c, 0x64, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x64, 0x61, 0x61, 0x73, 0x2f, 0x76, 0x61, + 0x6c, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x2f, + 0x76, 0x61, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_vald_object_proto_goTypes = []interface{}{ - (*payload.Object_ID)(nil), // 0: payload.v1.Object.ID - (*payload.Object_VectorRequest)(nil), // 1: payload.v1.Object.VectorRequest - (*payload.Object_List_Request)(nil), // 2: payload.v1.Object.List.Request - (*payload.Object_Vector)(nil), // 3: payload.v1.Object.Vector - (*payload.Object_StreamVector)(nil), // 4: payload.v1.Object.StreamVector - (*payload.Object_List_Response)(nil), // 5: payload.v1.Object.List.Response +var file_v1_vald_object_proto_goTypes = []any{ + (*payload.Object_ID)(nil), // 0: payload.v1.Object.ID + (*payload.Object_VectorRequest)(nil), // 1: payload.v1.Object.VectorRequest + (*payload.Object_List_Request)(nil), // 2: payload.v1.Object.List.Request + (*payload.Object_TimestampRequest)(nil), // 3: payload.v1.Object.TimestampRequest + (*payload.Object_Vector)(nil), // 4: payload.v1.Object.Vector + (*payload.Object_StreamVector)(nil), // 5: payload.v1.Object.StreamVector + (*payload.Object_List_Response)(nil), // 6: payload.v1.Object.List.Response + (*payload.Object_Timestamp)(nil), // 7: payload.v1.Object.Timestamp } + var file_v1_vald_object_proto_depIdxs = []int32{ 0, // 0: vald.v1.Object.Exists:input_type -> payload.v1.Object.ID 1, // 1: vald.v1.Object.GetObject:input_type -> payload.v1.Object.VectorRequest 1, // 2: vald.v1.Object.StreamGetObject:input_type -> payload.v1.Object.VectorRequest 2, // 3: vald.v1.Object.StreamListObject:input_type -> payload.v1.Object.List.Request - 0, // 4: vald.v1.Object.Exists:output_type -> payload.v1.Object.ID - 3, // 5: vald.v1.Object.GetObject:output_type -> payload.v1.Object.Vector - 4, // 6: vald.v1.Object.StreamGetObject:output_type -> payload.v1.Object.StreamVector - 5, // 7: vald.v1.Object.StreamListObject:output_type -> payload.v1.Object.List.Response - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] is the sub-list for method input_type + 3, // 4: vald.v1.Object.GetTimestamp:input_type -> payload.v1.Object.TimestampRequest + 0, // 5: vald.v1.Object.Exists:output_type -> payload.v1.Object.ID + 4, // 6: vald.v1.Object.GetObject:output_type -> payload.v1.Object.Vector + 5, // 7: vald.v1.Object.StreamGetObject:output_type -> payload.v1.Object.StreamVector + 6, // 8: vald.v1.Object.StreamListObject:output_type -> payload.v1.Object.List.Response + 7, // 9: vald.v1.Object.GetTimestamp:output_type -> payload.v1.Object.Timestamp + 5, // [5:10] is the sub-list for method output_type + 0, // [0:5] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name diff --git a/apis/grpc/v1/vald/object_vtproto.pb.go b/apis/grpc/v1/vald/object_vtproto.pb.go index 3f55828829..1df7b6eadf 100644 --- a/apis/grpc/v1/vald/object_vtproto.pb.go +++ b/apis/grpc/v1/vald/object_vtproto.pb.go @@ -50,6 +50,8 @@ type ObjectClient interface { StreamGetObject(ctx context.Context, opts ...grpc.CallOption) (Object_StreamGetObjectClient, error) // A method to get all the vectors with server streaming StreamListObject(ctx context.Context, in *payload.Object_List_Request, opts ...grpc.CallOption) (Object_StreamListObjectClient, error) + // Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process + GetTimestamp(ctx context.Context, in *payload.Object_TimestampRequest, opts ...grpc.CallOption) (*payload.Object_Timestamp, error) } type objectClient struct { @@ -60,7 +62,9 @@ func NewObjectClient(cc grpc.ClientConnInterface) ObjectClient { return &objectClient{cc} } -func (c *objectClient) Exists(ctx context.Context, in *payload.Object_ID, opts ...grpc.CallOption) (*payload.Object_ID, error) { +func (c *objectClient) Exists( + ctx context.Context, in *payload.Object_ID, opts ...grpc.CallOption, +) (*payload.Object_ID, error) { out := new(payload.Object_ID) err := c.cc.Invoke(ctx, "/vald.v1.Object/Exists", in, out, opts...) if err != nil { @@ -69,7 +73,9 @@ func (c *objectClient) Exists(ctx context.Context, in *payload.Object_ID, opts . return out, nil } -func (c *objectClient) GetObject(ctx context.Context, in *payload.Object_VectorRequest, opts ...grpc.CallOption) (*payload.Object_Vector, error) { +func (c *objectClient) GetObject( + ctx context.Context, in *payload.Object_VectorRequest, opts ...grpc.CallOption, +) (*payload.Object_Vector, error) { out := new(payload.Object_Vector) err := c.cc.Invoke(ctx, "/vald.v1.Object/GetObject", in, out, opts...) if err != nil { @@ -78,7 +84,9 @@ func (c *objectClient) GetObject(ctx context.Context, in *payload.Object_VectorR return out, nil } -func (c *objectClient) StreamGetObject(ctx context.Context, opts ...grpc.CallOption) (Object_StreamGetObjectClient, error) { +func (c *objectClient) StreamGetObject( + ctx context.Context, opts ...grpc.CallOption, +) (Object_StreamGetObjectClient, error) { stream, err := c.cc.NewStream(ctx, &Object_ServiceDesc.Streams[0], "/vald.v1.Object/StreamGetObject", opts...) if err != nil { return nil, err @@ -109,7 +117,9 @@ func (x *objectStreamGetObjectClient) Recv() (*payload.Object_StreamVector, erro return m, nil } -func (c *objectClient) StreamListObject(ctx context.Context, in *payload.Object_List_Request, opts ...grpc.CallOption) (Object_StreamListObjectClient, error) { +func (c *objectClient) StreamListObject( + ctx context.Context, in *payload.Object_List_Request, opts ...grpc.CallOption, +) (Object_StreamListObjectClient, error) { stream, err := c.cc.NewStream(ctx, &Object_ServiceDesc.Streams[1], "/vald.v1.Object/StreamListObject", opts...) if err != nil { return nil, err @@ -141,6 +151,17 @@ func (x *objectStreamListObjectClient) Recv() (*payload.Object_List_Response, er return m, nil } +func (c *objectClient) GetTimestamp( + ctx context.Context, in *payload.Object_TimestampRequest, opts ...grpc.CallOption, +) (*payload.Object_Timestamp, error) { + out := new(payload.Object_Timestamp) + err := c.cc.Invoke(ctx, "/vald.v1.Object/GetTimestamp", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ObjectServer is the server API for Object service. // All implementations must embed UnimplementedObjectServer // for forward compatibility @@ -153,25 +174,41 @@ type ObjectServer interface { StreamGetObject(Object_StreamGetObjectServer) error // A method to get all the vectors with server streaming StreamListObject(*payload.Object_List_Request, Object_StreamListObjectServer) error + // Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process + GetTimestamp(context.Context, *payload.Object_TimestampRequest) (*payload.Object_Timestamp, error) mustEmbedUnimplementedObjectServer() } // UnimplementedObjectServer must be embedded to have forward compatible implementations. -type UnimplementedObjectServer struct { -} +type UnimplementedObjectServer struct{} -func (UnimplementedObjectServer) Exists(context.Context, *payload.Object_ID) (*payload.Object_ID, error) { +func (UnimplementedObjectServer) Exists( + context.Context, *payload.Object_ID, +) (*payload.Object_ID, error) { return nil, status.Errorf(codes.Unimplemented, "method Exists not implemented") } -func (UnimplementedObjectServer) GetObject(context.Context, *payload.Object_VectorRequest) (*payload.Object_Vector, error) { + +func (UnimplementedObjectServer) GetObject( + context.Context, *payload.Object_VectorRequest, +) (*payload.Object_Vector, error) { return nil, status.Errorf(codes.Unimplemented, "method GetObject not implemented") } + func (UnimplementedObjectServer) StreamGetObject(Object_StreamGetObjectServer) error { return status.Errorf(codes.Unimplemented, "method StreamGetObject not implemented") } -func (UnimplementedObjectServer) StreamListObject(*payload.Object_List_Request, Object_StreamListObjectServer) error { + +func (UnimplementedObjectServer) StreamListObject( + *payload.Object_List_Request, Object_StreamListObjectServer, +) error { return status.Errorf(codes.Unimplemented, "method StreamListObject not implemented") } + +func (UnimplementedObjectServer) GetTimestamp( + context.Context, *payload.Object_TimestampRequest, +) (*payload.Object_Timestamp, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTimestamp not implemented") +} func (UnimplementedObjectServer) mustEmbedUnimplementedObjectServer() {} // UnsafeObjectServer may be embedded to opt out of forward compatibility for this service. @@ -185,7 +222,9 @@ func RegisterObjectServer(s grpc.ServiceRegistrar, srv ObjectServer) { s.RegisterService(&Object_ServiceDesc, srv) } -func _Object_Exists_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Object_Exists_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Object_ID) if err := dec(in); err != nil { return nil, err @@ -197,13 +236,15 @@ func _Object_Exists_Handler(srv interface{}, ctx context.Context, dec func(inter Server: srv, FullMethod: "/vald.v1.Object/Exists", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ObjectServer).Exists(ctx, req.(*payload.Object_ID)) } return interceptor(ctx, in, info, handler) } -func _Object_GetObject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Object_GetObject_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Object_VectorRequest) if err := dec(in); err != nil { return nil, err @@ -215,13 +256,13 @@ func _Object_GetObject_Handler(srv interface{}, ctx context.Context, dec func(in Server: srv, FullMethod: "/vald.v1.Object/GetObject", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ObjectServer).GetObject(ctx, req.(*payload.Object_VectorRequest)) } return interceptor(ctx, in, info, handler) } -func _Object_StreamGetObject_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Object_StreamGetObject_Handler(srv any, stream grpc.ServerStream) error { return srv.(ObjectServer).StreamGetObject(&objectStreamGetObjectServer{stream}) } @@ -247,7 +288,7 @@ func (x *objectStreamGetObjectServer) Recv() (*payload.Object_VectorRequest, err return m, nil } -func _Object_StreamListObject_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Object_StreamListObject_Handler(srv any, stream grpc.ServerStream) error { m := new(payload.Object_List_Request) if err := stream.RecvMsg(m); err != nil { return err @@ -268,6 +309,26 @@ func (x *objectStreamListObjectServer) Send(m *payload.Object_List_Response) err return x.ServerStream.SendMsg(m) } +func _Object_GetTimestamp_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { + in := new(payload.Object_TimestampRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ObjectServer).GetTimestamp(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vald.v1.Object/GetTimestamp", + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(ObjectServer).GetTimestamp(ctx, req.(*payload.Object_TimestampRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Object_ServiceDesc is the grpc.ServiceDesc for Object service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -283,6 +344,10 @@ var Object_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetObject", Handler: _Object_GetObject_Handler, }, + { + MethodName: "GetTimestamp", + Handler: _Object_GetTimestamp_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/apis/grpc/v1/vald/remove.pb.go b/apis/grpc/v1/vald/remove.pb.go index 1e16f2f3b8..cf58d5f1eb 100644 --- a/apis/grpc/v1/vald/remove.pb.go +++ b/apis/grpc/v1/vald/remove.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/vald/remove.proto @@ -80,7 +80,7 @@ var file_v1_vald_remove_proto_rawDesc = []byte{ 0x76, 0x61, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_vald_remove_proto_goTypes = []interface{}{ +var file_v1_vald_remove_proto_goTypes = []any{ (*payload.Remove_Request)(nil), // 0: payload.v1.Remove.Request (*payload.Remove_TimestampRequest)(nil), // 1: payload.v1.Remove.TimestampRequest (*payload.Remove_MultiRequest)(nil), // 2: payload.v1.Remove.MultiRequest @@ -88,6 +88,7 @@ var file_v1_vald_remove_proto_goTypes = []interface{}{ (*payload.Object_Locations)(nil), // 4: payload.v1.Object.Locations (*payload.Object_StreamLocation)(nil), // 5: payload.v1.Object.StreamLocation } + var file_v1_vald_remove_proto_depIdxs = []int32{ 0, // 0: vald.v1.Remove.Remove:input_type -> payload.v1.Remove.Request 1, // 1: vald.v1.Remove.RemoveByTimestamp:input_type -> payload.v1.Remove.TimestampRequest diff --git a/apis/grpc/v1/vald/remove_vtproto.pb.go b/apis/grpc/v1/vald/remove_vtproto.pb.go index 8355ebab10..68219d9faa 100644 --- a/apis/grpc/v1/vald/remove_vtproto.pb.go +++ b/apis/grpc/v1/vald/remove_vtproto.pb.go @@ -60,7 +60,9 @@ func NewRemoveClient(cc grpc.ClientConnInterface) RemoveClient { return &removeClient{cc} } -func (c *removeClient) Remove(ctx context.Context, in *payload.Remove_Request, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (c *removeClient) Remove( + ctx context.Context, in *payload.Remove_Request, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { out := new(payload.Object_Location) err := c.cc.Invoke(ctx, "/vald.v1.Remove/Remove", in, out, opts...) if err != nil { @@ -69,7 +71,9 @@ func (c *removeClient) Remove(ctx context.Context, in *payload.Remove_Request, o return out, nil } -func (c *removeClient) RemoveByTimestamp(ctx context.Context, in *payload.Remove_TimestampRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) { +func (c *removeClient) RemoveByTimestamp( + ctx context.Context, in *payload.Remove_TimestampRequest, opts ...grpc.CallOption, +) (*payload.Object_Locations, error) { out := new(payload.Object_Locations) err := c.cc.Invoke(ctx, "/vald.v1.Remove/RemoveByTimestamp", in, out, opts...) if err != nil { @@ -78,7 +82,9 @@ func (c *removeClient) RemoveByTimestamp(ctx context.Context, in *payload.Remove return out, nil } -func (c *removeClient) StreamRemove(ctx context.Context, opts ...grpc.CallOption) (Remove_StreamRemoveClient, error) { +func (c *removeClient) StreamRemove( + ctx context.Context, opts ...grpc.CallOption, +) (Remove_StreamRemoveClient, error) { stream, err := c.cc.NewStream(ctx, &Remove_ServiceDesc.Streams[0], "/vald.v1.Remove/StreamRemove", opts...) if err != nil { return nil, err @@ -109,7 +115,9 @@ func (x *removeStreamRemoveClient) Recv() (*payload.Object_StreamLocation, error return m, nil } -func (c *removeClient) MultiRemove(ctx context.Context, in *payload.Remove_MultiRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) { +func (c *removeClient) MultiRemove( + ctx context.Context, in *payload.Remove_MultiRequest, opts ...grpc.CallOption, +) (*payload.Object_Locations, error) { out := new(payload.Object_Locations) err := c.cc.Invoke(ctx, "/vald.v1.Remove/MultiRemove", in, out, opts...) if err != nil { @@ -134,19 +142,27 @@ type RemoveServer interface { } // UnimplementedRemoveServer must be embedded to have forward compatible implementations. -type UnimplementedRemoveServer struct { -} +type UnimplementedRemoveServer struct{} -func (UnimplementedRemoveServer) Remove(context.Context, *payload.Remove_Request) (*payload.Object_Location, error) { +func (UnimplementedRemoveServer) Remove( + context.Context, *payload.Remove_Request, +) (*payload.Object_Location, error) { return nil, status.Errorf(codes.Unimplemented, "method Remove not implemented") } -func (UnimplementedRemoveServer) RemoveByTimestamp(context.Context, *payload.Remove_TimestampRequest) (*payload.Object_Locations, error) { + +func (UnimplementedRemoveServer) RemoveByTimestamp( + context.Context, *payload.Remove_TimestampRequest, +) (*payload.Object_Locations, error) { return nil, status.Errorf(codes.Unimplemented, "method RemoveByTimestamp not implemented") } + func (UnimplementedRemoveServer) StreamRemove(Remove_StreamRemoveServer) error { return status.Errorf(codes.Unimplemented, "method StreamRemove not implemented") } -func (UnimplementedRemoveServer) MultiRemove(context.Context, *payload.Remove_MultiRequest) (*payload.Object_Locations, error) { + +func (UnimplementedRemoveServer) MultiRemove( + context.Context, *payload.Remove_MultiRequest, +) (*payload.Object_Locations, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiRemove not implemented") } func (UnimplementedRemoveServer) mustEmbedUnimplementedRemoveServer() {} @@ -162,7 +178,9 @@ func RegisterRemoveServer(s grpc.ServiceRegistrar, srv RemoveServer) { s.RegisterService(&Remove_ServiceDesc, srv) } -func _Remove_Remove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Remove_Remove_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Remove_Request) if err := dec(in); err != nil { return nil, err @@ -174,13 +192,15 @@ func _Remove_Remove_Handler(srv interface{}, ctx context.Context, dec func(inter Server: srv, FullMethod: "/vald.v1.Remove/Remove", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(RemoveServer).Remove(ctx, req.(*payload.Remove_Request)) } return interceptor(ctx, in, info, handler) } -func _Remove_RemoveByTimestamp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Remove_RemoveByTimestamp_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Remove_TimestampRequest) if err := dec(in); err != nil { return nil, err @@ -192,13 +212,13 @@ func _Remove_RemoveByTimestamp_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/vald.v1.Remove/RemoveByTimestamp", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(RemoveServer).RemoveByTimestamp(ctx, req.(*payload.Remove_TimestampRequest)) } return interceptor(ctx, in, info, handler) } -func _Remove_StreamRemove_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Remove_StreamRemove_Handler(srv any, stream grpc.ServerStream) error { return srv.(RemoveServer).StreamRemove(&removeStreamRemoveServer{stream}) } @@ -224,7 +244,9 @@ func (x *removeStreamRemoveServer) Recv() (*payload.Remove_Request, error) { return m, nil } -func _Remove_MultiRemove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Remove_MultiRemove_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Remove_MultiRequest) if err := dec(in); err != nil { return nil, err @@ -236,7 +258,7 @@ func _Remove_MultiRemove_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/vald.v1.Remove/MultiRemove", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(RemoveServer).MultiRemove(ctx, req.(*payload.Remove_MultiRequest)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/vald/search.pb.go b/apis/grpc/v1/vald/search.pb.go index 960c0b5081..2577281aa7 100644 --- a/apis/grpc/v1/vald/search.pb.go +++ b/apis/grpc/v1/vald/search.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/vald/search.proto @@ -132,7 +132,7 @@ var file_v1_vald_search_proto_rawDesc = []byte{ 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_vald_search_proto_goTypes = []interface{}{ +var file_v1_vald_search_proto_goTypes = []any{ (*payload.Search_Request)(nil), // 0: payload.v1.Search.Request (*payload.Search_IDRequest)(nil), // 1: payload.v1.Search.IDRequest (*payload.Search_MultiRequest)(nil), // 2: payload.v1.Search.MultiRequest @@ -141,6 +141,7 @@ var file_v1_vald_search_proto_goTypes = []interface{}{ (*payload.Search_StreamResponse)(nil), // 5: payload.v1.Search.StreamResponse (*payload.Search_Responses)(nil), // 6: payload.v1.Search.Responses } + var file_v1_vald_search_proto_depIdxs = []int32{ 0, // 0: vald.v1.Search.Search:input_type -> payload.v1.Search.Request 1, // 1: vald.v1.Search.SearchByID:input_type -> payload.v1.Search.IDRequest diff --git a/apis/grpc/v1/vald/search_vtproto.pb.go b/apis/grpc/v1/vald/search_vtproto.pb.go index c75cd0b136..bf69c0fbba 100644 --- a/apis/grpc/v1/vald/search_vtproto.pb.go +++ b/apis/grpc/v1/vald/search_vtproto.pb.go @@ -78,7 +78,9 @@ func NewSearchClient(cc grpc.ClientConnInterface) SearchClient { return &searchClient{cc} } -func (c *searchClient) Search(ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption) (*payload.Search_Response, error) { +func (c *searchClient) Search( + ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption, +) (*payload.Search_Response, error) { out := new(payload.Search_Response) err := c.cc.Invoke(ctx, "/vald.v1.Search/Search", in, out, opts...) if err != nil { @@ -87,7 +89,9 @@ func (c *searchClient) Search(ctx context.Context, in *payload.Search_Request, o return out, nil } -func (c *searchClient) SearchByID(ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption) (*payload.Search_Response, error) { +func (c *searchClient) SearchByID( + ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption, +) (*payload.Search_Response, error) { out := new(payload.Search_Response) err := c.cc.Invoke(ctx, "/vald.v1.Search/SearchByID", in, out, opts...) if err != nil { @@ -96,7 +100,9 @@ func (c *searchClient) SearchByID(ctx context.Context, in *payload.Search_IDRequ return out, nil } -func (c *searchClient) StreamSearch(ctx context.Context, opts ...grpc.CallOption) (Search_StreamSearchClient, error) { +func (c *searchClient) StreamSearch( + ctx context.Context, opts ...grpc.CallOption, +) (Search_StreamSearchClient, error) { stream, err := c.cc.NewStream(ctx, &Search_ServiceDesc.Streams[0], "/vald.v1.Search/StreamSearch", opts...) if err != nil { return nil, err @@ -127,7 +133,9 @@ func (x *searchStreamSearchClient) Recv() (*payload.Search_StreamResponse, error return m, nil } -func (c *searchClient) StreamSearchByID(ctx context.Context, opts ...grpc.CallOption) (Search_StreamSearchByIDClient, error) { +func (c *searchClient) StreamSearchByID( + ctx context.Context, opts ...grpc.CallOption, +) (Search_StreamSearchByIDClient, error) { stream, err := c.cc.NewStream(ctx, &Search_ServiceDesc.Streams[1], "/vald.v1.Search/StreamSearchByID", opts...) if err != nil { return nil, err @@ -158,7 +166,9 @@ func (x *searchStreamSearchByIDClient) Recv() (*payload.Search_StreamResponse, e return m, nil } -func (c *searchClient) MultiSearch(ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption) (*payload.Search_Responses, error) { +func (c *searchClient) MultiSearch( + ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption, +) (*payload.Search_Responses, error) { out := new(payload.Search_Responses) err := c.cc.Invoke(ctx, "/vald.v1.Search/MultiSearch", in, out, opts...) if err != nil { @@ -167,7 +177,9 @@ func (c *searchClient) MultiSearch(ctx context.Context, in *payload.Search_Multi return out, nil } -func (c *searchClient) MultiSearchByID(ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption) (*payload.Search_Responses, error) { +func (c *searchClient) MultiSearchByID( + ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption, +) (*payload.Search_Responses, error) { out := new(payload.Search_Responses) err := c.cc.Invoke(ctx, "/vald.v1.Search/MultiSearchByID", in, out, opts...) if err != nil { @@ -176,7 +188,9 @@ func (c *searchClient) MultiSearchByID(ctx context.Context, in *payload.Search_M return out, nil } -func (c *searchClient) LinearSearch(ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption) (*payload.Search_Response, error) { +func (c *searchClient) LinearSearch( + ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption, +) (*payload.Search_Response, error) { out := new(payload.Search_Response) err := c.cc.Invoke(ctx, "/vald.v1.Search/LinearSearch", in, out, opts...) if err != nil { @@ -185,7 +199,9 @@ func (c *searchClient) LinearSearch(ctx context.Context, in *payload.Search_Requ return out, nil } -func (c *searchClient) LinearSearchByID(ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption) (*payload.Search_Response, error) { +func (c *searchClient) LinearSearchByID( + ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption, +) (*payload.Search_Response, error) { out := new(payload.Search_Response) err := c.cc.Invoke(ctx, "/vald.v1.Search/LinearSearchByID", in, out, opts...) if err != nil { @@ -194,7 +210,9 @@ func (c *searchClient) LinearSearchByID(ctx context.Context, in *payload.Search_ return out, nil } -func (c *searchClient) StreamLinearSearch(ctx context.Context, opts ...grpc.CallOption) (Search_StreamLinearSearchClient, error) { +func (c *searchClient) StreamLinearSearch( + ctx context.Context, opts ...grpc.CallOption, +) (Search_StreamLinearSearchClient, error) { stream, err := c.cc.NewStream(ctx, &Search_ServiceDesc.Streams[2], "/vald.v1.Search/StreamLinearSearch", opts...) if err != nil { return nil, err @@ -225,7 +243,9 @@ func (x *searchStreamLinearSearchClient) Recv() (*payload.Search_StreamResponse, return m, nil } -func (c *searchClient) StreamLinearSearchByID(ctx context.Context, opts ...grpc.CallOption) (Search_StreamLinearSearchByIDClient, error) { +func (c *searchClient) StreamLinearSearchByID( + ctx context.Context, opts ...grpc.CallOption, +) (Search_StreamLinearSearchByIDClient, error) { stream, err := c.cc.NewStream(ctx, &Search_ServiceDesc.Streams[3], "/vald.v1.Search/StreamLinearSearchByID", opts...) if err != nil { return nil, err @@ -256,7 +276,9 @@ func (x *searchStreamLinearSearchByIDClient) Recv() (*payload.Search_StreamRespo return m, nil } -func (c *searchClient) MultiLinearSearch(ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption) (*payload.Search_Responses, error) { +func (c *searchClient) MultiLinearSearch( + ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption, +) (*payload.Search_Responses, error) { out := new(payload.Search_Responses) err := c.cc.Invoke(ctx, "/vald.v1.Search/MultiLinearSearch", in, out, opts...) if err != nil { @@ -265,7 +287,9 @@ func (c *searchClient) MultiLinearSearch(ctx context.Context, in *payload.Search return out, nil } -func (c *searchClient) MultiLinearSearchByID(ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption) (*payload.Search_Responses, error) { +func (c *searchClient) MultiLinearSearchByID( + ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption, +) (*payload.Search_Responses, error) { out := new(payload.Search_Responses) err := c.cc.Invoke(ctx, "/vald.v1.Search/MultiLinearSearchByID", in, out, opts...) if err != nil { @@ -308,43 +332,69 @@ type SearchServer interface { } // UnimplementedSearchServer must be embedded to have forward compatible implementations. -type UnimplementedSearchServer struct { -} +type UnimplementedSearchServer struct{} -func (UnimplementedSearchServer) Search(context.Context, *payload.Search_Request) (*payload.Search_Response, error) { +func (UnimplementedSearchServer) Search( + context.Context, *payload.Search_Request, +) (*payload.Search_Response, error) { return nil, status.Errorf(codes.Unimplemented, "method Search not implemented") } -func (UnimplementedSearchServer) SearchByID(context.Context, *payload.Search_IDRequest) (*payload.Search_Response, error) { + +func (UnimplementedSearchServer) SearchByID( + context.Context, *payload.Search_IDRequest, +) (*payload.Search_Response, error) { return nil, status.Errorf(codes.Unimplemented, "method SearchByID not implemented") } + func (UnimplementedSearchServer) StreamSearch(Search_StreamSearchServer) error { return status.Errorf(codes.Unimplemented, "method StreamSearch not implemented") } + func (UnimplementedSearchServer) StreamSearchByID(Search_StreamSearchByIDServer) error { return status.Errorf(codes.Unimplemented, "method StreamSearchByID not implemented") } -func (UnimplementedSearchServer) MultiSearch(context.Context, *payload.Search_MultiRequest) (*payload.Search_Responses, error) { + +func (UnimplementedSearchServer) MultiSearch( + context.Context, *payload.Search_MultiRequest, +) (*payload.Search_Responses, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiSearch not implemented") } -func (UnimplementedSearchServer) MultiSearchByID(context.Context, *payload.Search_MultiIDRequest) (*payload.Search_Responses, error) { + +func (UnimplementedSearchServer) MultiSearchByID( + context.Context, *payload.Search_MultiIDRequest, +) (*payload.Search_Responses, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiSearchByID not implemented") } -func (UnimplementedSearchServer) LinearSearch(context.Context, *payload.Search_Request) (*payload.Search_Response, error) { + +func (UnimplementedSearchServer) LinearSearch( + context.Context, *payload.Search_Request, +) (*payload.Search_Response, error) { return nil, status.Errorf(codes.Unimplemented, "method LinearSearch not implemented") } -func (UnimplementedSearchServer) LinearSearchByID(context.Context, *payload.Search_IDRequest) (*payload.Search_Response, error) { + +func (UnimplementedSearchServer) LinearSearchByID( + context.Context, *payload.Search_IDRequest, +) (*payload.Search_Response, error) { return nil, status.Errorf(codes.Unimplemented, "method LinearSearchByID not implemented") } + func (UnimplementedSearchServer) StreamLinearSearch(Search_StreamLinearSearchServer) error { return status.Errorf(codes.Unimplemented, "method StreamLinearSearch not implemented") } + func (UnimplementedSearchServer) StreamLinearSearchByID(Search_StreamLinearSearchByIDServer) error { return status.Errorf(codes.Unimplemented, "method StreamLinearSearchByID not implemented") } -func (UnimplementedSearchServer) MultiLinearSearch(context.Context, *payload.Search_MultiRequest) (*payload.Search_Responses, error) { + +func (UnimplementedSearchServer) MultiLinearSearch( + context.Context, *payload.Search_MultiRequest, +) (*payload.Search_Responses, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiLinearSearch not implemented") } -func (UnimplementedSearchServer) MultiLinearSearchByID(context.Context, *payload.Search_MultiIDRequest) (*payload.Search_Responses, error) { + +func (UnimplementedSearchServer) MultiLinearSearchByID( + context.Context, *payload.Search_MultiIDRequest, +) (*payload.Search_Responses, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiLinearSearchByID not implemented") } func (UnimplementedSearchServer) mustEmbedUnimplementedSearchServer() {} @@ -360,7 +410,9 @@ func RegisterSearchServer(s grpc.ServiceRegistrar, srv SearchServer) { s.RegisterService(&Search_ServiceDesc, srv) } -func _Search_Search_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Search_Search_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_Request) if err := dec(in); err != nil { return nil, err @@ -372,13 +424,15 @@ func _Search_Search_Handler(srv interface{}, ctx context.Context, dec func(inter Server: srv, FullMethod: "/vald.v1.Search/Search", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(SearchServer).Search(ctx, req.(*payload.Search_Request)) } return interceptor(ctx, in, info, handler) } -func _Search_SearchByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Search_SearchByID_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_IDRequest) if err := dec(in); err != nil { return nil, err @@ -390,13 +444,13 @@ func _Search_SearchByID_Handler(srv interface{}, ctx context.Context, dec func(i Server: srv, FullMethod: "/vald.v1.Search/SearchByID", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(SearchServer).SearchByID(ctx, req.(*payload.Search_IDRequest)) } return interceptor(ctx, in, info, handler) } -func _Search_StreamSearch_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Search_StreamSearch_Handler(srv any, stream grpc.ServerStream) error { return srv.(SearchServer).StreamSearch(&searchStreamSearchServer{stream}) } @@ -422,7 +476,7 @@ func (x *searchStreamSearchServer) Recv() (*payload.Search_Request, error) { return m, nil } -func _Search_StreamSearchByID_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Search_StreamSearchByID_Handler(srv any, stream grpc.ServerStream) error { return srv.(SearchServer).StreamSearchByID(&searchStreamSearchByIDServer{stream}) } @@ -448,7 +502,9 @@ func (x *searchStreamSearchByIDServer) Recv() (*payload.Search_IDRequest, error) return m, nil } -func _Search_MultiSearch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Search_MultiSearch_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_MultiRequest) if err := dec(in); err != nil { return nil, err @@ -460,13 +516,15 @@ func _Search_MultiSearch_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/vald.v1.Search/MultiSearch", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(SearchServer).MultiSearch(ctx, req.(*payload.Search_MultiRequest)) } return interceptor(ctx, in, info, handler) } -func _Search_MultiSearchByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Search_MultiSearchByID_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_MultiIDRequest) if err := dec(in); err != nil { return nil, err @@ -478,13 +536,15 @@ func _Search_MultiSearchByID_Handler(srv interface{}, ctx context.Context, dec f Server: srv, FullMethod: "/vald.v1.Search/MultiSearchByID", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(SearchServer).MultiSearchByID(ctx, req.(*payload.Search_MultiIDRequest)) } return interceptor(ctx, in, info, handler) } -func _Search_LinearSearch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Search_LinearSearch_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_Request) if err := dec(in); err != nil { return nil, err @@ -496,13 +556,15 @@ func _Search_LinearSearch_Handler(srv interface{}, ctx context.Context, dec func Server: srv, FullMethod: "/vald.v1.Search/LinearSearch", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(SearchServer).LinearSearch(ctx, req.(*payload.Search_Request)) } return interceptor(ctx, in, info, handler) } -func _Search_LinearSearchByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Search_LinearSearchByID_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_IDRequest) if err := dec(in); err != nil { return nil, err @@ -514,13 +576,13 @@ func _Search_LinearSearchByID_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/vald.v1.Search/LinearSearchByID", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(SearchServer).LinearSearchByID(ctx, req.(*payload.Search_IDRequest)) } return interceptor(ctx, in, info, handler) } -func _Search_StreamLinearSearch_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Search_StreamLinearSearch_Handler(srv any, stream grpc.ServerStream) error { return srv.(SearchServer).StreamLinearSearch(&searchStreamLinearSearchServer{stream}) } @@ -546,7 +608,7 @@ func (x *searchStreamLinearSearchServer) Recv() (*payload.Search_Request, error) return m, nil } -func _Search_StreamLinearSearchByID_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Search_StreamLinearSearchByID_Handler(srv any, stream grpc.ServerStream) error { return srv.(SearchServer).StreamLinearSearchByID(&searchStreamLinearSearchByIDServer{stream}) } @@ -572,7 +634,9 @@ func (x *searchStreamLinearSearchByIDServer) Recv() (*payload.Search_IDRequest, return m, nil } -func _Search_MultiLinearSearch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Search_MultiLinearSearch_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_MultiRequest) if err := dec(in); err != nil { return nil, err @@ -584,13 +648,15 @@ func _Search_MultiLinearSearch_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/vald.v1.Search/MultiLinearSearch", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(SearchServer).MultiLinearSearch(ctx, req.(*payload.Search_MultiRequest)) } return interceptor(ctx, in, info, handler) } -func _Search_MultiLinearSearchByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Search_MultiLinearSearchByID_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Search_MultiIDRequest) if err := dec(in); err != nil { return nil, err @@ -602,7 +668,7 @@ func _Search_MultiLinearSearchByID_Handler(srv interface{}, ctx context.Context, Server: srv, FullMethod: "/vald.v1.Search/MultiLinearSearchByID", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(SearchServer).MultiLinearSearchByID(ctx, req.(*payload.Search_MultiIDRequest)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/vald/update.pb.go b/apis/grpc/v1/vald/update.pb.go index 5c9fa2ed27..ad05fbe50c 100644 --- a/apis/grpc/v1/vald/update.pb.go +++ b/apis/grpc/v1/vald/update.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/vald/update.proto @@ -73,13 +73,14 @@ var file_v1_vald_update_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_vald_update_proto_goTypes = []interface{}{ +var file_v1_vald_update_proto_goTypes = []any{ (*payload.Update_Request)(nil), // 0: payload.v1.Update.Request (*payload.Update_MultiRequest)(nil), // 1: payload.v1.Update.MultiRequest (*payload.Object_Location)(nil), // 2: payload.v1.Object.Location (*payload.Object_StreamLocation)(nil), // 3: payload.v1.Object.StreamLocation (*payload.Object_Locations)(nil), // 4: payload.v1.Object.Locations } + var file_v1_vald_update_proto_depIdxs = []int32{ 0, // 0: vald.v1.Update.Update:input_type -> payload.v1.Update.Request 0, // 1: vald.v1.Update.StreamUpdate:input_type -> payload.v1.Update.Request diff --git a/apis/grpc/v1/vald/update_vtproto.pb.go b/apis/grpc/v1/vald/update_vtproto.pb.go index 70796ba018..60f92fd0a8 100644 --- a/apis/grpc/v1/vald/update_vtproto.pb.go +++ b/apis/grpc/v1/vald/update_vtproto.pb.go @@ -58,7 +58,9 @@ func NewUpdateClient(cc grpc.ClientConnInterface) UpdateClient { return &updateClient{cc} } -func (c *updateClient) Update(ctx context.Context, in *payload.Update_Request, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (c *updateClient) Update( + ctx context.Context, in *payload.Update_Request, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { out := new(payload.Object_Location) err := c.cc.Invoke(ctx, "/vald.v1.Update/Update", in, out, opts...) if err != nil { @@ -67,7 +69,9 @@ func (c *updateClient) Update(ctx context.Context, in *payload.Update_Request, o return out, nil } -func (c *updateClient) StreamUpdate(ctx context.Context, opts ...grpc.CallOption) (Update_StreamUpdateClient, error) { +func (c *updateClient) StreamUpdate( + ctx context.Context, opts ...grpc.CallOption, +) (Update_StreamUpdateClient, error) { stream, err := c.cc.NewStream(ctx, &Update_ServiceDesc.Streams[0], "/vald.v1.Update/StreamUpdate", opts...) if err != nil { return nil, err @@ -98,7 +102,9 @@ func (x *updateStreamUpdateClient) Recv() (*payload.Object_StreamLocation, error return m, nil } -func (c *updateClient) MultiUpdate(ctx context.Context, in *payload.Update_MultiRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) { +func (c *updateClient) MultiUpdate( + ctx context.Context, in *payload.Update_MultiRequest, opts ...grpc.CallOption, +) (*payload.Object_Locations, error) { out := new(payload.Object_Locations) err := c.cc.Invoke(ctx, "/vald.v1.Update/MultiUpdate", in, out, opts...) if err != nil { @@ -121,16 +127,21 @@ type UpdateServer interface { } // UnimplementedUpdateServer must be embedded to have forward compatible implementations. -type UnimplementedUpdateServer struct { -} +type UnimplementedUpdateServer struct{} -func (UnimplementedUpdateServer) Update(context.Context, *payload.Update_Request) (*payload.Object_Location, error) { +func (UnimplementedUpdateServer) Update( + context.Context, *payload.Update_Request, +) (*payload.Object_Location, error) { return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") } + func (UnimplementedUpdateServer) StreamUpdate(Update_StreamUpdateServer) error { return status.Errorf(codes.Unimplemented, "method StreamUpdate not implemented") } -func (UnimplementedUpdateServer) MultiUpdate(context.Context, *payload.Update_MultiRequest) (*payload.Object_Locations, error) { + +func (UnimplementedUpdateServer) MultiUpdate( + context.Context, *payload.Update_MultiRequest, +) (*payload.Object_Locations, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiUpdate not implemented") } func (UnimplementedUpdateServer) mustEmbedUnimplementedUpdateServer() {} @@ -146,7 +157,9 @@ func RegisterUpdateServer(s grpc.ServiceRegistrar, srv UpdateServer) { s.RegisterService(&Update_ServiceDesc, srv) } -func _Update_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Update_Update_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Update_Request) if err := dec(in); err != nil { return nil, err @@ -158,13 +171,13 @@ func _Update_Update_Handler(srv interface{}, ctx context.Context, dec func(inter Server: srv, FullMethod: "/vald.v1.Update/Update", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(UpdateServer).Update(ctx, req.(*payload.Update_Request)) } return interceptor(ctx, in, info, handler) } -func _Update_StreamUpdate_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Update_StreamUpdate_Handler(srv any, stream grpc.ServerStream) error { return srv.(UpdateServer).StreamUpdate(&updateStreamUpdateServer{stream}) } @@ -190,7 +203,9 @@ func (x *updateStreamUpdateServer) Recv() (*payload.Update_Request, error) { return m, nil } -func _Update_MultiUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Update_MultiUpdate_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Update_MultiRequest) if err := dec(in); err != nil { return nil, err @@ -202,7 +217,7 @@ func _Update_MultiUpdate_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/vald.v1.Update/MultiUpdate", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(UpdateServer).MultiUpdate(ctx, req.(*payload.Update_MultiRequest)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/vald/upsert.pb.go b/apis/grpc/v1/vald/upsert.pb.go index 336c393e1b..3c1a741dc1 100644 --- a/apis/grpc/v1/vald/upsert.pb.go +++ b/apis/grpc/v1/vald/upsert.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: v1/vald/upsert.proto @@ -73,13 +73,14 @@ var file_v1_vald_upsert_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_v1_vald_upsert_proto_goTypes = []interface{}{ +var file_v1_vald_upsert_proto_goTypes = []any{ (*payload.Upsert_Request)(nil), // 0: payload.v1.Upsert.Request (*payload.Upsert_MultiRequest)(nil), // 1: payload.v1.Upsert.MultiRequest (*payload.Object_Location)(nil), // 2: payload.v1.Object.Location (*payload.Object_StreamLocation)(nil), // 3: payload.v1.Object.StreamLocation (*payload.Object_Locations)(nil), // 4: payload.v1.Object.Locations } + var file_v1_vald_upsert_proto_depIdxs = []int32{ 0, // 0: vald.v1.Upsert.Upsert:input_type -> payload.v1.Upsert.Request 0, // 1: vald.v1.Upsert.StreamUpsert:input_type -> payload.v1.Upsert.Request diff --git a/apis/grpc/v1/vald/upsert_vtproto.pb.go b/apis/grpc/v1/vald/upsert_vtproto.pb.go index d50ca4c783..1a28a9461a 100644 --- a/apis/grpc/v1/vald/upsert_vtproto.pb.go +++ b/apis/grpc/v1/vald/upsert_vtproto.pb.go @@ -58,7 +58,9 @@ func NewUpsertClient(cc grpc.ClientConnInterface) UpsertClient { return &upsertClient{cc} } -func (c *upsertClient) Upsert(ctx context.Context, in *payload.Upsert_Request, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (c *upsertClient) Upsert( + ctx context.Context, in *payload.Upsert_Request, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { out := new(payload.Object_Location) err := c.cc.Invoke(ctx, "/vald.v1.Upsert/Upsert", in, out, opts...) if err != nil { @@ -67,7 +69,9 @@ func (c *upsertClient) Upsert(ctx context.Context, in *payload.Upsert_Request, o return out, nil } -func (c *upsertClient) StreamUpsert(ctx context.Context, opts ...grpc.CallOption) (Upsert_StreamUpsertClient, error) { +func (c *upsertClient) StreamUpsert( + ctx context.Context, opts ...grpc.CallOption, +) (Upsert_StreamUpsertClient, error) { stream, err := c.cc.NewStream(ctx, &Upsert_ServiceDesc.Streams[0], "/vald.v1.Upsert/StreamUpsert", opts...) if err != nil { return nil, err @@ -98,7 +102,9 @@ func (x *upsertStreamUpsertClient) Recv() (*payload.Object_StreamLocation, error return m, nil } -func (c *upsertClient) MultiUpsert(ctx context.Context, in *payload.Upsert_MultiRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) { +func (c *upsertClient) MultiUpsert( + ctx context.Context, in *payload.Upsert_MultiRequest, opts ...grpc.CallOption, +) (*payload.Object_Locations, error) { out := new(payload.Object_Locations) err := c.cc.Invoke(ctx, "/vald.v1.Upsert/MultiUpsert", in, out, opts...) if err != nil { @@ -121,16 +127,21 @@ type UpsertServer interface { } // UnimplementedUpsertServer must be embedded to have forward compatible implementations. -type UnimplementedUpsertServer struct { -} +type UnimplementedUpsertServer struct{} -func (UnimplementedUpsertServer) Upsert(context.Context, *payload.Upsert_Request) (*payload.Object_Location, error) { +func (UnimplementedUpsertServer) Upsert( + context.Context, *payload.Upsert_Request, +) (*payload.Object_Location, error) { return nil, status.Errorf(codes.Unimplemented, "method Upsert not implemented") } + func (UnimplementedUpsertServer) StreamUpsert(Upsert_StreamUpsertServer) error { return status.Errorf(codes.Unimplemented, "method StreamUpsert not implemented") } -func (UnimplementedUpsertServer) MultiUpsert(context.Context, *payload.Upsert_MultiRequest) (*payload.Object_Locations, error) { + +func (UnimplementedUpsertServer) MultiUpsert( + context.Context, *payload.Upsert_MultiRequest, +) (*payload.Object_Locations, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiUpsert not implemented") } func (UnimplementedUpsertServer) mustEmbedUnimplementedUpsertServer() {} @@ -146,7 +157,9 @@ func RegisterUpsertServer(s grpc.ServiceRegistrar, srv UpsertServer) { s.RegisterService(&Upsert_ServiceDesc, srv) } -func _Upsert_Upsert_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Upsert_Upsert_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Upsert_Request) if err := dec(in); err != nil { return nil, err @@ -158,13 +171,13 @@ func _Upsert_Upsert_Handler(srv interface{}, ctx context.Context, dec func(inter Server: srv, FullMethod: "/vald.v1.Upsert/Upsert", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(UpsertServer).Upsert(ctx, req.(*payload.Upsert_Request)) } return interceptor(ctx, in, info, handler) } -func _Upsert_StreamUpsert_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Upsert_StreamUpsert_Handler(srv any, stream grpc.ServerStream) error { return srv.(UpsertServer).StreamUpsert(&upsertStreamUpsertServer{stream}) } @@ -190,7 +203,9 @@ func (x *upsertStreamUpsertServer) Recv() (*payload.Upsert_Request, error) { return m, nil } -func _Upsert_MultiUpsert_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Upsert_MultiUpsert_Handler( + srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor, +) (any, error) { in := new(payload.Upsert_MultiRequest) if err := dec(in); err != nil { return nil, err @@ -202,7 +217,7 @@ func _Upsert_MultiUpsert_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/vald.v1.Upsert/MultiUpsert", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(UpsertServer).MultiUpsert(ctx, req.(*payload.Upsert_MultiRequest)) } return interceptor(ctx, in, info, handler) diff --git a/apis/grpc/v1/vald/vald.go b/apis/grpc/v1/vald/vald.go index e2886b0782..a67e7c97ef 100644 --- a/apis/grpc/v1/vald/vald.go +++ b/apis/grpc/v1/vald/vald.go @@ -17,18 +17,17 @@ // Package vald provides vald server interface package vald -import ( - grpc "google.golang.org/grpc" -) +import grpc "google.golang.org/grpc" type Server interface { + FlushServer + IndexServer InsertServer + ObjectServer + RemoveServer + SearchServer UpdateServer UpsertServer - SearchServer - RemoveServer - FlushServer - ObjectServer } type ServerWithFilter interface { @@ -37,13 +36,14 @@ type ServerWithFilter interface { } type UnimplementedValdServer struct { + UnimplementedFlushServer + UnimplementedIndexServer UnimplementedInsertServer + UnimplementedObjectServer + UnimplementedRemoveServer + UnimplementedSearchServer UnimplementedUpdateServer UnimplementedUpsertServer - UnimplementedSearchServer - UnimplementedRemoveServer - UnimplementedFlushServer - UnimplementedObjectServer } type UnimplementedValdServerWithFilter struct { @@ -52,13 +52,14 @@ type UnimplementedValdServerWithFilter struct { } type Client interface { + FlushClient + IndexClient InsertClient + ObjectClient + RemoveClient + SearchClient UpdateClient UpsertClient - SearchClient - RemoveClient - FlushClient - ObjectClient } type ClientWithFilter interface { @@ -69,14 +70,15 @@ type ClientWithFilter interface { const PackageName = "vald.v1" const ( + FilterRPCServiceName = "Filter" + FlushRPCServiceName = "Flush" + IndexRPCServiceName = "Index" InsertRPCServiceName = "Insert" + ObjectRPCServiceName = "Object" + RemoveRPCServiceName = "Remove" + SearchRPCServiceName = "Search" UpdateRPCServiceName = "Update" UpsertRPCServiceName = "Upsert" - SearchRPCServiceName = "Search" - RemoveRPCServiceName = "Remove" - FlushRPCServiceName = "Flush" - ObjectRPCServiceName = "Object" - FilterRPCServiceName = "Filter" ) const ( @@ -132,26 +134,33 @@ const ( GetTimestampRPCName = "GetTimestamp" StreamGetObjectRPCName = "StreamGetObject" StreamListObjectRPCName = "StreamListObject" + + IndexInfoRPCName = "IndexInfo" + IndexDetailRPCName = "IndexDetail" + IndexStatisticsRPCName = "IndexStatistics" + IndexStatisticsDetailRPCName = "IndexStatisticsDetail" ) type client struct { + FlushClient + IndexClient InsertClient + ObjectClient + RemoveClient + SearchClient UpdateClient UpsertClient - SearchClient - RemoveClient - FlushClient - ObjectClient } func RegisterValdServer(s *grpc.Server, srv Server) { + RegisterFlushServer(s, srv) + RegisterIndexServer(s, srv) RegisterInsertServer(s, srv) + RegisterObjectServer(s, srv) + RegisterRemoveServer(s, srv) + RegisterSearchServer(s, srv) RegisterUpdateServer(s, srv) RegisterUpsertServer(s, srv) - RegisterSearchServer(s, srv) - RegisterRemoveServer(s, srv) - RegisterFlushServer(s, srv) - RegisterObjectServer(s, srv) } func RegisterValdServerWithFilter(s *grpc.Server, srv ServerWithFilter) { @@ -161,12 +170,13 @@ func RegisterValdServerWithFilter(s *grpc.Server, srv ServerWithFilter) { func NewValdClient(conn *grpc.ClientConn) Client { return &client{ - NewInsertClient(conn), - NewUpdateClient(conn), - NewUpsertClient(conn), - NewSearchClient(conn), - NewRemoveClient(conn), - NewFlushClient(conn), - NewObjectClient(conn), + FlushClient: NewFlushClient(conn), + IndexClient: NewIndexClient(conn), + InsertClient: NewInsertClient(conn), + ObjectClient: NewObjectClient(conn), + RemoveClient: NewRemoveClient(conn), + SearchClient: NewSearchClient(conn), + UpdateClient: NewUpdateClient(conn), + UpsertClient: NewUpsertClient(conn), } } diff --git a/apis/proto/v1/agent/core/agent.proto b/apis/proto/v1/agent/core/agent.proto index 779f6a5b74..268778e380 100644 --- a/apis/proto/v1/agent/core/agent.proto +++ b/apis/proto/v1/agent/core/agent.proto @@ -30,7 +30,7 @@ option java_package = "org.vdaas.vald.api.v1.agent.core"; service Agent { // Represent the creating index RPC. rpc CreateIndex(payload.v1.Control.CreateIndexRequest) returns (payload.v1.Empty) { - option (google.api.http).get = "/index/create"; + option (google.api.http).get = "/index/create/{pool_size}"; } // Represent the saving index RPC. @@ -40,16 +40,6 @@ service Agent { // Represent the creating and saving index RPC. rpc CreateAndSaveIndex(payload.v1.Control.CreateIndexRequest) returns (payload.v1.Empty) { - option (google.api.http).get = "/index/createandsave"; - } - - // Represent the RPC to get the agent index information. - rpc IndexInfo(payload.v1.Empty) returns (payload.v1.Info.Index.Count) { - option (google.api.http).get = "/index/info"; - } - - // Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process - rpc GetTimestamp(payload.v1.Object.GetTimestampRequest) returns (payload.v1.Object.Timestamp) { - option (google.api.http).get = "/object/meta"; + option (google.api.http).get = "/index/createandsave/{pool_size}"; } } diff --git a/apis/proto/v1/payload/payload.proto b/apis/proto/v1/payload/payload.proto index 5f9af665a0..f49160d381 100644 --- a/apis/proto/v1/payload/payload.proto +++ b/apis/proto/v1/payload/payload.proto @@ -302,7 +302,8 @@ message Remove { // Represent the remove request based on timestamp. message TimestampRequest { - // The timestamp comparison list. If more than one is specified, the `AND` search is applied. + // The timestamp comparison list. If more than one is specified, the `AND` + // search is applied. repeated Timestamp timestamps = 1; } @@ -314,11 +315,13 @@ message Remove { Eq = 0; // The timestamp is not equal to the specified value in the request. Ne = 1; - // The timestamp is greater than or equal to the specified value in the request. + // The timestamp is greater than or equal to the specified value in the + // request. Ge = 2; // The timestamp is greater than the specified value in the request. Gt = 3; - // The timestamp is less than or equal to the specified value in the request. + // The timestamp is less than or equal to the specified value in the + // request. Le = 4; // The timestamp is less than the specified value in the request. Lt = 5; @@ -392,7 +395,7 @@ message Object { } // Represent a request to fetch vector meta data. - message GetTimestampRequest { + message TimestampRequest { // The vector ID to be fetched. ID id = 1 [(buf.validate.field).repeated.min_items = 2]; } @@ -523,6 +526,15 @@ message Info { // The saving index count. bool saving = 4; } + // Represent the index count for each Agents message. + message Detail { + // count infos for each agents + map counts = 1; + // index replica of vald cluster + uint32 replica = 2; + // live agent replica of vald cluster + uint32 live_agents = 3; + } // Represent the UUID message. message UUID { @@ -535,6 +547,49 @@ message Info { string uuid = 1; } } + + // Represents index Statistics + message Statistics { + bool valid = 1; + int32 median_indegree = 2; + int32 median_outdegree = 3; + uint64 max_number_of_indegree = 4; + uint64 max_number_of_outdegree = 5; + uint64 min_number_of_indegree = 6; + uint64 min_number_of_outdegree = 7; + uint64 mode_indegree = 8; + uint64 mode_outdegree = 9; + uint64 nodes_skipped_for_10_edges = 10; + uint64 nodes_skipped_for_indegree_distance = 11; + uint64 number_of_edges = 12; + uint64 number_of_indexed_objects = 13; + uint64 number_of_nodes = 14; + uint64 number_of_nodes_without_edges = 15; + uint64 number_of_nodes_without_indegree = 16; + uint64 number_of_objects = 17; + uint64 number_of_removed_objects = 18; + uint64 size_of_object_repository = 19; + uint64 size_of_refinement_object_repository = 20; + double variance_of_indegree = 21; + double variance_of_outdegree = 22; + double mean_edge_length = 23; + double mean_edge_length_for_10_edges = 24; + double mean_indegree_distance_for_10_edges = 25; + double mean_number_of_edges_per_node = 26; + double c1_indegree = 27; + double c5_indegree = 28; + double c95_outdegree = 29; + double c99_outdegree = 30; + repeated int64 indegree_count = 31; + repeated uint64 outdegree_histogram = 32; + repeated uint64 indegree_histogram = 33; + } + + // Represents index Statistics for each Agents + message StatisticsDetail { + // count infos for each agents + map details = 1; + } } // Represent the pod information message. diff --git a/apis/proto/v1/manager/index/index_manager.proto b/apis/proto/v1/vald/index.proto similarity index 55% rename from apis/proto/v1/manager/index/index_manager.proto rename to apis/proto/v1/vald/index.proto index a18f0c1bba..037132e59a 100644 --- a/apis/proto/v1/manager/index/index_manager.proto +++ b/apis/proto/v1/vald/index.proto @@ -16,15 +16,15 @@ syntax = "proto3"; -package manager.index.v1; +package vald.v1; import "google/api/annotations.proto"; import "v1/payload/payload.proto"; -option go_package = "github.com/vdaas/vald/apis/grpc/v1/manager/index"; +option go_package = "github.com/vdaas/vald/apis/grpc/v1/vald"; option java_multiple_files = true; -option java_outer_classname = "ValdIndexManager"; -option java_package = "org.vdaas.vald.api.v1.manager.index"; +option java_outer_classname = "ValdIndex"; +option java_package = "org.vdaas.vald.api.v1.vald"; // Represent the index manager service. service Index { @@ -32,4 +32,17 @@ service Index { rpc IndexInfo(payload.v1.Empty) returns (payload.v1.Info.Index.Count) { option (google.api.http).get = "/index/info"; } + // Represent the RPC to get the index information for each agents. + rpc IndexDetail(payload.v1.Empty) returns (payload.v1.Info.Index.Detail) { + option (google.api.http).get = "/index/detail"; + } + // Represent the RPC to get the index statistics. + rpc IndexStatistics(payload.v1.Empty) returns (payload.v1.Info.Index.Statistics) { + option (google.api.http).get = "/index/statistics"; + } + + // Represent the RPC to get the index statistics for each agents. + rpc IndexStatisticsDetail(payload.v1.Empty) returns (payload.v1.Info.Index.StatisticsDetail) { + option (google.api.http).get = "/index/statistics/detail"; + } } diff --git a/apis/proto/v1/vald/object.proto b/apis/proto/v1/vald/object.proto index ee8f454b07..73e5723381 100644 --- a/apis/proto/v1/vald/object.proto +++ b/apis/proto/v1/vald/object.proto @@ -45,4 +45,9 @@ service Object { rpc StreamListObject(payload.v1.Object.List.Request) returns (stream payload.v1.Object.List.Response) { option (google.api.http).get = "/object/list"; } + + // Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process + rpc GetTimestamp(payload.v1.Object.TimestampRequest) returns (payload.v1.Object.Timestamp) { + option (google.api.http).get = "/object/meta/{id.id}"; + } } diff --git a/apis/swagger/v1/agent/core/agent.swagger.json b/apis/swagger/v1/agent/core/agent.swagger.json index a3c2fda39b..2abce5f222 100644 --- a/apis/swagger/v1/agent/core/agent.swagger.json +++ b/apis/swagger/v1/agent/core/agent.swagger.json @@ -12,7 +12,7 @@ "consumes": ["application/json"], "produces": ["application/json"], "paths": { - "/index/create": { + "/index/create/{poolSize}": { "get": { "summary": "Represent the creating index RPC.", "operationId": "Agent_CreateIndex", @@ -34,8 +34,8 @@ { "name": "poolSize", "description": "The pool size of the create index operation.", - "in": "query", - "required": false, + "in": "path", + "required": true, "type": "integer", "format": "int64" } @@ -43,7 +43,7 @@ "tags": ["Agent"] } }, - "/index/createandsave": { + "/index/createandsave/{poolSize}": { "get": { "summary": "Represent the creating and saving index RPC.", "operationId": "Agent_CreateAndSaveIndex", @@ -65,8 +65,8 @@ { "name": "poolSize", "description": "The pool size of the create index operation.", - "in": "query", - "required": false, + "in": "path", + "required": true, "type": "integer", "format": "int64" } @@ -74,27 +74,6 @@ "tags": ["Agent"] } }, - "/index/info": { - "get": { - "summary": "Represent the RPC to get the agent index information.", - "operationId": "Agent_IndexInfo", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/IndexCount" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "tags": ["Agent"] - } - }, "/index/save": { "get": { "summary": "Represent the saving index RPC.", @@ -115,71 +94,9 @@ }, "tags": ["Agent"] } - }, - "/object/meta": { - "get": { - "summary": "Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process", - "operationId": "Agent_GetTimestamp", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/v1ObjectTimestamp" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "id.id", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": ["Agent"] - } } }, "definitions": { - "IndexCount": { - "type": "object", - "properties": { - "stored": { - "type": "integer", - "format": "int64", - "description": "The stored index count." - }, - "uncommitted": { - "type": "integer", - "format": "int64", - "description": "The uncommitted index count." - }, - "indexing": { - "type": "boolean", - "description": "The indexing index count." - }, - "saving": { - "type": "boolean", - "description": "The saving index count." - } - }, - "description": "Represent the index count message." - }, - "ObjectID": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - }, - "description": "Represent the vector ID." - }, "protobufAny": { "type": "object", "properties": { @@ -217,21 +134,6 @@ "v1Empty": { "type": "object", "description": "Represent an empty message." - }, - "v1ObjectTimestamp": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The vector ID." - }, - "timestamp": { - "type": "string", - "format": "int64", - "description": "timestamp represents when this vector inserted." - } - }, - "description": "Represent a vector meta data." } } } diff --git a/apis/swagger/v1/manager/index/index_manager.swagger.json b/apis/swagger/v1/vald/index.swagger.json similarity index 51% rename from apis/swagger/v1/manager/index/index_manager.swagger.json rename to apis/swagger/v1/vald/index.swagger.json index 73a3c346cf..8a42e80373 100644 --- a/apis/swagger/v1/manager/index/index_manager.swagger.json +++ b/apis/swagger/v1/vald/index.swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "title": "v1/manager/index/index_manager.proto", + "title": "v1/vald/index.proto", "version": "version not set" }, "tags": [ @@ -12,6 +12,27 @@ "consumes": ["application/json"], "produces": ["application/json"], "paths": { + "/index/detail": { + "get": { + "summary": "Represent the RPC to get the index information for each agents.", + "operationId": "Index_IndexDetail", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/IndexDetail" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "tags": ["Index"] + } + }, "/index/info": { "get": { "summary": "Represent the RPC to get the index information.", @@ -32,6 +53,48 @@ }, "tags": ["Index"] } + }, + "/index/statistics": { + "get": { + "summary": "Represent the RPC to get the index statistics.", + "operationId": "Index_IndexStatistics", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/IndexStatistics" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "tags": ["Index"] + } + }, + "/index/statistics/detail": { + "get": { + "summary": "Represent the RPC to get the index statistics for each agents.", + "operationId": "Index_IndexStatisticsDetail", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/IndexStatisticsDetail" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "tags": ["Index"] + } } }, "definitions": { @@ -59,6 +122,188 @@ }, "description": "Represent the index count message." }, + "IndexDetail": { + "type": "object", + "properties": { + "counts": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/IndexCount" + }, + "title": "count infos for each agents" + }, + "replica": { + "type": "integer", + "format": "int64", + "title": "index replica of vald cluster" + }, + "liveAgents": { + "type": "integer", + "format": "int64", + "title": "live agent replica of vald cluster" + } + }, + "description": "Represent the index count for each Agents message." + }, + "IndexStatistics": { + "type": "object", + "properties": { + "valid": { + "type": "boolean" + }, + "medianIndegree": { + "type": "integer", + "format": "int32" + }, + "medianOutdegree": { + "type": "integer", + "format": "int32" + }, + "maxNumberOfIndegree": { + "type": "string", + "format": "uint64" + }, + "maxNumberOfOutdegree": { + "type": "string", + "format": "uint64" + }, + "minNumberOfIndegree": { + "type": "string", + "format": "uint64" + }, + "minNumberOfOutdegree": { + "type": "string", + "format": "uint64" + }, + "modeIndegree": { + "type": "string", + "format": "uint64" + }, + "modeOutdegree": { + "type": "string", + "format": "uint64" + }, + "nodesSkippedFor10Edges": { + "type": "string", + "format": "uint64" + }, + "nodesSkippedForIndegreeDistance": { + "type": "string", + "format": "uint64" + }, + "numberOfEdges": { + "type": "string", + "format": "uint64" + }, + "numberOfIndexedObjects": { + "type": "string", + "format": "uint64" + }, + "numberOfNodes": { + "type": "string", + "format": "uint64" + }, + "numberOfNodesWithoutEdges": { + "type": "string", + "format": "uint64" + }, + "numberOfNodesWithoutIndegree": { + "type": "string", + "format": "uint64" + }, + "numberOfObjects": { + "type": "string", + "format": "uint64" + }, + "numberOfRemovedObjects": { + "type": "string", + "format": "uint64" + }, + "sizeOfObjectRepository": { + "type": "string", + "format": "uint64" + }, + "sizeOfRefinementObjectRepository": { + "type": "string", + "format": "uint64" + }, + "varianceOfIndegree": { + "type": "number", + "format": "double" + }, + "varianceOfOutdegree": { + "type": "number", + "format": "double" + }, + "meanEdgeLength": { + "type": "number", + "format": "double" + }, + "meanEdgeLengthFor10Edges": { + "type": "number", + "format": "double" + }, + "meanIndegreeDistanceFor10Edges": { + "type": "number", + "format": "double" + }, + "meanNumberOfEdgesPerNode": { + "type": "number", + "format": "double" + }, + "c1Indegree": { + "type": "number", + "format": "double" + }, + "c5Indegree": { + "type": "number", + "format": "double" + }, + "c95Outdegree": { + "type": "number", + "format": "double" + }, + "c99Outdegree": { + "type": "number", + "format": "double" + }, + "indegreeCount": { + "type": "array", + "items": { + "type": "string", + "format": "int64" + } + }, + "outdegreeHistogram": { + "type": "array", + "items": { + "type": "string", + "format": "uint64" + } + }, + "indegreeHistogram": { + "type": "array", + "items": { + "type": "string", + "format": "uint64" + } + } + }, + "title": "Represents index Statistics" + }, + "IndexStatisticsDetail": { + "type": "object", + "properties": { + "details": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/IndexStatistics" + }, + "title": "count infos for each agents" + } + }, + "title": "Represents index Statistics for each Agents" + }, "protobufAny": { "type": "object", "properties": { diff --git a/apis/swagger/v1/vald/object.swagger.json b/apis/swagger/v1/vald/object.swagger.json index de87f3948e..263808e6d3 100644 --- a/apis/swagger/v1/vald/object.swagger.json +++ b/apis/swagger/v1/vald/object.swagger.json @@ -71,6 +71,35 @@ "tags": ["Object"] } }, + "/object/meta/{id.id}": { + "get": { + "summary": "Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process", + "operationId": "Object_GetTimestamp", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1ObjectTimestamp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id.id", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": ["Object"] + } + }, "/object/{id.id}": { "get": { "summary": "A method to fetch a vector.", @@ -223,6 +252,21 @@ } }, "description": "Represent the target filter server." + }, + "v1ObjectTimestamp": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The vector ID." + }, + "timestamp": { + "type": "string", + "format": "int64", + "description": "timestamp represents when this vector inserted." + } + }, + "description": "Represent a vector meta data." } } } diff --git a/apis/swagger/v1/vald/remove.swagger.json b/apis/swagger/v1/vald/remove.swagger.json index b68f220b47..34695978e5 100644 --- a/apis/swagger/v1/vald/remove.swagger.json +++ b/apis/swagger/v1/vald/remove.swagger.json @@ -101,7 +101,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/RemoveTimestampRequest" + "$ref": "#/definitions/v1RemoveTimestampRequest" } } ], @@ -146,25 +146,11 @@ }, "description": "Represent the stream response of the vector location." }, - "RemoveTimestampRequest": { - "type": "object", - "properties": { - "timestamps": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/v1RemoveTimestamp" - }, - "description": "The timestamp comparison list. If more than one is specified, the `AND` search is applied." - } - }, - "description": "Represent the remove request based on timestamp." - }, "TimestampOperator": { "type": "string", "enum": ["Eq", "Ne", "Ge", "Gt", "Le", "Lt"], "default": "Eq", - "description": "Operator is enum of each conditional operator.\n\n - Eq: The timestamp is equal to the specified value in the request.\n - Ne: The timestamp is not equal to the specified value in the request.\n - Ge: The timestamp is greater than or equal to the specified value in the request.\n - Gt: The timestamp is greater than the specified value in the request.\n - Le: The timestamp is less than or equal to the specified value in the request.\n - Lt: The timestamp is less than the specified value in the request." + "description": "Operator is enum of each conditional operator.\n\n - Eq: The timestamp is equal to the specified value in the request.\n - Ne: The timestamp is not equal to the specified value in the request.\n - Ge: The timestamp is greater than or equal to the specified value in the\nrequest.\n - Gt: The timestamp is greater than the specified value in the request.\n - Le: The timestamp is less than or equal to the specified value in the\nrequest.\n - Lt: The timestamp is less than the specified value in the request." }, "protobufAny": { "type": "object", @@ -278,6 +264,20 @@ } }, "description": "Represent the timestamp comparison." + }, + "v1RemoveTimestampRequest": { + "type": "object", + "properties": { + "timestamps": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1RemoveTimestamp" + }, + "description": "The timestamp comparison list. If more than one is specified, the `AND`\nsearch is applied." + } + }, + "description": "Represent the remove request based on timestamp." } } } diff --git a/assets/test/templates/option/function.tmpl b/assets/test/templates/option/function.tmpl index 42d4952270..72d48a75bc 100644 --- a/assets/test/templates/option/function.tmpl +++ b/assets/test/templates/option/function.tmpl @@ -3,7 +3,7 @@ func {{ .TestName }}(t *testing.T) { // Change interface type to the type of object you are testing - type T = interface{} + type T = any {{- if .TestParameters }} type args struct { {{- range .TestParameters }} diff --git a/charts/vald-helm-operator/crds/valdrelease.yaml b/charts/vald-helm-operator/crds/valdrelease.yaml index dff6669d2e..88657d76e0 100644 --- a/charts/vald-helm-operator/crds/valdrelease.yaml +++ b/charts/vald-helm-operator/crds/valdrelease.yaml @@ -147,6 +147,63 @@ spec: x-kubernetes-preserve-unknown-fields: true externalTrafficPolicy: type: string + faiss: + type: object + properties: + auto_index_check_duration: + type: string + auto_index_duration_limit: + type: string + auto_index_length: + type: integer + auto_save_index_duration: + type: string + dimension: + type: integer + minimum: 1 + enable_copy_on_write: + type: boolean + enable_in_memory_mode: + type: boolean + enable_proactive_gc: + type: boolean + index_path: + type: string + initial_delay_max_duration: + type: string + kvsdb: + type: object + properties: + concurrency: + type: integer + load_index_timeout_factor: + type: string + m: + type: integer + max_load_index_timeout: + type: string + metric_type: + type: string + enum: + - innerproduct + - l2 + min_load_index_timeout: + type: string + namespace: + type: string + nbits_per_idx: + type: integer + nlist: + type: integer + pod_name: + type: string + vqueue: + type: object + properties: + delete_buffer_pool_size: + type: integer + insert_buffer_pool_size: + type: integer hpa: type: object properties: @@ -275,6 +332,8 @@ spec: type: boolean enable_proactive_gc: type: boolean + enable_statistics: + type: boolean error_buffer_limit: type: integer minimum: 1 diff --git a/charts/vald-helm-operator/templates/operator.yaml b/charts/vald-helm-operator/templates/operator.yaml index d34793bbe4..4603efb3a8 100644 --- a/charts/vald-helm-operator/templates/operator.yaml +++ b/charts/vald-helm-operator/templates/operator.yaml @@ -53,8 +53,6 @@ spec: image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} args: - - "run" - - "--watches-file=./watches.yaml" {{- if .Values.enableLeaderElection }} - "--leader-elect" - "--leader-election-id={{ default .Values.name .Values.leaderElectionID }}" diff --git a/charts/vald/README.md b/charts/vald/README.md index 593b000f7a..31f0ef1494 100644 --- a/charts/vald/README.md +++ b/charts/vald/README.md @@ -61,6 +61,28 @@ Run the following command to install the chart, | agent.enabled | bool | `true` | agent enabled | | agent.env | list | `[{"name":"MY_NODE_NAME","valueFrom":{"fieldRef":{"fieldPath":"spec.nodeName"}}},{"name":"MY_POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"MY_POD_NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}}]` | environment variables | | agent.externalTrafficPolicy | string | `""` | external traffic policy (can be specified when service type is LoadBalancer or NodePort) : Cluster or Local | +| agent.faiss.auto_index_check_duration | string | `"30m"` | check duration of automatic indexing | +| agent.faiss.auto_index_duration_limit | string | `"24h"` | limit duration of automatic indexing | +| agent.faiss.auto_index_length | int | `100` | number of cache to trigger automatic indexing | +| agent.faiss.auto_save_index_duration | string | `"35m"` | duration of automatic save index | +| agent.faiss.dimension | int | `4096` | vector dimension | +| agent.faiss.enable_copy_on_write | bool | `false` | enable copy on write saving for more stable backup | +| agent.faiss.enable_in_memory_mode | bool | `true` | in-memory mode enabled | +| agent.faiss.enable_proactive_gc | bool | `false` | enable proactive GC call for reducing heap memory allocation | +| agent.faiss.index_path | string | `""` | path to index data | +| agent.faiss.initial_delay_max_duration | string | `"3m"` | maximum duration for initial delay | +| agent.faiss.kvsdb.concurrency | int | `6` | kvsdb processing concurrency | +| agent.faiss.load_index_timeout_factor | string | `"1ms"` | a factor of load index timeout. timeout duration will be calculated by (index count to be loaded) \* (factor). | +| agent.faiss.m | int | `8` | | +| agent.faiss.max_load_index_timeout | string | `"10m"` | maximum duration of load index timeout | +| agent.faiss.metric_type | string | `"l2"` | | +| agent.faiss.min_load_index_timeout | string | `"3m"` | minimum duration of load index timeout | +| agent.faiss.namespace | string | `"_MY_POD_NAMESPACE_"` | namespace of myself | +| agent.faiss.nbits_per_idx | int | `8` | | +| agent.faiss.nlist | int | `100` | | +| agent.faiss.pod_name | string | `"_MY_POD_NAME_"` | pod name of myself | +| agent.faiss.vqueue.delete_buffer_pool_size | int | `5000` | delete slice pool buffer size | +| agent.faiss.vqueue.insert_buffer_pool_size | int | `10000` | insert slice pool buffer size | | agent.hpa.enabled | bool | `false` | HPA enabled | | agent.hpa.targetCPUUtilizationPercentage | int | `80` | HPA CPU utilization percentage | | agent.image.pullPolicy | string | `"Always"` | image pull policy | @@ -90,6 +112,7 @@ Run the following command to install the chart, | agent.ngt.enable_export_index_info_to_k8s | bool | `false` | enable export index info to k8s | | agent.ngt.enable_in_memory_mode | bool | `true` | in-memory mode enabled | | agent.ngt.enable_proactive_gc | bool | `false` | enable proactive GC call for reducing heap memory allocation | +| agent.ngt.enable_statistics | bool | `false` | enable index statistics loading | | agent.ngt.error_buffer_limit | int | `10` | maximum number of core ngt error buffer pool size limit | | agent.ngt.export_index_info_duration | string | `"1m"` | duration of exporting index info | | agent.ngt.index_path | string | `""` | path to index data | diff --git a/charts/vald/templates/gateway/filter/configmap.yaml b/charts/vald/templates/gateway/filter/configmap.yaml index 15d49ae311..45480d466d 100644 --- a/charts/vald/templates/gateway/filter/configmap.yaml +++ b/charts/vald/templates/gateway/filter/configmap.yaml @@ -16,6 +16,7 @@ {{- $gateway := .Values.gateway.filter -}} {{- $lb := .Values.gateway.lb -}} {{- $agent := .Values.agent -}} +{{- $mirror := .Values.gateway.mirror -}} {{- if $gateway.enabled }} apiVersion: v1 kind: ConfigMap @@ -44,7 +45,14 @@ data: {{- include "vald.observability" $observability | nindent 6 }} client: {{- $nextGatewayClient := $gateway.gateway_config.gateway_client }} - {{- if $lb.enabled -}} + {{- if $mirror.enabled -}} + {{- $mirrorServerPort := $mirror.server_config.servers.grpc.port }} + {{- $defaultMirrorHost := printf "%s.%s.svc.cluster.local" $mirror.name .Release.Namespace }} + {{- $defaultMirrorPort := default .Values.defaults.server_config.servers.grpc.port $mirrorServerPort }} + {{- $defaultMirrorAddr := (list (printf "%s:%d" $defaultMirrorHost (int64 $defaultMirrorPort))) }} + {{- $mirrorAddrs := dict "Values" $nextGatewayClient.addrs "default" $defaultMirrorAddr }} + {{- include "vald.grpc.client.addrs" $mirrorAddrs | nindent 6 }} + {{- else if $lb.enabled -}} {{- $lbServerPort := $lb.server_config.servers.grpc.port }} {{- $defaultLBHost := printf "%s.%s.svc.cluster.local" $lb.name .Release.Namespace }} {{- $defaultLBPort := default .Values.defaults.server_config.servers.grpc.port $lbServerPort }} @@ -70,25 +78,25 @@ data: {{- include "vald.grpc.client" $ingressFilterGRPCClient | nindent 8 }} vectorizer: {{ $gateway.gateway_config.ingress_filter.vectorizer | quote }} {{- if $gateway.gateway_config.ingress_filter.search_filters }} - search_filters: + search_filters: {{- toYaml $gateway.gateway_config.ingress_filter.search_filters | nindent 8 }} {{- else }} search_filters: [] {{- end }} {{- if $gateway.gateway_config.ingress_filter.insert_filters }} - insert_filters: + insert_filters: {{- toYaml $gateway.gateway_config.ingress_filter.insert_filters | nindent 8 }} {{- else }} insert_filters: [] {{- end }} {{- if $gateway.gateway_config.ingress_filter.update_filters }} - update_filters: + update_filters: {{- toYaml $gateway.gateway_config.ingress_filter.update_filters | nindent 8 }} {{- else }} update_filters: [] {{- end }} {{- if $gateway.gateway_config.ingress_filter.upsert_filters }} - upsert_filters: + upsert_filters: {{- toYaml $gateway.gateway_config.ingress_filter.upsert_filters | nindent 8 }} {{- else }} upsert_filters: [] @@ -101,13 +109,13 @@ data: {{- $egressFilterGRPCClient := dict "Values" $egressFilterClient "default" .Values.defaults.grpc.client }} {{- include "vald.grpc.client" $egressFilterGRPCClient | nindent 8 }} {{- if $gateway.gateway_config.egress_filter.object_filters }} - object_filters: + object_filters: {{- toYaml $gateway.gateway_config.egress_filter.object_filters | nindent 8 }} {{- else }} object_filters: [] {{- end }} {{- if $gateway.gateway_config.egress_filter.distance_filters }} - distance_filters: + distance_filters: {{- toYaml $gateway.gateway_config.egress_filter.distance_filters | nindent 8 }} {{- else }} distance_filters: [] diff --git a/charts/vald/templates/gateway/ing.yaml b/charts/vald/templates/gateway/ing.yaml index d9dff5060c..f417c04f8b 100644 --- a/charts/vald/templates/gateway/ing.yaml +++ b/charts/vald/templates/gateway/ing.yaml @@ -62,7 +62,79 @@ spec: - host: {{ $gateway.ingress.host }} http: paths: - {{- if $filterIngEnabled }} + {{- if and $mirrorIngEnabled $filterIngEnabled $lb.enabled }} + - path: "/vald.v1.Search" + backend: + service: + name: {{ $filter.name }} + {{- include "vald.ingressPort" (dict "Values" $filter.ingress) | nindent 12 }} + pathType: {{ $filter.ingress.pathType }} + - path: "/vald.v1.Insert" + backend: + service: + name: {{ $filter.name }} + {{- include "vald.ingressPort" (dict "Values" $filter.ingress) | nindent 12 }} + pathType: {{ $filter.ingress.pathType }} + - path: "/vald.v1.Update" + backend: + service: + name: {{ $filter.name }} + {{- include "vald.ingressPort" (dict "Values" $filter.ingress) | nindent 12 }} + pathType: {{ $filter.ingress.pathType }} + - path: "/vald.v1.Upsert" + backend: + service: + name: {{ $filter.name }} + {{- include "vald.ingressPort" (dict "Values" $filter.ingress) | nindent 12 }} + pathType: {{ $filter.ingress.pathType }} + - path: "/vald.v1.Index" + backend: + service: + name: {{ $lb.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $lb.ingress.pathType }} + - path: "/vald.v1.Object.Exists" + backend: + service: + name: {{ $lb.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $lb.ingress.pathType }} + - path: "/vald.v1.Object.GetTimestamp" + backend: + service: + name: {{ $lb.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $lb.ingress.pathType }} + - path: "/vald.v1.Object" + backend: + service: + name: {{ $filter.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $filter.ingress.pathType }} + - backend: + service: + name: {{ $mirror.name }} + {{- include "vald.ingressPort" (dict "Values" $mirror.ingress) | nindent 12 }} + pathType: {{ $mirror.ingress.pathType }} + {{- else if and $filterIngEnabled $lb.enabled }} + - path: "/vald.v1.Index" + backend: + service: + name: {{ $lb.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $lb.ingress.pathType }} + - path: "/vald.v1.Object.Exists" + backend: + service: + name: {{ $lb.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $lb.ingress.pathType }} + - path: "/vald.v1.Object.GetTimestamp" + backend: + service: + name: {{ $lb.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $lb.ingress.pathType }} - backend: service: name: {{ $filter.name }} @@ -74,13 +146,31 @@ spec: service: name: {{ $lb.name }} {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} - pathType: {{ $mirror.ingress.pathType }} + pathType: {{ $lb.ingress.pathType }} + - path: "/vald.v1.Index" + backend: + service: + name: {{ $lb.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $lb.ingress.pathType }} + - path: "/vald.v1.Object.Exists" + backend: + service: + name: {{ $lb.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $lb.ingress.pathType }} + - path: "/vald.v1.Object.GetTimestamp" + backend: + service: + name: {{ $lb.name }} + {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} + pathType: {{ $lb.ingress.pathType }} - path: "/vald.v1.Object" backend: service: name: {{ $lb.name }} {{- include "vald.ingressPort" (dict "Values" $lb.ingress) | nindent 12 }} - pathType: {{ $mirror.ingress.pathType }} + pathType: {{ $lb.ingress.pathType }} - backend: service: name: {{ $mirror.name }} diff --git a/charts/vald/values.go b/charts/vald/values.go index 318b87248a..58e835e21d 100644 --- a/charts/vald/values.go +++ b/charts/vald/values.go @@ -13,9 +13,7 @@ // limitations under the License. package vald -import ( - "github.com/vdaas/vald/internal/config" -) +import "github.com/vdaas/vald/internal/config" // Affinity. type Affinity struct { diff --git a/charts/vald/values.schema.json b/charts/vald/values.schema.json index ef9c647eb7..772d20c328 100644 --- a/charts/vald/values.schema.json +++ b/charts/vald/values.schema.json @@ -103,6 +103,98 @@ "type": "string", "description": "external traffic policy (can be specified when service type is LoadBalancer or NodePort) : Cluster or Local" }, + "faiss": { + "type": "object", + "properties": { + "auto_index_check_duration": { + "type": "string", + "description": "check duration of automatic indexing" + }, + "auto_index_duration_limit": { + "type": "string", + "description": "limit duration of automatic indexing" + }, + "auto_index_length": { + "type": "integer", + "description": "number of cache to trigger automatic indexing" + }, + "auto_save_index_duration": { + "type": "string", + "description": "duration of automatic save index" + }, + "dimension": { + "type": "integer", + "description": "vector dimension", + "minimum": 1 + }, + "enable_copy_on_write": { + "type": "boolean", + "description": "enable copy on write saving for more stable backup" + }, + "enable_in_memory_mode": { + "type": "boolean", + "description": "in-memory mode enabled" + }, + "enable_proactive_gc": { + "type": "boolean", + "description": "enable proactive GC call for reducing heap memory allocation" + }, + "index_path": { + "type": "string", + "description": "path to index data" + }, + "initial_delay_max_duration": { + "type": "string", + "description": "maximum duration for initial delay" + }, + "kvsdb": { + "type": "object", + "properties": { + "concurrency": { + "type": "integer", + "description": "kvsdb processing concurrency" + } + } + }, + "load_index_timeout_factor": { + "type": "string", + "description": "a factor of load index timeout. timeout duration will be calculated by (index count to be loaded) * (factor)." + }, + "m": { "type": "integer" }, + "max_load_index_timeout": { + "type": "string", + "description": "maximum duration of load index timeout" + }, + "metric_type": { "type": "string", "enum": ["innerproduct", "l2"] }, + "min_load_index_timeout": { + "type": "string", + "description": "minimum duration of load index timeout" + }, + "namespace": { + "type": "string", + "description": "namespace of myself" + }, + "nbits_per_idx": { "type": "integer" }, + "nlist": { "type": "integer" }, + "pod_name": { + "type": "string", + "description": "pod name of myself" + }, + "vqueue": { + "type": "object", + "properties": { + "delete_buffer_pool_size": { + "type": "integer", + "description": "delete slice pool buffer size" + }, + "insert_buffer_pool_size": { + "type": "integer", + "description": "insert slice pool buffer size" + } + } + } + } + }, "hpa": { "type": "object", "properties": { @@ -277,6 +369,10 @@ "type": "boolean", "description": "enable proactive GC call for reducing heap memory allocation" }, + "enable_statistics": { + "type": "boolean", + "description": "enable index statistics loading" + }, "error_buffer_limit": { "type": "integer", "description": "maximum number of core ngt error buffer pool size limit", diff --git a/charts/vald/values.yaml b/charts/vald/values.yaml index c005ed1db6..4d7c2a052b 100644 --- a/charts/vald/values.yaml +++ b/charts/vald/values.yaml @@ -2174,6 +2174,83 @@ agent: # @schema {"name": "agent.ngt.error_buffer_limit", "type": "integer", "minimum": 1} # agent.ngt.error_buffer_limit -- maximum number of core ngt error buffer pool size limit error_buffer_limit: 10 + # @schema {"name": "agent.ngt.enable_statistics", "type": "boolean"} + # agent.ngt.enable_statistics -- enable index statistics loading + enable_statistics: false + # @schema {"name": "agent.faiss", "type": "object"} + faiss: + # @schema {"name": "agent.faiss.pod_name", "type": "string"} + # agent.faiss.pod_name -- pod name of myself + pod_name: _MY_POD_NAME_ + # @schema {"name": "agent.faiss.namespace", "type": "string"} + # agent.faiss.namespace -- namespace of myself + namespace: _MY_POD_NAMESPACE_ + # @schema {"name": "agent.faiss.index_path", "type": "string"} + # agent.faiss.index_path -- path to index data + index_path: "" + # @schema {"name": "agent.faiss.auto_index_duration_limit", "type": "string"} + # agent.faiss.auto_index_duration_limit -- limit duration of automatic indexing + auto_index_duration_limit: 24h + # @schema {"name": "agent.faiss.auto_index_check_duration", "type": "string"} + # agent.faiss.auto_index_check_duration -- check duration of automatic indexing + auto_index_check_duration: 30m + # @schema {"name": "agent.faiss.auto_index_length", "type": "integer"} + # agent.faiss.auto_index_length -- number of cache to trigger automatic indexing + auto_index_length: 100 + # @schema {"name": "agent.faiss.auto_save_index_duration", "type": "string"} + # agent.faiss.auto_save_index_duration -- duration of automatic save index + auto_save_index_duration: 35m + # @schema {"name": "agent.faiss.initial_delay_max_duration", "type": "string"} + # agent.faiss.initial_delay_max_duration -- maximum duration for initial delay + initial_delay_max_duration: 3m + # @schema {"name": "agent.faiss.dimension", "type": "integer", "minimum": 1} + # agent.faiss.dimension -- vector dimension + dimension: 4096 + # @schema {"name": "agent.faiss.metric_type", "type": "string", "enum": ["innerproduct", "l2"]} + # agent.faiss.metric_type-- metric type + # it should be `innerproduct` or `l2` + metric_type: l2 + # @schema {"name": "agent.faiss.nlist", "type": "integer"} + # agent.faiss.nlist-- nlist + nlist: 100 + # @schema {"name": "agent.faiss.m", "type": "integer"} + # agent.faiss.m-- m + m: 8 + # @schema {"name": "agent.faiss.nbits_per_idx", "type": "integer"} + # agent.faiss.nbits_per_idx-- nbits_per_idx + nbits_per_idx: 8 + # @schema {"name": "agent.faiss.enable_in_memory_mode", "type": "boolean"} + # agent.faiss.enable_in_memory_mode -- in-memory mode enabled + enable_in_memory_mode: true + # @schema {"name": "agent.faiss.min_load_index_timeout", "type": "string"} + # agent.faiss.min_load_index_timeout -- minimum duration of load index timeout + min_load_index_timeout: 3m + # @schema {"name": "agent.faiss.max_load_index_timeout", "type": "string"} + # agent.faiss.max_load_index_timeout -- maximum duration of load index timeout + max_load_index_timeout: 10m + # @schema {"name": "agent.faiss.load_index_timeout_factor", "type": "string"} + # agent.faiss.load_index_timeout_factor -- a factor of load index timeout. + # timeout duration will be calculated by (index count to be loaded) * (factor). + load_index_timeout_factor: 1ms + # @schema {"name": "agent.faiss.enable_proactive_gc", "type": "boolean"} + # agent.faiss.enable_proactive_gc -- enable proactive GC call for reducing heap memory allocation + enable_proactive_gc: false + # @schema {"name": "agent.faiss.enable_copy_on_write", "type": "boolean"} + # agent.faiss.enable_copy_on_write -- enable copy on write saving for more stable backup + enable_copy_on_write: false + # @schema {"name": "agent.faiss.vqueue", "type": "object"} + vqueue: + # @schema {"name": "agent.faiss.vqueue.insert_buffer_pool_size", "type": "integer"} + # agent.faiss.vqueue.insert_buffer_pool_size -- insert slice pool buffer size + insert_buffer_pool_size: 10000 + # @schema {"name": "agent.faiss.vqueue.delete_buffer_pool_size", "type": "integer"} + # agent.faiss.vqueue.delete_buffer_pool_size -- delete slice pool buffer size + delete_buffer_pool_size: 5000 + # @schema {"name": "agent.faiss.kvsdb", "type": "object"} + kvsdb: + # @schema {"name": "agent.faiss.kvsdb.concurrency", "type": "integer"} + # agent.faiss.kvsdb.concurrency -- kvsdb processing concurrency + concurrency: 6 # @schema {"name": "agent.sidecar", "type": "object"} sidecar: # @schema {"name": "agent.sidecar.enabled", "type": "boolean"} diff --git a/charts/vald/values/agent-ngt-standalone.yaml b/charts/vald/values/agent-ngt-standalone.yaml index 66fde669f6..2126d582d5 100644 --- a/charts/vald/values/agent-ngt-standalone.yaml +++ b/charts/vald/values/agent-ngt-standalone.yaml @@ -16,7 +16,7 @@ defaults: image: - tag: latest + tag: nightly agent: ngt: auto_index_duration_limit: 30m diff --git a/charts/vald/values/vald-backup-via-pv-and-s3.yaml b/charts/vald/values/vald-backup-via-pv-and-s3.yaml index 36d6f3267a..0e4c635a4f 100644 --- a/charts/vald/values/vald-backup-via-pv-and-s3.yaml +++ b/charts/vald/values/vald-backup-via-pv-and-s3.yaml @@ -15,7 +15,7 @@ # defaults: image: - tag: latest + tag: nightly gateway: lb: diff --git a/charts/vald/values/vald-backup-via-pv.yaml b/charts/vald/values/vald-backup-via-pv.yaml index 89f31a38fd..bf83930f5a 100644 --- a/charts/vald/values/vald-backup-via-pv.yaml +++ b/charts/vald/values/vald-backup-via-pv.yaml @@ -15,7 +15,7 @@ # defaults: image: - tag: latest + tag: nightly gateway: lb: resources: diff --git a/charts/vald/values/vald-backup-via-s3.yaml b/charts/vald/values/vald-backup-via-s3.yaml index 4bb143cbba..284c78ccfa 100644 --- a/charts/vald/values/vald-backup-via-s3.yaml +++ b/charts/vald/values/vald-backup-via-s3.yaml @@ -15,7 +15,7 @@ # defaults: image: - tag: latest + tag: nightly gateway: lb: diff --git a/charts/vald/values/vald-in-memory-mode-no-backup.yaml b/charts/vald/values/vald-in-memory-mode-no-backup.yaml index a42e0880a0..4f91bb0abd 100644 --- a/charts/vald/values/vald-in-memory-mode-no-backup.yaml +++ b/charts/vald/values/vald-in-memory-mode-no-backup.yaml @@ -15,7 +15,7 @@ # defaults: image: - tag: latest + tag: nightly gateway: lb: resources: diff --git a/cmd/agent/core/faiss/main.go b/cmd/agent/core/faiss/main.go index 3c78d90e65..87ce7d2f4e 100644 --- a/cmd/agent/core/faiss/main.go +++ b/cmd/agent/core/faiss/main.go @@ -41,14 +41,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Data)) }), ) diff --git a/cmd/agent/core/faiss/main_test.go b/cmd/agent/core/faiss/main_test.go new file mode 100644 index 0000000000..db40970b74 --- /dev/null +++ b/cmd/agent/core/faiss/main_test.go @@ -0,0 +1,86 @@ +// 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 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/cmd/agent/core/faiss/sample.yaml b/cmd/agent/core/faiss/sample.yaml index 238fccb89c..3b8952b365 100644 --- a/cmd/agent/core/faiss/sample.yaml +++ b/cmd/agent/core/faiss/sample.yaml @@ -115,7 +115,7 @@ faiss: load_index_timeout_factor: 1ms m: 8 # dimension % m == 0, train size >= 2^m(or nlist) * minPointsPerCentroid max_load_index_timeout: 10m - metric_type: "inner_product" + metric_type: "innerproduct" min_load_index_timeout: 3m nbits_per_idx: 8 nlist: 100 diff --git a/cmd/agent/core/ngt/main.go b/cmd/agent/core/ngt/main.go index c5365673a4..ac27a0842f 100644 --- a/cmd/agent/core/ngt/main.go +++ b/cmd/agent/core/ngt/main.go @@ -41,14 +41,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Data)) }), ) diff --git a/cmd/agent/core/ngt/main_test.go b/cmd/agent/core/ngt/main_test.go index 7445059b95..a5b983933e 100644 --- a/cmd/agent/core/ngt/main_test.go +++ b/cmd/agent/core/ngt/main_test.go @@ -20,8 +20,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/agent/sidecar/main.go b/cmd/agent/sidecar/main.go index 90fbf9cd63..1e32ab72fd 100644 --- a/cmd/agent/sidecar/main.go +++ b/cmd/agent/sidecar/main.go @@ -41,14 +41,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Data)) }), ) diff --git a/cmd/agent/sidecar/main_test.go b/cmd/agent/sidecar/main_test.go index 7445059b95..a5b983933e 100644 --- a/cmd/agent/sidecar/main_test.go +++ b/cmd/agent/sidecar/main_test.go @@ -20,8 +20,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/discoverer/k8s/main.go b/cmd/discoverer/k8s/main.go index bf50866778..a0a4242fa3 100644 --- a/cmd/discoverer/k8s/main.go +++ b/cmd/discoverer/k8s/main.go @@ -41,14 +41,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Data)) }), ) diff --git a/cmd/discoverer/k8s/main_test.go b/cmd/discoverer/k8s/main_test.go index 7445059b95..a5b983933e 100644 --- a/cmd/discoverer/k8s/main_test.go +++ b/cmd/discoverer/k8s/main_test.go @@ -20,8 +20,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/gateway/filter/main.go b/cmd/gateway/filter/main.go index 675d91cb79..fa5be90444 100644 --- a/cmd/gateway/filter/main.go +++ b/cmd/gateway/filter/main.go @@ -41,14 +41,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Data)) }), ) diff --git a/cmd/gateway/filter/main_test.go b/cmd/gateway/filter/main_test.go index 7445059b95..a5b983933e 100644 --- a/cmd/gateway/filter/main_test.go +++ b/cmd/gateway/filter/main_test.go @@ -20,8 +20,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/gateway/lb/main.go b/cmd/gateway/lb/main.go index 4fe52099e7..c1ec67e64f 100644 --- a/cmd/gateway/lb/main.go +++ b/cmd/gateway/lb/main.go @@ -41,14 +41,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Data)) }), ) diff --git a/cmd/gateway/lb/main_test.go b/cmd/gateway/lb/main_test.go index 7445059b95..a5b983933e 100644 --- a/cmd/gateway/lb/main_test.go +++ b/cmd/gateway/lb/main_test.go @@ -20,8 +20,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/gateway/mirror/main.go b/cmd/gateway/mirror/main.go index ed7658c40d..a535835e39 100644 --- a/cmd/gateway/mirror/main.go +++ b/cmd/gateway/mirror/main.go @@ -37,14 +37,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { c, ok := cfg.(*config.Data) if !ok { return nil, errors.ErrInvalidConfig diff --git a/cmd/gateway/mirror/main_test.go b/cmd/gateway/mirror/main_test.go new file mode 100644 index 0000000000..db40970b74 --- /dev/null +++ b/cmd/gateway/mirror/main_test.go @@ -0,0 +1,86 @@ +// 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 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/cmd/index/job/correction/main.go b/cmd/index/job/correction/main.go index 6067748403..705f4f5e20 100644 --- a/cmd/index/job/correction/main.go +++ b/cmd/index/job/correction/main.go @@ -37,14 +37,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { c, ok := cfg.(*config.Data) if !ok { return nil, errors.ErrInvalidConfig diff --git a/cmd/index/job/correction/main_test.go b/cmd/index/job/correction/main_test.go index 6305e83cdb..db40970b74 100644 --- a/cmd/index/job/correction/main_test.go +++ b/cmd/index/job/correction/main_test.go @@ -16,8 +16,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/index/job/creation/main.go b/cmd/index/job/creation/main.go index c17b3b3209..f43bb58715 100644 --- a/cmd/index/job/creation/main.go +++ b/cmd/index/job/creation/main.go @@ -37,14 +37,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { c, ok := cfg.(*config.Data) if !ok { return nil, errors.ErrInvalidConfig diff --git a/cmd/index/job/creation/main_test.go b/cmd/index/job/creation/main_test.go index 6305e83cdb..db40970b74 100644 --- a/cmd/index/job/creation/main_test.go +++ b/cmd/index/job/creation/main_test.go @@ -16,8 +16,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/index/job/readreplica/rotate/main.go b/cmd/index/job/readreplica/rotate/main.go index b35315e1c8..fe23e3c3a3 100644 --- a/cmd/index/job/readreplica/rotate/main.go +++ b/cmd/index/job/readreplica/rotate/main.go @@ -37,14 +37,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { c, ok := cfg.(*config.Data) if !ok { return nil, errors.ErrInvalidConfig diff --git a/cmd/index/job/readreplica/rotate/main_test.go b/cmd/index/job/readreplica/rotate/main_test.go index 6305e83cdb..db40970b74 100644 --- a/cmd/index/job/readreplica/rotate/main_test.go +++ b/cmd/index/job/readreplica/rotate/main_test.go @@ -16,8 +16,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/index/job/save/main.go b/cmd/index/job/save/main.go index 5c753b0686..a5b445ca8b 100644 --- a/cmd/index/job/save/main.go +++ b/cmd/index/job/save/main.go @@ -37,14 +37,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { c, ok := cfg.(*config.Data) if !ok { return nil, errors.ErrInvalidConfig diff --git a/cmd/index/job/save/main_test.go b/cmd/index/job/save/main_test.go index 6305e83cdb..db40970b74 100644 --- a/cmd/index/job/save/main_test.go +++ b/cmd/index/job/save/main_test.go @@ -16,8 +16,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/index/operator/main.go b/cmd/index/operator/main.go index d09c1dfb78..bcff12d18e 100644 --- a/cmd/index/operator/main.go +++ b/cmd/index/operator/main.go @@ -37,14 +37,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { c, ok := cfg.(*config.Data) if !ok { return nil, errors.ErrInvalidConfig diff --git a/cmd/index/operator/main_test.go b/cmd/index/operator/main_test.go new file mode 100644 index 0000000000..db40970b74 --- /dev/null +++ b/cmd/index/operator/main_test.go @@ -0,0 +1,86 @@ +// 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 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/cmd/manager/index/main.go b/cmd/manager/index/main.go index 6d4dfb01ef..ea7bfa6e46 100644 --- a/cmd/manager/index/main.go +++ b/cmd/manager/index/main.go @@ -41,14 +41,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Data)) }), ) diff --git a/cmd/manager/index/main_test.go b/cmd/manager/index/main_test.go index 7445059b95..a5b983933e 100644 --- a/cmd/manager/index/main_test.go +++ b/cmd/manager/index/main_test.go @@ -20,8 +20,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/tools/benchmark/job/main.go b/cmd/tools/benchmark/job/main.go index c7badde186..b24ade2084 100644 --- a/cmd/tools/benchmark/job/main.go +++ b/cmd/tools/benchmark/job/main.go @@ -42,14 +42,14 @@ func main() { ctx, runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(ctx, path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Config)) }), ) diff --git a/cmd/tools/benchmark/job/main_test.go b/cmd/tools/benchmark/job/main_test.go new file mode 100644 index 0000000000..db40970b74 --- /dev/null +++ b/cmd/tools/benchmark/job/main_test.go @@ -0,0 +1,86 @@ +// 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 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/cmd/tools/benchmark/operator/main.go b/cmd/tools/benchmark/operator/main.go index 6d3e2d0d12..3975ca246e 100644 --- a/cmd/tools/benchmark/operator/main.go +++ b/cmd/tools/benchmark/operator/main.go @@ -41,14 +41,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Config)) }), ) diff --git a/cmd/tools/benchmark/operator/main_test.go b/cmd/tools/benchmark/operator/main_test.go new file mode 100644 index 0000000000..db40970b74 --- /dev/null +++ b/cmd/tools/benchmark/operator/main_test.go @@ -0,0 +1,86 @@ +// 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 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/cmd/tools/cli/benchmark/core/main.go b/cmd/tools/cli/benchmark/core/main.go index 4a1c41baef..02e8685445 100644 --- a/cmd/tools/cli/benchmark/core/main.go +++ b/cmd/tools/cli/benchmark/core/main.go @@ -163,7 +163,7 @@ func main() { var m runtime.MemStats runtime.ReadMemStats(&m) - metrics := []interface{}{ + metrics := []any{ header, vmpeak, vmsize, @@ -346,7 +346,16 @@ func main() { }) } -func run(ctx context.Context, load bool, path string, dim int, vectors [][]float32, ids []uint, dur time.Duration, output func(header string)) { +func run( + ctx context.Context, + load bool, + path string, + dim int, + vectors [][]float32, + ids []uint, + dur time.Duration, + output func(header string), +) { const poolSize = 8 var n ngt.NGT if load { diff --git a/cmd/tools/cli/benchmark/core/main_test.go b/cmd/tools/cli/benchmark/core/main_test.go index 8e326fbcfe..be6c73c06d 100644 --- a/cmd/tools/cli/benchmark/core/main_test.go +++ b/cmd/tools/cli/benchmark/core/main_test.go @@ -16,8 +16,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want @@ -97,8 +96,7 @@ package main // dur time.Duration // output func(header string) // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -196,8 +194,7 @@ package main // fn func() // efn func() // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -370,7 +367,6 @@ package main // if err := checkFunc(test.want, gotTrain, gotTest, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/cmd/tools/cli/loadtest/main.go b/cmd/tools/cli/loadtest/main.go index d784d2d924..205cf86933 100644 --- a/cmd/tools/cli/loadtest/main.go +++ b/cmd/tools/cli/loadtest/main.go @@ -37,14 +37,14 @@ func main() { context.Background(), runner.WithName(name), runner.WithVersion(info.Version, maxVersion, minVersion), - runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { + runner.WithConfigLoader(func(path string) (any, *config.GlobalConfig, error) { cfg, err := config.NewConfig(path) if err != nil { return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") } return cfg, &cfg.GlobalConfig, nil }), - runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { + runner.WithDaemonInitializer(func(cfg any) (runner.Runner, error) { return usecase.New(cfg.(*config.Data)) }), ) diff --git a/cmd/tools/cli/loadtest/main_test.go b/cmd/tools/cli/loadtest/main_test.go index 6305e83cdb..db40970b74 100644 --- a/cmd/tools/cli/loadtest/main_test.go +++ b/cmd/tools/cli/loadtest/main_test.go @@ -16,8 +16,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/cmd/tools/cli/vdctl/main_test.go b/cmd/tools/cli/vdctl/main_test.go index 83b7cc068c..a186340cf0 100644 --- a/cmd/tools/cli/vdctl/main_test.go +++ b/cmd/tools/cli/vdctl/main_test.go @@ -19,8 +19,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want diff --git a/dockers/agent/core/agent/Dockerfile b/dockers/agent/core/agent/Dockerfile index 726571fac6..c13f258679 100644 --- a/dockers/agent/core/agent/Dockerfile +++ b/dockers/agent/core/agent/Dockerfile @@ -15,81 +15,84 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/cc-debian12 -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" ARG TARGETARCH ARG TARGETOS +ARG GO_VERSION ARG RUST_VERSION - -ENV RUST_HOME /usr/local/lib/rust -ENV RUSTUP_HOME ${RUST_HOME}/rustup -ENV CARGO_HOME ${RUST_HOME}/cargo -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV PATH ${PATH}:${RUSTUP_HOME}/bin:${CARGO_HOME}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG agent/core/ngt -ENV APP_NAME ngt - +ENV APP_NAME=agent +ENV DEBIAN_FRONTEND=noninteractive +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=agent/core/agent +ENV REPO=vald +ENV RUST_HOME=/usr/loacl/lib/rust +ENV RUSTUP_HOME=${RUST_HOME}/rustup +ENV CARGO_HOME=${RUST_HOME}/cargo +ENV PATH=${CARGO_HOME}/bin:${RUSTUP_HOME}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ ca-certificates \ - cmake \ curl \ + git \ + cmake \ g++ \ gcc \ - git \ + unzip \ liblapack-dev \ libomp-dev \ libopenblas-dev \ - unzip \ - upx \ + gfortran \ && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +WORKDIR ${HOME}/rust/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . - -RUN make RUST_VERSION=${RUST_VERSION} rust/install - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd -COPY cmd . - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +WORKDIR ${HOME}/rust/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${HOME}/rust/src/github.com/${ORG}/${REPO}/versions COPY versions . - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/rust +WORKDIR ${HOME}/rust/src/github.com/${ORG}/${REPO}/rust COPY rust . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} -RUN make ngt/install - -RUN make rust/target/release/agent \ - && mv ./rust/target/release/agent "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +WORKDIR ${HOME}/rust/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 +RUN make RUST_VERSION="${RUST_VERSION}" rust/install \ + && make ngt/install \ + && make faiss/install \ + && make rust/target/release/${APP_NAME} \ + && mv "rust/target/release/${APP_NAME}" "/usr/bin/${APP_NAME}" \ + && rm -rf rust/target +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/cc-debian12:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME ngt +ENV APP_NAME=agent COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} -COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/usr/bin/ngt"] +ENTRYPOINT ["/usr/bin/agent"] diff --git a/dockers/agent/core/faiss/Dockerfile b/dockers/agent/core/faiss/Dockerfile index 6e88b55a81..d9755d36c1 100644 --- a/dockers/agent/core/faiss/Dockerfile +++ b/dockers/agent/core/faiss/Dockerfile @@ -15,111 +15,97 @@ # limitations under the License. # -# ARG DISTROLESS_IMAGE=gcr.io/distroless/static -# ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" ARG TARGETARCH ARG TARGETOS ARG GO_VERSION - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG agent/core/faiss -ENV PKG_INTERNAL agent/internal -ENV APP_NAME faiss - +ARG RUST_VERSION +ENV APP_NAME=faiss +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=agent/core/faiss +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ ca-certificates \ - cmake \ curl \ + git \ + cmake \ g++ \ gcc \ - git \ - intel-mkl \ unzip \ - upx \ + liblapack-dev \ + libomp-dev \ + libopenblas-dev \ + gfortran \ && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/agent/internal +COPY pkg/agent/internal . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG_INTERNAL} -COPY pkg/${PKG_INTERNAL} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} -RUN update-alternatives --set libblas.so-x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libmkl_rt.so \ - && make faiss/install - +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make faiss/install \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ubuntu:devel +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME faiss +ENV APP_NAME=faiss -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - -COPY --from=builder /usr/local/lib/libfaiss.so /usr/local/lib/libfaiss.so -COPY --from=builder /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -COPY --from=builder /lib/x86_64-linux-gnu/libstdc++.so.6 /lib/x86_64-linux-gnu/libstdc++.so.6 -COPY --from=builder /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/libgcc_s.so.1 -COPY --from=builder /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6 -COPY --from=builder /lib/x86_64-linux-gnu/libmkl_intel_lp64.so /lib/x86_64-linux-gnu/libmkl_intel_lp64.so -COPY --from=builder /lib/x86_64-linux-gnu/libmkl_sequential.so /lib/x86_64-linux-gnu/libmkl_sequential.so -COPY --from=builder /lib/x86_64-linux-gnu/libmkl_core.so /lib/x86_64-linux-gnu/libmkl_core.so -COPY --from=builder /lib/x86_64-linux-gnu/libgomp.so.1 /lib/x86_64-linux-gnu/libgomp.so.1 -COPY --from=builder /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/libm.so.6 -COPY --from=builder /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libdl.so.2 -COPY --from=builder /lib/x86_64-linux-gnu/libpthread.so.0 /lib/x86_64-linux-gnu/libpthread.so.0 -COPY --from=builder /lib/x86_64-linux-gnu/libmkl_avx2.so /lib/x86_64-linux-gnu/libmkl_avx2.so -RUN ldconfig -v - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/faiss"] +ENTRYPOINT ["/usr/bin/faiss"] diff --git a/dockers/agent/core/ngt/Dockerfile b/dockers/agent/core/ngt/Dockerfile index ecc852f2f2..f1ef1aa20e 100644 --- a/dockers/agent/core/ngt/Dockerfile +++ b/dockers/agent/core/ngt/Dockerfile @@ -15,97 +15,96 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" ARG TARGETARCH ARG TARGETOS ARG GO_VERSION - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG agent/core/ngt -ENV PKG_INTERNAL agent/internal -ENV APP_NAME ngt - +ARG RUST_VERSION +ENV APP_NAME=ngt +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=agent/core/ngt +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ ca-certificates \ - cmake \ curl \ + git \ + cmake \ g++ \ gcc \ - git \ + unzip \ liblapack-dev \ libomp-dev \ libopenblas-dev \ - unzip \ - upx \ && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/agent/internal +COPY pkg/agent/internal . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG_INTERNAL} -COPY pkg/${PKG_INTERNAL} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} -RUN make ngt/install - +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make ngt/install \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME ngt +ENV APP_NAME=ngt -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/ngt"] +ENTRYPOINT ["/usr/bin/ngt"] diff --git a/dockers/agent/sidecar/Dockerfile b/dockers/agent/sidecar/Dockerfile index e511fdaeef..21cdfea4d0 100644 --- a/dockers/agent/sidecar/Dockerfile +++ b/dockers/agent/sidecar/Dockerfile @@ -15,83 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV GOPATH /go -ENV GOROOT /opt/go -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV ORG vdaas -ENV REPO vald -ENV APP_NAME sidecar -ENV PKG agent/sidecar -ENV PKG_INTERNAL agent/internal -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=sidecar +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=agent/sidecar +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/agent/internal +COPY pkg/agent/internal . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG_INTERNAL} -COPY pkg/${PKG_INTERNAL} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME sidecar - -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +ENV APP_NAME=sidecar +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/sidecar"] +ENTRYPOINT ["/usr/bin/sidecar"] diff --git a/dockers/buildbase/Dockerfile b/dockers/buildbase/Dockerfile new file mode 100644 index 0000000000..9be2e4b20b --- /dev/null +++ b/dockers/buildbase/Dockerfile @@ -0,0 +1,18 @@ +# syntax = docker/dockerfile:latest +# +# 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. +# + +FROM ubuntu:devel AS builder diff --git a/dockers/ci/base/Dockerfile b/dockers/ci/base/Dockerfile index 745731c716..f6e4aae0c6 100644 --- a/dockers/ci/base/Dockerfile +++ b/dockers/ci/base/Dockerfile @@ -15,85 +15,110 @@ # limitations under the License. # -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin:/usr/local/bin - -RUN sysctl -w net.ipv6.conf.all.disable_ipv6=1 \ - && sysctl -w net.ipv6.conf.default.disable_ipv6=1 \ - && sysctl -w net.ipv6.conf.lo.disable_ipv6=1 +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=ci-container +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=ci/base +ENV REPO=vald +ENV RUST_HOME=/usr/loacl/lib/rust +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} SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ ca-certificates \ - cmake \ curl \ + git \ + cmake \ g++ \ - gawk \ gcc \ + unzip \ + liblapack-dev \ + libomp-dev \ + libopenblas-dev \ + gfortran \ + curl \ + gawk \ git \ gnupg2 \ graphviz \ jq \ libhdf5-dev \ - liblapack-dev \ - libomp-dev \ - libopenblas-dev \ + libaec-dev \ nodejs \ npm \ sed \ - unzip \ zip \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR ${GOPATH}/src/github.com/vdaas/vald - -ENV ROOTDIR . + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . -COPY Makefile.d Makefile.d -COPY apis/proto apis/proto -COPY example/client/go.mod.default example/client/go.mod.default -COPY go.mod . -COPY go.sum . -COPY hack/go.mod.default hack/go.mod.default -COPY rust rust -COPY versions versions +COPY .git . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +COPY . . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} deps ROOTDIR=${ROOTDIR} GO_CLEAN_DEPS=false \ - && make ngt/install \ - && make faiss/install \ - && make helm/install \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make RUST_VERSION="${RUST_VERSION}" rust/install \ + && sysctl -w net.ipv6.conf.all.disable_ipv6=1 \ + && sysctl -w net.ipv6.conf.default.disable_ipv6=1 \ + && sysctl -w net.ipv6.conf.lo.disable_ipv6=1 \ + && sysctl -p \ + && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} deps GO_CLEAN_DEPS=false \ + && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} golangci-lint/install \ + && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} gotestfmt/install \ + && make buf/install \ + && make hdf5/install \ && make helm-docs/install \ + && make helm/install \ + && make k3d/install \ + && make k9s/install \ && make kind/install \ - && make valdcli/install \ + && make kubectl/install \ && make kubelinter/install \ - && make yq/install \ - && make tparse/install \ - && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} gotestfmt/install \ - && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} golangci-lint/install \ && make reviewdog/install \ - && make kubectl/install \ - && make k3d/install \ - && make buf/install \ - && make k9s/install \ - && rm -rf "${GOPATH}/src/github.com/vdaas/vald/*" + && make tparse/install \ + && make valdcli/install \ + && make yq/install \ + && make minikube/install \ + && make stern/install \ + && make telepresence/install \ + && make ngt/install \ + && make faiss/install \ + && rm -rf ${GOPATH}/src/github.com/${ORG}/${REPO}/* diff --git a/dockers/dev/Dockerfile b/dockers/dev/Dockerfile index 3a3f2ce617..d7409e637e 100644 --- a/dockers/dev/Dockerfile +++ b/dockers/dev/Dockerfile @@ -15,79 +15,113 @@ # limitations under the License. # -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go +ARG UPX_OPTIONS=-9 # skipcq: DOK-DL3026 -# we should stick to official devcontainers as a base image because it is well tested to be used with the vscode devcontainer extension. -FROM --platform=${TARGETPLATFORM} mcr.microsoft.com/vscode/devcontainers/base:debian +FROM mcr.microsoft.com/vscode/devcontainers/base:debian +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin:/usr/local/bin +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=dev-container +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=dev +ENV REPO=vald +ENV RUST_HOME=/usr/loacl/lib/rust +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} SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ ca-certificates \ - cmake \ curl \ + git \ + cmake \ g++ \ - gawk \ gcc \ + unzip \ + liblapack-dev \ + libomp-dev \ + libopenblas-dev \ + gfortran \ + curl \ + gawk \ git \ gnupg2 \ graphviz \ jq \ libhdf5-dev \ - liblapack-dev \ - libomp-dev \ - libopenblas-dev \ + libaec-dev \ nodejs \ npm \ sed \ - unzip \ zip \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR ${GOPATH}/src/github.com/vdaas/vald + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . -COPY Makefile.d Makefile.d -COPY versions versions -COPY rust rust -COPY hack/go.mod.default hack/go.mod.default -COPY example/client/go.mod.default example/client/go.mod.default +COPY .git . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +COPY . . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make RUST_VERSION="${RUST_VERSION}" rust/install \ && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} deps GO_CLEAN_DEPS=false \ - && make ngt/install \ - && make faiss/install \ - && make helm/install \ - && make helm-docs/install \ - && make valdcli/install \ - && make yq/install \ && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} golangci-lint/install \ - && make reviewdog/install \ - && make kubectl/install \ - && make k3d/install \ + && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} gotestfmt/install \ && make buf/install \ + && make hdf5/install \ + && make helm-docs/install \ + && make helm/install \ + && make k3d/install \ && make k9s/install \ + && make kind/install \ + && make kubectl/install \ + && make kubelinter/install \ + && make reviewdog/install \ + && make tparse/install \ + && make valdcli/install \ + && make yq/install \ && make minikube/install \ && make stern/install \ && make telepresence/install \ && echo "installing golang vscode extension dependencies" \ + && make delve/install \ + && make gomodifytags/install \ && make gopls/install \ && make gotests/install \ - && make gomodifytags/install \ && make impl/install \ - && make delve/install \ - && make staticcheck/install + && make staticcheck/install \ + && make ngt/install \ + && make faiss/install \ + && rm -rf ${GOPATH}/src/github.com/${ORG}/${REPO}/* diff --git a/dockers/discoverer/k8s/Dockerfile b/dockers/discoverer/k8s/Dockerfile index 70fa029a3b..28fd4770c7 100644 --- a/dockers/discoverer/k8s/Dockerfile +++ b/dockers/discoverer/k8s/Dockerfile @@ -15,84 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG discoverer/k8s -ENV APP_NAME discoverer - - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=discoverer +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=discoverer/k8s +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME discoverer +ENV APP_NAME=discoverer -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/discoverer"] +ENTRYPOINT ["/usr/bin/discoverer"] diff --git a/dockers/gateway/filter/Dockerfile b/dockers/gateway/filter/Dockerfile index cd9e486e46..b2f5478a5c 100644 --- a/dockers/gateway/filter/Dockerfile +++ b/dockers/gateway/filter/Dockerfile @@ -15,83 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG gateway/filter -ENV APP_NAME filter - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=filter +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=gateway/filter +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME filter +ENV APP_NAME=filter -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/filter"] +ENTRYPOINT ["/usr/bin/filter"] diff --git a/dockers/gateway/lb/Dockerfile b/dockers/gateway/lb/Dockerfile index 083dbf0c65..bf78cc7ad8 100644 --- a/dockers/gateway/lb/Dockerfile +++ b/dockers/gateway/lb/Dockerfile @@ -15,83 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG gateway/lb -ENV APP_NAME lb - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=lb +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=gateway/lb +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME lb +ENV APP_NAME=lb -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/lb"] +ENTRYPOINT ["/usr/bin/lb"] diff --git a/dockers/gateway/mirror/Dockerfile b/dockers/gateway/mirror/Dockerfile index 0059578185..c52c633a04 100644 --- a/dockers/gateway/mirror/Dockerfile +++ b/dockers/gateway/mirror/Dockerfile @@ -14,79 +14,87 @@ # See the License for the specific language governing permissions and # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go + +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG gateway/mirror -ENV APP_NAME mirror - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=mirror +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=gateway/mirror +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} -LABEL maintainer "${MAINTAINER}" - -ENV APP_NAME mirror - -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +ENV APP_NAME=mirror +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} +COPY --from=builder /tmp/config.yaml /etc/server/config.yaml USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/mirror"] +ENTRYPOINT ["/usr/bin/mirror"] diff --git a/dockers/index/job/correction/Dockerfile b/dockers/index/job/correction/Dockerfile index 56eb6d3bca..269648c226 100644 --- a/dockers/index/job/correction/Dockerfile +++ b/dockers/index/job/correction/Dockerfile @@ -15,83 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG index/job/correction -ENV APP_NAME index-correction - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=index-correction +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=index/job/correction +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME index-correction +ENV APP_NAME=index-correction -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/index-correction"] +ENTRYPOINT ["/usr/bin/index-correction"] diff --git a/dockers/index/job/creation/Dockerfile b/dockers/index/job/creation/Dockerfile index c3d67126c4..6af94e2436 100644 --- a/dockers/index/job/creation/Dockerfile +++ b/dockers/index/job/creation/Dockerfile @@ -15,83 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG index/job/creation -ENV APP_NAME index-creation - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=index-creation +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=index/job/creation +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME index-creation +ENV APP_NAME=index-creation -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/index-creation"] +ENTRYPOINT ["/usr/bin/index-creation"] diff --git a/dockers/index/job/readreplica/rotate/Dockerfile b/dockers/index/job/readreplica/rotate/Dockerfile index 41e9b8ff7f..4fac5a23a2 100644 --- a/dockers/index/job/readreplica/rotate/Dockerfile +++ b/dockers/index/job/readreplica/rotate/Dockerfile @@ -15,83 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG index/job/readreplica/rotate -ENV APP_NAME readreplica-rotate - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=readreplica-rotate +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=index/job/readreplica/rotate +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME readreplica-rotate +ENV APP_NAME=readreplica-rotate -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/readreplica-rotate"] +ENTRYPOINT ["/usr/bin/readreplica-rotate"] diff --git a/dockers/index/job/save/Dockerfile b/dockers/index/job/save/Dockerfile index 057c94d209..2af2997b22 100644 --- a/dockers/index/job/save/Dockerfile +++ b/dockers/index/job/save/Dockerfile @@ -15,83 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG index/job/save -ENV APP_NAME index-save - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=index-save +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=index/job/save +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME index-save +ENV APP_NAME=index-save -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/index-save"] +ENTRYPOINT ["/usr/bin/index-save"] diff --git a/dockers/index/operator/Dockerfile b/dockers/index/operator/Dockerfile index ab3a2d4a5c..ab6931a089 100644 --- a/dockers/index/operator/Dockerfile +++ b/dockers/index/operator/Dockerfile @@ -15,84 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG index/operator -ENV APP_NAME index-operator - - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=index-operator +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=index/operator +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME index-operator +ENV APP_NAME=index-operator -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/index-operator"] +ENTRYPOINT ["/usr/bin/index-operator"] diff --git a/dockers/manager/index/Dockerfile b/dockers/manager/index/Dockerfile index ced3126419..0475251f4c 100644 --- a/dockers/manager/index/Dockerfile +++ b/dockers/manager/index/Dockerfile @@ -15,83 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV PKG manager/index -ENV APP_NAME index - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=index +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=manager/index +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME index +ENV APP_NAME=index -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/index"] +ENTRYPOINT ["/usr/bin/index"] diff --git a/dockers/operator/helm/Dockerfile b/dockers/operator/helm/Dockerfile index 3fffbf842a..1e7f1a4bf5 100644 --- a/dockers/operator/helm/Dockerfile +++ b/dockers/operator/helm/Dockerfile @@ -14,41 +14,36 @@ # See the License for the specific language governing permissions and # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot -ARG OPERATOR_SDK_VERSION -ARG UPX_OPTIONS=-9 -ARG VERSION="v1" -ARG GROUP="vald.vdaas.org" -ARG VALD_KIND="ValdRelease" -ARG VALD_HELM_OPERATOR_KIND="ValdHelmOperatorRelease" -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go + +ARG UPX_OPTIONS=-9 +ARG OPERATOR_SDK_VERSION=latest +# skipcq: DOK-DL3026 +FROM quay.io/operator-framework/helm-operator:${OPERATOR_SDK_VERSION} AS operator # skipcq: DOK-DL3026 -FROM --platform=${TARGETPLATFORM} quay.io/operator-framework/helm-operator:${OPERATOR_SDK_VERSION} AS operator -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION -ARG OPERATOR_SDK_VERSION -ARG VERSION -ARG GROUP -ARG VALD_KIND -ARG VALD_HELM_OPERATOR_KIND -ARG UPX_OPTIONS ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV APP_NAME helm-operator - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=helm-operator +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=operator/helm +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 RUN apt-get clean \ && rm -rf \ @@ -57,11 +52,11 @@ RUN apt-get clean \ && apt-get update -y \ && apt-get upgrade -y \ && apt-get install -y --no-install-recommends --fix-missing \ - ca-certificates \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + upx \ && ldconfig \ && apt-get clean \ && rm -rf \ @@ -69,75 +64,55 @@ RUN apt-get clean \ /var/cache/* \ && apt-get autoremove -RUN { \ - echo "---"; \ - echo "- version: ${VERSION}"; \ - echo " group: ${GROUP}"; \ - echo " kind: ${VALD_KIND}"; \ - echo " chart: helm-charts/vald"; \ - echo "- version: ${VERSION}"; \ - echo " group: ${GROUP}"; \ - echo " kind: ${VALD_HELM_OPERATOR_KIND}"; \ - echo " chart: helm-charts/vald-helm-operator"; \ - } > /tmp/watches.yaml - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal/errors -COPY internal/errors . - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal/log -COPY internal/log . - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal/conv -COPY internal/conv . - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal/sync -COPY internal/sync . - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal/strings -COPY internal/strings . - +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions COPY versions . - +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal +COPY internal . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/charts COPY charts . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/hack COPY hack . +COPY --from=operator /usr/local/bin/${APP_NAME} /usr/bin/${APP_NAME} WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} -RUN make GOARCH=${TARGETARCH} GOOS=${TARGETOS} helm/schema/vald \ +#skipcq: DOK-W1001, DOK-SC2086 +RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ + --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && mkdir -p /opt/helm/charts \ + && { \ + echo "---"; \ + echo "- version: v1"; \ + echo " group: vald.vdaas.org"; \ + echo " kind: ValdRelease"; \ + echo " chart: /opt/helm/charts/vald"; \ + echo "- version: v1"; \ + echo " group: vald.vdaas.org"; \ + echo " kind: ValdHelmOperatorRelease"; \ + echo " chart: /opt/helm/charts/vald-helm-operator"; \ + } > /opt/helm/watches.yaml \ + && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} helm/schema/vald \ && make GOARCH=${TARGETARCH} GOOS=${TARGETOS} helm/schema/vald-helm-operator \ - && cp -r charts /charts - -COPY --from=operator /usr/local/bin/${APP_NAME} /usr/bin/${APP_NAME} - -RUN upx ${UPX_OPTIONS} "/usr/bin/${APP_NAME}" - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} + && cp -r charts/* /opt/helm/charts/ \ + && upx "/usr/bin/${APP_NAME}" +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME helm-operator - -ENV HOME=/opt/helm -WORKDIR ${HOME} +ENV APP_NAME=helm-operator -COPY --from=builder /tmp/watches.yaml watches.yaml -COPY --from=builder /charts/vald helm-charts/vald -COPY --from=builder /charts/vald-helm-operator helm-charts/vald-helm-operator COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} - +COPY --from=builder /opt/helm/watches.yaml /opt/helm/watches.yaml +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 USER nonroot:nonroot - -ENTRYPOINT ["/usr/bin/helm-operator", "run", "--watches-file=./watches.yaml"] +ENTRYPOINT ["/usr/bin/helm-operator", "run", "--watches-file=/opt/helm/watches.yaml"] diff --git a/dockers/readreplica/job/readreplica/rotate/Dockerfile b/dockers/readreplica/job/readreplica/rotate/Dockerfile new file mode 100644 index 0000000000..f04b8fd16f --- /dev/null +++ b/dockers/readreplica/job/readreplica/rotate/Dockerfile @@ -0,0 +1,110 @@ +# syntax = docker/dockerfile:latest +# +# 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. +# + +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go + +ARG RUNTIME_IMAGE=gcr.io/distroless/static +ARG RUNTIME_IMAGE_TAG=nonroot +ARG UPX_OPTIONS=-9 +ARG MAINTAINER="vdaas.org vald team " + +FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +LABEL maintainer="${MAINTAINER}" + +ARG TARGETARCH +ARG TARGETOS +ARG GO_VERSION + +ENV GO111MODULE=on +ENV DEBIAN_FRONTEND=noninteractive +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV GOROOT=/opt/go +ENV GOPATH=/go +ENV PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin:/usr/local/bin +ENV ORG=vdaas +ENV REPO=vald +ENV PKG=readreplica/job/readreplica/rotate + +ENV APP_NAME=readreplica-rotate + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# skipcq: DOK-DL3008 +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + g++ \ + gcc \ + git \ + unzip \ + upx \ + && ldconfig \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +COPY Makefile . +COPY .git . +COPY go.mod . +COPY go.sum . + +RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ + --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ + make GO_VERSION=${GO_VERSION} go/install \ + && make go/download + +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal +COPY internal . + +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc +COPY apis/grpc . + +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} +COPY pkg/${PKG} . + +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} +COPY cmd/${PKG} . + +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . + +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} + +RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ + --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ + make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" + +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} +RUN cp sample.yaml /tmp/config.yaml + +FROM --platform=${TARGETPLATFORM} ${RUNTIME_IMAGE}:${RUNTIME_IMAGE_TAG} +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" + +ENV APP_NAME=readreplica-rotate + +COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /tmp/config.yaml /etc/server/config.yaml + +USER nonroot:nonroot + +ENTRYPOINT ["/go/bin/readreplica-rotate"] diff --git a/dockers/tools/benchmark/job/Dockerfile b/dockers/tools/benchmark/job/Dockerfile index d7ce37b64f..a75d7645d7 100644 --- a/dockers/tools/benchmark/job/Dockerfile +++ b/dockers/tools/benchmark/job/Dockerfile @@ -15,113 +15,93 @@ # limitations under the License. # -ARG ZLIB_VERSION -ARG HDF5_VERSION -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go + ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder - -ARG GO_VERSION -ARG UPX_OPTIONS -ARG ZLIB_VERSION -ARG HDF5_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV APP_NAME job -ENV PKG tools/benchmark/${APP_NAME} -ENV BUILD_DIR=/usr/local -ENV LIB_DIR=/usr/local/lib -ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${LIB_DIR}:/lib - -# skipcq: DOK-DL3008, DOK-DL3003 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=job +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=tools/benchmark/job +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# skipcq: DOK-DL3008 +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ - g++ \ git \ + cmake \ + g++ \ + gcc \ + unzip \ + libhdf5-dev \ + libaec-dev \ && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* \ - && mkdir -p ${LIB_DIR} \ - && curl -fsSLO https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz \ - && mkdir -p zlib \ - && tar -xzvf zlib-${ZLIB_VERSION}.tar.gz -C zlib --strip-components 1 \ - && cd zlib \ - && ./configure --prefix=${LIB_DIR} --static \ - && make \ - && make test \ - && make install \ - && cd / \ - && mkdir -p hdf5 \ - && curl -fsSLO https://github.com/HDFGroup/hdf5/releases/download/${HDF5_VERSION}/${HDF5_VERSION}.tar.gz \ - && tar -xzvf ${HDF5_VERSION}.tar.gz -C hdf5 --strip-components 2 \ - && cd hdf5 \ - && ./configure --enable-build-mode=production --enable-static-exec --disable-shared --prefix=${BUILD_DIR} --with-zlib=${BUILD_DIR}/include,${LIB_DIR} LDFLAGS="-Wl,-rpath,${LIB_DIR}" \ - && make check \ - && make install \ - && ldconfig - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make hdf5/install \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME job +ENV APP_NAME=job -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} COPY --from=builder /tmp/config.yaml /etc/server/config.yaml - USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/job"] +ENTRYPOINT ["/usr/bin/job"] diff --git a/dockers/tools/benchmark/operator/Dockerfile b/dockers/tools/benchmark/operator/Dockerfile index 123fe81ae2..56a011fcab 100644 --- a/dockers/tools/benchmark/operator/Dockerfile +++ b/dockers/tools/benchmark/operator/Dockerfile @@ -15,85 +15,86 @@ # limitations under the License. # -ARG DISTROLESS_IMAGE=gcr.io/distroless/static -ARG DISTROLESS_IMAGE_TAG=nonroot +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go + ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder - -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS - -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -# ARG UPX_OPTIONS -ENV ORG vdaas -ENV REPO vald -ENV APP_NAME operator -ENV PKG tools/benchmark/${APP_NAME} - +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=operator +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=tools/benchmark/operator +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions -COPY versions . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} +#skipcq: DOK-W1001, DOK-SC2086 RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" - -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} -RUN cp sample.yaml /tmp/config.yaml - -FROM --platform=${TARGETPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME operator -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} -COPY --from=builder /tmp/config.yaml /etc/server/config.yaml +ENV APP_NAME=operator +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} +COPY --from=builder /tmp/config.yaml /etc/server/config.yaml USER nonroot:nonroot - -ENTRYPOINT ["/go/bin/operator"] +ENTRYPOINT ["/usr/bin/operator"] diff --git a/dockers/tools/cli/loadtest/Dockerfile b/dockers/tools/cli/loadtest/Dockerfile index ffafc92b4d..f92a30cbe1 100644 --- a/dockers/tools/cli/loadtest/Dockerfile +++ b/dockers/tools/cli/loadtest/Dockerfile @@ -15,116 +15,95 @@ # limitations under the License. # -ARG MAINTAINER="vdaas.org vald team " +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go -FROM --platform=${TARGETPLATFORM} ubuntu:devel AS builder +ARG UPX_OPTIONS=-9 +# skipcq: DOK-DL3026 +FROM ghcr.io/vdaas/vald/vald-buildbase:nightly AS builder +ARG MAINTAINER="vdaas.org vald team " +LABEL maintainer="${MAINTAINER}" -ARG GO_VERSION ARG TARGETARCH ARG TARGETOS +ARG GO_VERSION +ARG RUST_VERSION +ENV APP_NAME=loadtest +ENV DEBIAN_FRONTEND=noninteractive +ENV GO111MODULE=on +ENV GOPATH=/go +ENV GOROOT=/opt/go +ENV HOME=/root +ENV INITRD=No +ENV LANG=en_US.UTF-8 +ENV ORG=vdaas +ENV PKG=tools/cli/loadtest +ENV REPO=vald +ENV PATH=${GOPATH}/bin:${GOROOT}/bin:/usr/local/bin:${PATH} -ENV GO111MODULE on -ENV DEBIAN_FRONTEND noninteractive -ENV INITRD No -ENV LANG en_US.UTF-8 -ENV GOROOT /opt/go -ENV GOPATH /go -ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin -ENV ORG vdaas -ENV REPO vald -ENV APP_NAME loadtest -ENV PKG tools/cli/${APP_NAME} - +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # skipcq: DOK-DL3008 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ build-essential \ + ca-certificates \ curl \ - upx \ git \ + cmake \ + g++ \ + gcc \ + unzip \ libhdf5-dev \ + libaec-dev \ && ldconfig \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d -COPY Makefile.d . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} COPY Makefile . COPY .git . COPY go.mod . COPY go.sum . - -RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ - --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ - make GO_VERSION=${GO_VERSION} go/install \ - && make go/download - +COPY cmd/${PKG}/sample.yaml /tmp/config.yaml +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d +COPY Makefile.d . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions +COPY versions . +WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/hack/benchmark/assets/x1b +COPY hack/benchmark/assets/x1b . WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal COPY internal . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/apis/grpc COPY apis/grpc . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/pkg/${PKG} COPY pkg/${PKG} . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} COPY cmd/${PKG} . -WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/hack/benchmark/assets/x1b -COPY hack/benchmark/assets/x1b . - WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} -COPY versions/GO_VERSION . -COPY versions/VALD_VERSION . -COPY .git . -SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN GO_VERSION="$(< GO_VERSION)" \ - && VALD_VERSION="$(< VALD_VERSION)" \ - && GIT_COMMIT="$(git rev-list -1 HEAD)" \ - && CPU_INFO_FLAGS="$(< /proc/cpuinfo | grep flags | cut -d " " -f 2- | head -1 || true)" \ - && GOOS="$(go env GOOS)" \ - && GOARCH="$(go env GOARCH)" \ - && CGO_ENABLED=1 \ - && CGO_CXXFLAGS="-g -Ofast -march=native" \ - CGO_FFLAGS="-g -Ofast -march=native" \ - CGO_LDFLAGS="-g -Ofast -march=native" \ - GO111MODULE=on \ - go build \ - --ldflags "-s -w \ - -X 'github.com/${ORG}/${REPO}/internal/info.Version=${VALD_VERSION}' \ - -X 'github.com/${ORG}/${REPO}/internal/info.GitCommit=${GIT_COMMIT}' \ - -X 'github.com/${ORG}/${REPO}/internal/info.GoVersion=${GO_VERSION}' \ - -X 'github.com/${ORG}/${REPO}/internal/info.GoOS=${GOOS}' \ - -X 'github.com/${ORG}/${REPO}/internal/info.GoArch=${GOARCH}' \ - -X 'github.com/${ORG}/${REPO}/internal/info.CGOEnabled=${CGO_ENABLED}' \ - -X 'github.com/${ORG}/${REPO}/internal/info.BuildCPUInfoFlags=${CPU_INFO_FLAGS}'" \ - -a \ - -tags "cgo netgo" \ - -trimpath \ - -installsuffix "cgo netgo" \ - -o "${APP_NAME}" \ - "cmd/${PKG}/main.go" \ - && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}" - -# Start From Scratch For Running Environment -FROM --platform=${TARGETPLATFORM} ubuntu:devel +#skipcq: DOK-W1001, DOK-SC2086 +RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ + --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ + make GO_VERSION="${GO_VERSION}" go/install \ + && make go/download \ + && make hdf5/install \ + && make GOARCH="${TARGETARCH}" GOOS="${TARGETOS}" REPO="${ORG}" NAME="${REPO}" cmd/${PKG}/${APP_NAME} \ + && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" +# skipcq: DOK-DL3026 +FROM gcr.io/distroless/static:nonroot +ARG MAINTAINER="vdaas.org vald team " LABEL maintainer="${MAINTAINER}" -ENV APP_NAME loadtest - -COPY --from=builder /usr/lib/x86_64-linux-gnu/libaec* /usr/lib/x86_64-linux-gnu/ -COPY --from=builder /usr/lib/x86_64-linux-gnu/libhdf5* /usr/lib/x86_64-linux-gnu/ -COPY --from=builder /usr/lib/x86_64-linux-gnu/libsz* /usr/lib/x86_64-linux-gnu/ - -# Copy certificates for SSL/TLS -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -# Copy permissions -COPY --from=builder /etc/passwd /etc/passwd -# workaround: https://github.com/moby/moby/issues/37965 -RUN true -# Copy our static executable -COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} +ENV APP_NAME=loadtest -ENTRYPOINT ["/go/bin/loadtest"] +COPY --from=builder /usr/bin/${APP_NAME} /usr/bin/${APP_NAME} +COPY --from=builder /tmp/config.yaml /etc/server/config.yaml +USER nonroot:nonroot +ENTRYPOINT ["/usr/bin/loadtest"] diff --git a/docs/api/build_proto.md b/docs/api/build_proto.md index 8057b81cf1..d2bfe0516e 100644 --- a/docs/api/build_proto.md +++ b/docs/api/build_proto.md @@ -227,9 +227,9 @@ There are many tools for building proto in Rust, we use [tonic](https://github.c } ``` - 1. `src/clinet.rs` + 1. `src/client.rs` - There are 4 steps in `src/clinet.rs`: + There are 4 steps in `src/client.rs`: 1. Load dataset 1. Insert vector to Vald cluster diff --git a/docs/api/filter-gateway.md b/docs/api/filter-gateway.md index dba621862c..33a4349878 100644 --- a/docs/api/filter-gateway.md +++ b/docs/api/filter-gateway.md @@ -2,7 +2,7 @@ ## Overview -Filter Servie is responsible for providing insert, update, upsert and search interface for `Vald Filter Gateway`. +Filter Server is responsible for providing insert, update, upsert and search interface for `Vald Filter Gateway`. Vald Filter Gateway forward user request to user-defined ingress/egress filter components allowing user to run custom logic. diff --git a/docs/api/flush.md b/docs/api/flush.md index 93c8ce6761..fb5b4478bf 100644 --- a/docs/api/flush.md +++ b/docs/api/flush.md @@ -31,7 +31,6 @@ Flush RPC is the method to remove all vectors. empty - ### Output - the scheme of `payload.v1.Info.Index.Count` @@ -47,14 +46,14 @@ Flush RPC is the method to remove all vectors. } ``` - Object.Info_Index_Count + Object.Info_Index_Count - | field | type | label | desc. | - | :---------: |:------ | :---- | :------------------------------------------------------------------------- | - | stored | uint32 | | count of indices. | - | uncommitted | uint32 | | count of uncommitted indices. | - | indexing | bool | | the state indicating whether `vald-agent` pods is present in the indexing. | - | saving | bool | | the state indicating whether `vald-agent` pods is present in the saving. | + | field | type | label | desc. | + | :---------: | :----- | :---- | :------------------------------------------------------------------------- | + | stored | uint32 | | count of indices. | + | uncommitted | uint32 | | count of uncommitted indices. | + | indexing | bool | | the state indicating whether `vald-agent` pods is present in the indexing. | + | saving | bool | | the state indicating whether `vald-agent` pods is present in the saving. | ### Status Code diff --git a/docs/api/remove.md b/docs/api/remove.md index b0f4c5c641..156176fc70 100644 --- a/docs/api/remove.md +++ b/docs/api/remove.md @@ -160,10 +160,10 @@ RemoveByTimestamp RPC is the method to remove vectors based on timestamp. - Remove.Timestamp - | field | type | label | required | description | - | :-------: | :------------------------ | :---- | :------: | :------------------------------------------------ | - | timestamp | int64 | | \* | The timestamp. | - | operator | Remove.Timestamp.Operator | | | The conditionl operator. (default value is `Eq`). | + | field | type | label | required | description | + | :-------: | :------------------------ | :---- | :------: | :------------------------------------------------- | + | timestamp | int64 | | \* | The timestamp. | + | operator | Remove.Timestamp.Operator | | | The conditional operator. (default value is `Eq`). | - Remove.Timestamp.Operator diff --git a/docs/contributing/coding-style.md b/docs/contributing/coding-style.md index f8c0e0ab83..ffd67cef7c 100644 --- a/docs/contributing/coding-style.md +++ b/docs/contributing/coding-style.md @@ -14,7 +14,7 @@ Please also read the [Contribution guideline](../contributing/contributing-guide Code formatting and naming conventions affect coding readability and maintainability. Every developer has a different coding style. Luckily Go provides tools to format source code and check for potential issues in the source code. -We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option. +We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) and [crlfmt](https://github.com/cockroachdb/crlfmt) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option. We suggest everyone install the plugin for your editor to format the code once you edit the code automatically and use `make format/go` command if you want to format the source code manually. But having tools to format source code does not mean you do not need to care about the formatting of the code, for example: @@ -91,7 +91,7 @@ Here are the naming conventions of the package: ```go // bad - package encodebase64 + package encode // good package base64 // inside the encoding/base64 folder @@ -273,7 +273,7 @@ The variable and the constant should be named as: ```go // bad - yamlprocessor := new(something) + yamlProcessor := new(something) // good yamlProcessor := new(something) @@ -315,7 +315,7 @@ In this section, rules also apply to the `function` (without receiver). The meth ```go // bad - func (s *something) somemethod() {} + func (s *something) someMethod() {} // bad func (s *something) some_method() {} @@ -329,7 +329,7 @@ In this section, rules also apply to the `function` (without receiver). The meth ```go // bad - func (s *something) genereateRandomNumber() int {} + func (s *something) generateRandomNumber() int {} // good func (s *something) genRandNum() int {} @@ -875,7 +875,7 @@ tests := []test { for _, tc := range tests { test := tc - t.Run(test.name, func(tt *tesint.T) { + t.Run(test.name, func(tt *testing.T) { checkFunc = defaultCheckFunc if test.checkFunc != nil { checkFunc = test.checkFunc @@ -1246,7 +1246,7 @@ In Vald, we can apply it to the different helper functions like `beforeFunc()` o ```go type test struct { ... - beforeFunc func(*testing.T) // helper function to initialze testing + beforeFunc func(*testing.T) // helper function to initialize testing afterFunc func(*testing.T) // helper function to cleanup } @@ -1318,7 +1318,7 @@ For example, we decided to mock the following implementation `Encoder`. package json type Encoder interface { - Encode(interface{}) ([]byte, error) + Encode(any) ([]byte, error) } ``` @@ -1327,7 +1327,7 @@ type encoder struct { encoder json.Encoder } -func (e *encoder) Encode(obj interface{}) ([]byte, error) { +func (e *encoder) Encode(obj any) ([]byte, error) { return e.encoder.Encode(obj) } ``` @@ -1338,10 +1338,10 @@ The following is an example of mock implementation: package json type MockEncoder struct { - EncoderFunc func(interface{}) ([]byte, error) + EncoderFunc func(any) ([]byte, error) } -func (m *MockEncoder) Encode(obj interface{}) ([]byte, error) { +func (m *MockEncoder) Encode(obj any) ([]byte, error) { return m.EncodeFunc(obj) } ``` @@ -1354,7 +1354,7 @@ tests := []test { name: "returns (byte{}, nil) when encode success" fields: fields { encoding: &json.MockEncoder { - EncoderFunc: func(interface{}) ([]byte, error) { + EncoderFunc: func(any) ([]byte, error) { return []byte{}, nil }, }, diff --git a/docs/contributing/development.md b/docs/contributing/development.md index e0d4a66cb7..c27642ee68 100644 --- a/docs/contributing/development.md +++ b/docs/contributing/development.md @@ -25,7 +25,7 @@ This is the easiest way to start developing `Vald`. You can just open our [devco We don't officially have a setup documentation for now, but you can take a look at the [`Dockerfile`](https://github.com/vdaas/vald/blob/main/dockers/dev/Dockerfile). That's everything you need to build and test `Vald`, so you can use it as a reference. -> If you would like to use the `Dockerfile` directlly, please note that `docker-in-docker` environment is required to run our E2E tests. +> If you would like to use the `Dockerfile` directly, please note that `docker-in-docker` environment is required to run our E2E tests. > In devcontainer, [`VS Code` handles it for us](https://github.com/devcontainers/features/tree/main/src/docker-in-docker). ## Run tests diff --git a/docs/contributing/unit-test-guideline.md b/docs/contributing/unit-test-guideline.md index 4db1a310a2..833e65addf 100644 --- a/docs/contributing/unit-test-guideline.md +++ b/docs/contributing/unit-test-guideline.md @@ -88,7 +88,7 @@ It is not only a single input, but also multi inputs. If a function or method accepts multiple inputs, we should try to create test cases to cover all the inputs. -(Note: The below `calcSum()` is diffrent function from `calsSum(val ...int32)` which we mention before.) +(Note: The below `calcSum()` is different function from `calcSum(val ...int32)` which we mention before.) ```go func calcAverageDiff(val1 []int32, val2 []int32) (diff float64) { @@ -180,7 +180,7 @@ And, you may also create unit tests based on robust boundary tests or equivalenc But, we have to take care the Vald is developed using Go. As you know as Go has many coding features as other languages. -One of the features is that Go will convert a single value to a slice value when the Function or Method receives a variadic argument (e.g., `...[]int`, `...[]string`, `...interface{}`, or etc.) as the input. +One of the features is that Go will convert a single value to a slice value when the Function or Method receives a variadic argument (e.g., `...[]int`, `...[]string`, `...any`, or etc.) as the input. And we apply the table-driven test for running unit tests. For example, when we create the unit test of `func getMeta(...[]int)`, the test code will be more complex than other functions' tests which don't use variadic argument as the input, if we create the test for all input patterns. @@ -189,15 +189,15 @@ So, we define the basic unit case slightly different from [the basic test case]( This change is very clear and you can apply it easily. Our basic test case depends on the type of two variadic arguments. -1. When input is `...interface{}` - - We have to write all test cases which satisfy `...interface{}` as same as a [basic test case](#Basic). For example, `val = 1`, `val = "input"`, `val = []float64{2020.12}` and so on. -1. When input is not `...interface{}` but `...[]int`, `...[]string` or etc. +1. When input is `...any` + - We have to write all test cases which satisfy `...any` as same as a [basic test case](#Basic). For example, `val = 1`, `val = "input"`, `val = []float64{2020.12}` and so on. +1. When input is not `...any` but `...[]int`, `...[]string` or etc. - We have to create only slice pattern test cases, which is the same as not creating test cases with a single value. - We should test with boundary cases, for example, we should test with `val = []int{math.MaxInt64()}` when the input value is `...[]int`. Summarize Vald unit test guideline: -- Apply basic test case, but take care of input variable pattern, in particular, the variadic argument (`...interface{}` or not) +- Apply basic test case, but take care of input variable pattern, in particular, the variadic argument (`...any` or not) - Apply robust boundary tests, including edge cases (e.g., `math.MaxInt64()`) - Apply equivalence class testing when needed. diff --git a/docs/overview/architecture.md b/docs/overview/architecture.md index 13149194c7..856202b04e 100644 --- a/docs/overview/architecture.md +++ b/docs/overview/architecture.md @@ -47,7 +47,7 @@ Here are the concepts of Vald. - Distributed vector spaces - All the vector data and indexes are distributed to Vald Agents in the Vald cluster. Whenever you search a vector in Vald cluster, all Vald agents can process parallelly and merge the result by Vald LB Gateway. + All the vector data and indexes are distributed to Vald Agents in the Vald cluster. Whenever you search a vector in Vald cluster, all Vald agents can process parallel and merge the result by Vald LB Gateway. - Kubernetes based diff --git a/docs/overview/data-flow.md b/docs/overview/data-flow.md index 57bb4e504f..ebf0266d4e 100644 --- a/docs/overview/data-flow.md +++ b/docs/overview/data-flow.md @@ -77,7 +77,7 @@ Upsert request updates the existing vector if the same vector ID already exists -When the user upserts a vector to Vald: +When the user upsert a vector to Vald: 1. Vald LB Gateway receives the request from the user, including the user's vector ID(s) and the vector(s). 2. Vald LB Gateway will broadcast an existing check request to the Vald Agent(s) to check if the vector exists. diff --git a/docs/support/faq.md b/docs/support/FAQ.md similarity index 100% rename from docs/support/faq.md rename to docs/support/FAQ.md diff --git a/docs/troubleshooting/client-side.md b/docs/troubleshooting/client-side.md index 39357685a2..6efc5f1ff3 100644 --- a/docs/troubleshooting/client-side.md +++ b/docs/troubleshooting/client-side.md @@ -55,4 +55,4 @@ Please check your CPU information. - [Provisioning Troubleshooting](../troubleshooting/provisioning.md) - [API Status](../api/status.md) -- [FAQ](../support/faq.md) +- [FAQ](../support/FAQ.md) diff --git a/docs/tutorial/get-started-with-faiss-agent.md b/docs/tutorial/get-started-with-faiss-agent.md index 87d7562160..2997d302b4 100644 --- a/docs/tutorial/get-started-with-faiss-agent.md +++ b/docs/tutorial/get-started-with-faiss-agent.md @@ -60,7 +60,7 @@ In this tutorial, you will deploy the basic configuration of Vald that is consis load_index_timeout_factor: 1ms m: 8 # dimension % m == 0, train size >= 2^m(or nlist) * minPointsPerCentroid max_load_index_timeout: 10m - metric_type: "inner_product" + metric_type: "innerproduct" min_load_index_timeout: 3m nbits_per_idx: 8 nlist: 100 diff --git a/docs/tutorial/vald-multicluster-on-k8s.md b/docs/tutorial/vald-multicluster-on-k8s.md index 2da2838bb0..6cdd344bc6 100644 --- a/docs/tutorial/vald-multicluster-on-k8s.md +++ b/docs/tutorial/vald-multicluster-on-k8s.md @@ -194,7 +194,7 @@ It requires applying the `ValdMirrorTarget` Custom Resource to the one Namespace When applied successfully, the destination information is automatically created on other Namespaces when interconnected with each `vald-mirror-gateway`. -This tutorial will deploy the [ValdMirrorTarger](https://github.com/vdaas/vald/tree/main/charts/vald/values/mirror-target.yaml) Custom Resource to the `vald-03` Namespace with the following command. +This tutorial will deploy the [ValdMirrorTarget](https://github.com/vdaas/vald/tree/main/charts/vald/values/mirror-target.yaml) Custom Resource to the `vald-03` Namespace with the following command. ```bash kubectl apply -f ./charts/vald/values/multi-vald/mirror-target.yaml -n vald-03 diff --git a/docs/user-guides/configuration.md b/docs/user-guides/configuration.md index f54def2a17..31655186a3 100644 --- a/docs/user-guides/configuration.md +++ b/docs/user-guides/configuration.md @@ -190,7 +190,7 @@ The important parameters are the followings: - `agent.faiss.nlist` Users should configure these parameters first to fit their use case. -For further details, please read [the Fiass wiki][faiss-wiki]. +For further details, please read [the Faiss wiki][faiss-wiki]. Vald Agent Faiss has a feature to start indexing automatically. The behavior of this feature can be configured with these parameters: @@ -394,7 +394,7 @@ For further details, there are references to the Helm values in the Vald GitHub - [README of Vald Helm Chart][vald-helm-chart] - [README of Vald-Helm-Operator Chart][vald-helm-operator-chart] - + [vald-helm-chart]: https://github.com/vdaas/vald/tree/main/charts/vald [vald-helm-operator-chart]: https://github.com/vdaas/vald/tree/main/charts/vald-helm-operator diff --git a/docs/user-guides/deployment.md b/docs/user-guides/deployment.md index 68a50f904f..adffdef08d 100644 --- a/docs/user-guides/deployment.md +++ b/docs/user-guides/deployment.md @@ -138,7 +138,7 @@ After create `values.yaml`, you can deploy by the following steps. When you need to update the configuration, you can update by following command with your new `values.yaml`. ```bash -helm upgrate vald vald/vald --values +helm upgrade vald vald/vald --values ``` ### Cleanup diff --git a/docs/user-guides/observability-configuration.md b/docs/user-guides/observability-configuration.md index 66617e874b..677781f191 100644 --- a/docs/user-guides/observability-configuration.md +++ b/docs/user-guides/observability-configuration.md @@ -5,14 +5,14 @@ By enabling observability, you can monitor and visualize the number of indexes, This page shows the best practice for applying observing features by constructing an observability environment and setting the Vald Helm chart. -## Arhitecture +## Architecture -Vald conforms [OpenTeremetry Protocol](https://opentelemetry.io/docs/reference/specification/protocol/otlp/) and does NOT depend on any commercial data format. +Vald conforms [OpenTelemetry Protocol](https://opentelemetry.io/docs/reference/specification/protocol/otlp/) and does NOT depend on any commercial data format. OpenTelemetry Collector handles receiving / processing / exporting the telemetry data, which does NOT depend on the vendors' format. -All Vald components can send OTLP-compliant telemetry data, like metrics, traces, or logs, to the OpenTelemerty Collector. +All Vald components can send OTLP-compliant telemetry data, like metrics, traces, or logs, to the OpenTelemetry Collector. The telemetry data is used to monitor or visualize with the observing tools. ## Build an observing environment @@ -23,7 +23,7 @@ The recommended observability environment consists of the following: - Jaeger Operator and Jaeger - Prometheus Operator and Prometheus - Grafana -- OpenTelemetry Operator and OpenTelemtry Collector +- OpenTelemetry Operator and OpenTelemetry Collector Vald provides [the default manifests](https://github.com/vdaas/vald/tree/main/k8s/metrics) and [the make commands](https://github.com/vdaas/vald/blob/main/Makefile.d/k8s.mk) for deploying those components. Please refer to the following sections to deploy each component. @@ -67,7 +67,7 @@ make k8s/metrics/grafana/deploy ### OpenTelemetry Operator and OpenTelemetry Collector Vald uses OpenTelemetry Collector to get the telemetry data and export it to monitor backend components. -The following command deploys OpenTelemtry Collector via OpenTelemerty Collector. +The following command deploys OpenTelemetry Collector via OpenTelemetry Collector.
Before executing the following command, please ensure the Prometheus operator runs healthy. diff --git a/docs/user-guides/upgrade-cluster.md b/docs/user-guides/upgrade-cluster.md index 694a213213..41aa64f2e3 100644 --- a/docs/user-guides/upgrade-cluster.md +++ b/docs/user-guides/upgrade-cluster.md @@ -27,7 +27,7 @@ You can edit your `values.yaml` and update your Vald cluster by following steps: ```bash helm upgrade vald/vald --values - # e.g., helm upgrade vald vald/vald --values valeus.yaml + # e.g., helm upgrade vald vald/vald --values values.yaml ``` ### Using vald-helm-operator @@ -107,7 +107,7 @@ If there is major or minor upgrading, the chart structure may have changed. ```bash helm upgrade vald/vald --values - # e.g., helm upgrade vald vald/vald --values valeus.yaml + # e.g., helm upgrade vald vald/vald --values values.yaml ``` ### Using vald-helm-operator diff --git a/example/client/agent/main.go b/example/client/agent/main.go index bddbb70677..77cf7eee48 100644 --- a/example/client/agent/main.go +++ b/example/client/agent/main.go @@ -44,10 +44,10 @@ var ( func init() { /** - Path option specifies hdf file by path. Default value is `fashion-mnist-784-euclidean.hdf5`. - Addr option specifies grpc server address. Default value is `127.0.0.1:8080`. - Wait option specifies indexing wait time (in seconds). Default value is `60`. - **/ + Path option specifies hdf file by path. Default value is `fashion-mnist-784-euclidean.hdf5`. + Addr option specifies grpc server address. Default value is `127.0.0.1:8080`. + Wait option specifies indexing wait time (in seconds). Default value is `60`. + **/ flag.StringVar(&datasetPath, "path", "fashion-mnist-784-euclidean.hdf5", "dataset path") flag.StringVar(&grpcServerAddr, "addr", "127.0.0.1:8081", "gRPC server address") flag.UintVar(&indexingWaitSeconds, "wait", 60, "indexing wait seconds") @@ -56,9 +56,9 @@ func init() { func main() { /** - Gets training data, test data and ids based on the dataset path. - the number of ids is equal to that of training dataset. - **/ + Gets training data, test data and ids based on the dataset path. + the number of ids is equal to that of training dataset. + **/ ids, train, test, err := load(datasetPath) if err != nil { glg.Fatal(err) @@ -98,10 +98,10 @@ func main() { } glg.Infof("Finish Inserting %d training vector to Vald Agent", insertCount) /** - Optional: Run Indexing instead of Auto Indexing - If you run client.CreateAndSaveIndex, it costs less time for search - When default_pool_size is not set, the below codes are required. - **/ + Optional: Run Indexing instead of Auto Indexing + If you run client.CreateAndSaveIndex, it costs less time for search + When default_pool_size is not set, the below codes are required. + **/ glg.Info("Start Indexing dataset.") _, err = agent.NewAgentClient(conn).CreateAndSaveIndex(ctx, &payload.Control_CreateIndexRequest{ PoolSize: uint32(insertCount), @@ -142,9 +142,9 @@ func main() { glg.Info("Finish getting object") /** - Gets approximate vectors, which is based on the value of `SearchConfig`, from the indexed tree based on the training data. - In this example, Vald Agent gets 10 approximate vectors each search vector. - **/ + Gets approximate vectors, which is based on the value of `SearchConfig`, from the indexed tree based on the training data. + In this example, Vald Agent gets 10 approximate vectors each search vector. + **/ glg.Infof("Start searching %d times", testCount) for i, vec := range test[:testCount] { // Send searching vector and configuration object to the Vald Agent server via gRPC. @@ -188,11 +188,11 @@ func main() { glg.Info("Finish removing vector") glg.Info("Start removing indexed vector from backup") /** - Run Indexing instead of Auto Indexing. - Before calling the SaveIndex (or CreateAndSaveIndex) API, the vectors you inserted before still exist in the NGT graph index even the Remove API is called due to the design of NGT. - So at this moment, the neighbor vectors will be returned from the SearchByID API. - To remove the vectors from the NGT graph completely, the SaveIndex API will be used here instead of waiting auto CreateIndex phase. - **/ + Run Indexing instead of Auto Indexing. + Before calling the SaveIndex (or CreateAndSaveIndex) API, the vectors you inserted before still exist in the NGT graph index even the Remove API is called due to the design of NGT. + So at this moment, the neighbor vectors will be returned from the SearchByID API. + To remove the vectors from the NGT graph completely, the SaveIndex API will be used here instead of waiting auto CreateIndex phase. + **/ _, err = agent.NewAgentClient(conn).SaveIndex(ctx, &payload.Empty{}) if err != nil { glg.Fatal(err) diff --git a/example/client/go.mod b/example/client/go.mod index 2c9b6a8e7a..79923afce1 100644 --- a/example/client/go.mod +++ b/example/client/go.mod @@ -1,21 +1,21 @@ module github.com/vdaas/vald/example/client -go 1.22.3 +go 1.22.5 replace ( github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v1.0.4 - github.com/goccy/go-json => github.com/goccy/go-json v0.10.2 + github.com/goccy/go-json => github.com/goccy/go-json v0.10.3 github.com/golang/protobuf => github.com/golang/protobuf v1.5.4 github.com/kpango/glg => github.com/kpango/glg v1.6.15 github.com/pkg/sftp => github.com/pkg/sftp v1.13.6 - golang.org/x/crypto => golang.org/x/crypto v0.23.0 - golang.org/x/net => golang.org/x/net v0.25.0 - golang.org/x/text => golang.org/x/text v0.15.0 - google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240506185236-b8a5c65736ae - google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae - google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae - google.golang.org/grpc => google.golang.org/grpc v1.63.2 - google.golang.org/protobuf => google.golang.org/protobuf v1.34.1 + golang.org/x/crypto => golang.org/x/crypto v0.25.0 + golang.org/x/net => golang.org/x/net v0.27.0 + golang.org/x/text => golang.org/x/text v0.16.0 + google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240725223205-93522f1f2a9f + google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f + google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f + google.golang.org/grpc => google.golang.org/grpc v1.65.0 + 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 ) @@ -25,7 +25,7 @@ require ( github.com/kpango/glg v1.6.14 github.com/vdaas/vald-client-go v1.7.12 gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 - google.golang.org/grpc v1.63.2 + google.golang.org/grpc v1.64.1 ) require ( @@ -33,10 +33,10 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/kpango/fastime v1.1.9 // indirect github.com/planetscale/vtprotobuf v0.6.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect - google.golang.org/protobuf v1.34.1 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade // indirect + google.golang.org/protobuf v1.34.2 // indirect ) diff --git a/example/client/go.mod.default b/example/client/go.mod.default index eba3aefdcf..14c78eebdf 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.22.3 +go 1.22.5 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 c526bb0895..80e249dcb9 100644 --- a/example/client/go.sum +++ b/example/client/go.sum @@ -1,7 +1,7 @@ buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20240221180331-f05a6f4403ce.1 h1:AmmAwHbvaeOIxDKG2+aTn5C36HjmFIMkrdTp49rp80Q= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20240221180331-f05a6f4403ce.1/go.mod h1:tiTMKD8j6Pd/D2WzREoweufjzaJKHZg35f/VGcZ2v3I= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +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/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -24,20 +24,20 @@ go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 h1:vJpL69PeUullhJyKtTjHjENEmZU3BkO4e+fod7nKzgM= gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946/go.mod h1:BQUWDHIAygjdt1HnUPQ0eWqLN2n5FwJycrpYUVUOx2I= -google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae h1:AH34z6WAGVNkllnKs5raNq3yRq93VnjBG6rpfub/jYk= -google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:FfiGhwUm6CJviekPrc0oJ+7h29e+DmWU6UtjX0ZvI7Y= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae h1:c55+MER4zkBS14uJhSZMGGmya0yJx5iHV4x/fpOSNRk= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f h1:b1Ln/PG8orm0SsBbHZWke8dDp2lrCD4jSmfglFpTZbk= +google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f h1:RARaIm8pxYuxyNPbBQf5igT7XdOyCNtat1qAT2ZxjU4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +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/example/client/main.go b/example/client/main.go index b57c895c9d..c323a1e3ba 100644 --- a/example/client/main.go +++ b/example/client/main.go @@ -42,11 +42,11 @@ var ( func init() { /** - Path option specifies hdf file by path. Default value is `fashion-mnist-784-euclidean.hdf5`. - Addr option specifies grpc server address. Default value is `127.0.0.1:8081`. - Insert option specifies insert count. Default value is `400`. - Wait option specifies indexing wait time (in seconds). Default value is `60`. - **/ + Path option specifies hdf file by path. Default value is `fashion-mnist-784-euclidean.hdf5`. + Addr option specifies grpc server address. Default value is `127.0.0.1:8081`. + Insert option specifies insert count. Default value is `400`. + Wait option specifies indexing wait time (in seconds). Default value is `60`. + **/ flag.StringVar(&datasetPath, "path", "fashion-mnist-784-euclidean.hdf5", "dataset path") flag.StringVar(&grpcServerAddr, "addr", "localhost:8081", "gRPC server address") flag.UintVar(&insertCount, "insert", 400, "insert count") @@ -56,9 +56,9 @@ func init() { func main() { /** - Gets training data, test data and ids based on the dataset path. - the number of ids is equal to that of training dataset. - **/ + Gets training data, test data and ids based on the dataset path. + the number of ids is equal to that of training dataset. + **/ ids, train, test, err := load(datasetPath) if err != nil { glg.Fatal(err) @@ -103,9 +103,9 @@ func main() { time.Sleep(wt) /** - Gets approximate vectors, which is based on the value of `SearchConfig`, from the indexed tree based on the training data. - In this example, Vald gets 10 approximate vectors each search vector. - **/ + Gets approximate vectors, which is based on the value of `SearchConfig`, from the indexed tree based on the training data. + In this example, Vald gets 10 approximate vectors each search vector. + **/ glg.Infof("Start searching %d times", testCount) for i, vec := range test[:testCount] { // Send searching vector and configuration object to the Vald server via gRPC. diff --git a/example/client/mirror/main.go b/example/client/mirror/main.go index 38d586ed64..8e8f4b074e 100644 --- a/example/client/mirror/main.go +++ b/example/client/mirror/main.go @@ -43,10 +43,10 @@ var ( func init() { /** - Path option specifies hdf file by path. Default value is `fashion-mnist-784-euclidean.hdf5`. - Addr option specifies grpc server addresses. Default value is `127.0.0.1:8080`,`127.0.0.1:8081`,`127.0.0.1:8082`. - Wait option specifies indexing wait time (in seconds). Default value is `60`. - **/ + Path option specifies hdf file by path. Default value is `fashion-mnist-784-euclidean.hdf5`. + Addr option specifies grpc server addresses. Default value is `127.0.0.1:8080`,`127.0.0.1:8081`,`127.0.0.1:8082`. + Wait option specifies indexing wait time (in seconds). Default value is `60`. + **/ flag.StringVar(&datasetPath, "path", "fashion-mnist-784-euclidean.hdf5", "dataset path") flag.StringVar(&grpcServerAddr, "addrs", "localhost:8080,localhost:8081,localhost:8082", "gRPC server addresses") flag.UintVar(&indexingWaitSeconds, "wait", 60, "indexing wait seconds") @@ -56,9 +56,9 @@ func init() { func main() { /** - Gets training data, test data and ids based on the dataset path. - the number of ids is equal to that of training dataset. - **/ + Gets training data, test data and ids based on the dataset path. + the number of ids is equal to that of training dataset. + **/ ids, train, test, err := load(datasetPath) if err != nil { glg.Fatal(err) @@ -107,9 +107,9 @@ func main() { time.Sleep(wt) /** - Gets approximate vectors, which is based on the value of `SearchConfig`, from the indexed tree based on the training data. - In this example, Vald gets 10 approximate vectors each search vector. - **/ + Gets approximate vectors, which is based on the value of `SearchConfig`, from the indexed tree based on the training data. + In this example, Vald gets 10 approximate vectors each search vector. + **/ glg.Infof("Start searching %d times", testCount) for i, vec := range test[:testCount] { for j, client := range clients { @@ -137,8 +137,8 @@ func main() { glg.Infof("Finish searching %d times", testCount) /** - Gets the vector using inserted vector id from Vald cluster. - **/ + Gets the vector using inserted vector id from Vald cluster. + **/ glg.Infof("Start getting %d times", insertCount) for i, id := range ids[:insertCount] { for j, client := range clients { diff --git a/example/helm/values-standalone-agent-ngt.yaml b/example/helm/values-standalone-agent-ngt.yaml index d797cdde7a..8ceb2f1c1e 100644 --- a/example/helm/values-standalone-agent-ngt.yaml +++ b/example/helm/values-standalone-agent-ngt.yaml @@ -18,7 +18,7 @@ default: logging: level: debug image: - tag: latest + tag: nightly agent: minReplicas: 4 maxReplicas: 8 diff --git a/example/helm/values-with-pyroscope.yaml b/example/helm/values-with-pyroscope.yaml index c428bda76e..882e38289e 100644 --- a/example/helm/values-with-pyroscope.yaml +++ b/example/helm/values-with-pyroscope.yaml @@ -18,7 +18,7 @@ defaults: logging: level: debug image: - tag: latest + tag: nightly time_zone: Asia/Tokyo server_config: metrics: diff --git a/example/helm/values.yaml b/example/helm/values.yaml index a845537436..8b292fbcaf 100644 --- a/example/helm/values.yaml +++ b/example/helm/values.yaml @@ -18,7 +18,7 @@ defaults: logging: level: debug image: - tag: latest + tag: nightly server_config: healths: liveness: diff --git a/go.mod b/go.mod index 92a8a9826a..9d60dce779 100644 --- a/go.mod +++ b/go.mod @@ -1,76 +1,76 @@ module github.com/vdaas/vald -go 1.22.3 +go 1.22.5 replace ( - cloud.google.com/go => cloud.google.com/go v0.112.2 - cloud.google.com/go/bigquery => cloud.google.com/go/bigquery v1.61.0 - cloud.google.com/go/compute => cloud.google.com/go/compute v1.26.0 - cloud.google.com/go/datastore => cloud.google.com/go/datastore v1.16.0 - cloud.google.com/go/firestore => cloud.google.com/go/firestore v1.15.0 - cloud.google.com/go/iam => cloud.google.com/go/iam v1.1.8 - cloud.google.com/go/kms => cloud.google.com/go/kms v1.15.9 - cloud.google.com/go/monitoring => cloud.google.com/go/monitoring v1.19.0 - cloud.google.com/go/pubsub => cloud.google.com/go/pubsub v1.38.0 - cloud.google.com/go/secretmanager => cloud.google.com/go/secretmanager v1.13.0 - cloud.google.com/go/storage => cloud.google.com/go/storage v1.40.0 - cloud.google.com/go/trace => cloud.google.com/go/trace v1.10.7 - code.cloudfoundry.org/bytefmt => code.cloudfoundry.org/bytefmt v0.0.0-20240507165102-251b29179075 + cloud.google.com/go => cloud.google.com/go v0.115.0 + cloud.google.com/go/bigquery => cloud.google.com/go/bigquery v1.62.0 + cloud.google.com/go/compute => cloud.google.com/go/compute v1.27.4 + cloud.google.com/go/datastore => cloud.google.com/go/datastore v1.17.1 + cloud.google.com/go/firestore => cloud.google.com/go/firestore v1.16.0 + cloud.google.com/go/iam => cloud.google.com/go/iam v1.1.12 + cloud.google.com/go/kms => cloud.google.com/go/kms v1.18.4 + cloud.google.com/go/monitoring => cloud.google.com/go/monitoring v1.20.3 + cloud.google.com/go/pubsub => cloud.google.com/go/pubsub v1.40.0 + cloud.google.com/go/secretmanager => cloud.google.com/go/secretmanager v1.13.5 + cloud.google.com/go/storage => cloud.google.com/go/storage v1.43.0 + cloud.google.com/go/trace => cloud.google.com/go/trace v1.10.11 + code.cloudfoundry.org/bytefmt => code.cloudfoundry.org/bytefmt v0.0.0-20240725181214-870a2a4a34a6 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 git.sr.ht/~sbinet/gg => git.sr.ht/~sbinet/gg v0.5.0 github.com/Azure/azure-amqp-common-go/v3 => github.com/Azure/azure-amqp-common-go/v3 v3.2.3 github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v68.0.0+incompatible - github.com/Azure/azure-sdk-for-go/sdk/azcore => github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity => github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 - github.com/Azure/azure-sdk-for-go/sdk/internal => github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore => github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.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.0.5 - github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.2.1-0.20240104002855-4c0e21ca2bbb+incompatible - github.com/Azure/go-autorest/autorest => github.com/Azure/go-autorest/autorest v0.11.30-0.20240104002855-4c0e21ca2bbb - github.com/Azure/go-autorest/autorest/adal => github.com/Azure/go-autorest/autorest/adal v0.9.23 - github.com/Azure/go-autorest/autorest/date => github.com/Azure/go-autorest/autorest/date v0.3.1-0.20240104002855-4c0e21ca2bbb - github.com/Azure/go-autorest/autorest/mocks => github.com/Azure/go-autorest/autorest/mocks v0.4.3-0.20240104002855-4c0e21ca2bbb - github.com/Azure/go-autorest/autorest/to => github.com/Azure/go-autorest/autorest/to v0.4.1-0.20240104002855-4c0e21ca2bbb - github.com/Azure/go-autorest/logger => github.com/Azure/go-autorest/logger v0.2.2-0.20240104002855-4c0e21ca2bbb - github.com/Azure/go-autorest/tracing => github.com/Azure/go-autorest/tracing v0.6.1-0.20240104002855-4c0e21ca2bbb - github.com/BurntSushi/toml => github.com/BurntSushi/toml v1.3.2 + 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 + github.com/Azure/go-autorest/autorest/date => github.com/Azure/go-autorest/autorest/date v0.3.1-0.20240530140449-f7ea664c9cff + github.com/Azure/go-autorest/autorest/mocks => github.com/Azure/go-autorest/autorest/mocks v0.4.3-0.20240530140449-f7ea664c9cff + github.com/Azure/go-autorest/autorest/to => github.com/Azure/go-autorest/autorest/to v0.4.1-0.20240530140449-f7ea664c9cff + github.com/Azure/go-autorest/logger => github.com/Azure/go-autorest/logger v0.2.2-0.20240530140449-f7ea664c9cff + github.com/Azure/go-autorest/tracing => github.com/Azure/go-autorest/tracing v0.6.1-0.20240530140449-f7ea664c9cff + github.com/BurntSushi/toml => github.com/BurntSushi/toml v1.4.0 github.com/DATA-DOG/go-sqlmock => github.com/DATA-DOG/go-sqlmock v1.5.2 - github.com/GoogleCloudPlatform/cloudsql-proxy => github.com/GoogleCloudPlatform/cloudsql-proxy v1.35.1 + github.com/GoogleCloudPlatform/cloudsql-proxy => github.com/GoogleCloudPlatform/cloudsql-proxy v1.36.0 github.com/Masterminds/semver/v3 => github.com/Masterminds/semver/v3 v3.2.1 - github.com/ajstarks/deck => github.com/ajstarks/deck v0.0.0-20240329135147-d1f085d9d01e - github.com/ajstarks/deck/generate => github.com/ajstarks/deck/generate v0.0.0-20240329135147-d1f085d9d01e + github.com/ajstarks/deck => github.com/ajstarks/deck v0.0.0-20240717142941-38ed00367aa6 + github.com/ajstarks/deck/generate => github.com/ajstarks/deck/generate v0.0.0-20240717142941-38ed00367aa6 github.com/ajstarks/svgo => github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b github.com/akrylysov/pogreb => github.com/akrylysov/pogreb v0.10.2 github.com/antihax/optional => github.com/antihax/optional v1.0.0 github.com/armon/go-socks5 => github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 - github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.52.4 - github.com/aws/aws-sdk-go-v2 => github.com/aws/aws-sdk-go-v2 v1.26.1 - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream => github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 - github.com/aws/aws-sdk-go-v2/config => github.com/aws/aws-sdk-go-v2/config v1.27.11 - github.com/aws/aws-sdk-go-v2/credentials => github.com/aws/aws-sdk-go-v2/credentials v1.17.11 - github.com/aws/aws-sdk-go-v2/feature/ec2/imds => github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 - github.com/aws/aws-sdk-go-v2/feature/s3/manager => github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.15 - github.com/aws/aws-sdk-go-v2/internal/configsources => github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.5 - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 => github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.5 + github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.55.3 + github.com/aws/aws-sdk-go-v2 => github.com/aws/aws-sdk-go-v2 v1.30.3 + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream => github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 + github.com/aws/aws-sdk-go-v2/config => github.com/aws/aws-sdk-go-v2/config v1.27.27 + github.com/aws/aws-sdk-go-v2/credentials => github.com/aws/aws-sdk-go-v2/credentials v1.17.27 + github.com/aws/aws-sdk-go-v2/feature/ec2/imds => github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 + github.com/aws/aws-sdk-go-v2/feature/s3/manager => github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.9 + github.com/aws/aws-sdk-go-v2/internal/configsources => github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 => github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 github.com/aws/aws-sdk-go-v2/internal/ini => github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding => github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 - github.com/aws/aws-sdk-go-v2/service/internal/checksum => github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.7 - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url => github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7 - github.com/aws/aws-sdk-go-v2/service/internal/s3shared => github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.5 - github.com/aws/aws-sdk-go-v2/service/kms => github.com/aws/aws-sdk-go-v2/service/kms v1.31.0 - github.com/aws/aws-sdk-go-v2/service/s3 => github.com/aws/aws-sdk-go-v2/service/s3 v1.53.1 - github.com/aws/aws-sdk-go-v2/service/secretsmanager => github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.28.6 - github.com/aws/aws-sdk-go-v2/service/sns => github.com/aws/aws-sdk-go-v2/service/sns v1.29.4 - github.com/aws/aws-sdk-go-v2/service/sqs => github.com/aws/aws-sdk-go-v2/service/sqs v1.31.4 - github.com/aws/aws-sdk-go-v2/service/ssm => github.com/aws/aws-sdk-go-v2/service/ssm v1.50.0 - github.com/aws/aws-sdk-go-v2/service/sso => github.com/aws/aws-sdk-go-v2/service/sso v1.20.5 - github.com/aws/aws-sdk-go-v2/service/sts => github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 - github.com/aws/smithy-go => github.com/aws/smithy-go v1.20.2 + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding => github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 + github.com/aws/aws-sdk-go-v2/service/internal/checksum => github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.17 + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url => github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 + github.com/aws/aws-sdk-go-v2/service/internal/s3shared => github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.15 + github.com/aws/aws-sdk-go-v2/service/kms => github.com/aws/aws-sdk-go-v2/service/kms v1.35.3 + github.com/aws/aws-sdk-go-v2/service/s3 => github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2 + github.com/aws/aws-sdk-go-v2/service/secretsmanager => github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.4 + github.com/aws/aws-sdk-go-v2/service/sns => github.com/aws/aws-sdk-go-v2/service/sns v1.31.3 + github.com/aws/aws-sdk-go-v2/service/sqs => github.com/aws/aws-sdk-go-v2/service/sqs v1.34.3 + github.com/aws/aws-sdk-go-v2/service/ssm => github.com/aws/aws-sdk-go-v2/service/ssm v1.52.3 + github.com/aws/aws-sdk-go-v2/service/sso => github.com/aws/aws-sdk-go-v2/service/sso v1.22.4 + github.com/aws/aws-sdk-go-v2/service/sts => github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 + github.com/aws/smithy-go => github.com/aws/smithy-go v1.20.3 github.com/benbjohnson/clock => github.com/benbjohnson/clock v1.3.5 github.com/beorn7/perks => github.com/beorn7/perks v1.0.1 github.com/bmizerany/assert => github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 - github.com/boombuler/barcode => github.com/boombuler/barcode v1.0.1 + github.com/boombuler/barcode => github.com/boombuler/barcode v1.0.2 github.com/buger/jsonparser => github.com/buger/jsonparser v1.1.1 github.com/cenkalti/backoff/v4 => github.com/cenkalti/backoff/v4 v4.3.0 github.com/census-instrumentation/opencensus-proto => github.com/census-instrumentation/opencensus-proto v0.4.1 @@ -79,7 +79,7 @@ replace ( github.com/chzyer/readline => github.com/chzyer/readline v1.5.1 github.com/chzyer/test => github.com/chzyer/test v1.0.0 github.com/cncf/udpa/go => github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe - github.com/cncf/xds/go => github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b + github.com/cncf/xds/go => github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 github.com/cockroachdb/apd => github.com/cockroachdb/apd v1.1.0 github.com/coreos/go-systemd/v22 => github.com/coreos/go-systemd/v22 v22.5.0 github.com/cpuguy83/go-md2man/v2 => github.com/cpuguy83/go-md2man/v2 v2.0.4 @@ -91,7 +91,7 @@ replace ( github.com/dnaeon/go-vcr => github.com/dnaeon/go-vcr v1.2.0 github.com/docopt/docopt-go => github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 github.com/dustin/go-humanize => github.com/dustin/go-humanize v1.0.1 - github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.12.0 + github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.12.1 github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.12.0 github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v1.0.4 github.com/evanphx/json-patch => github.com/evanphx/json-patch v0.5.2 @@ -102,16 +102,16 @@ replace ( github.com/gin-contrib/sse => github.com/gin-contrib/sse v0.1.0 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors => github.com/go-errors/errors v1.5.1 - github.com/go-fonts/dejavu => github.com/go-fonts/dejavu v0.3.3 - github.com/go-fonts/latin-modern => github.com/go-fonts/latin-modern v0.3.2 - github.com/go-fonts/liberation => github.com/go-fonts/liberation v0.3.2 + github.com/go-fonts/dejavu => github.com/go-fonts/dejavu v0.3.4 + github.com/go-fonts/latin-modern => github.com/go-fonts/latin-modern v0.3.3 + github.com/go-fonts/liberation => github.com/go-fonts/liberation v0.3.3 github.com/go-fonts/stix => github.com/go-fonts/stix v0.2.2 github.com/go-gl/gl => github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 github.com/go-gl/glfw/v3.3/glfw => github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a github.com/go-kit/log => github.com/go-kit/log v0.2.1 - github.com/go-latex/latex => github.com/go-latex/latex v0.0.0-20231108140139-5c1ce85aa4ea + github.com/go-latex/latex => github.com/go-latex/latex v0.0.0-20240709081214-31cef3c7570e github.com/go-logfmt/logfmt => github.com/go-logfmt/logfmt v0.6.0 - github.com/go-logr/logr => github.com/go-logr/logr v1.4.1 + github.com/go-logr/logr => github.com/go-logr/logr v1.4.2 github.com/go-logr/stdr => github.com/go-logr/stdr v1.2.2 github.com/go-logr/zapr => github.com/go-logr/zapr v1.3.0 github.com/go-openapi/jsonpointer => github.com/go-openapi/jsonpointer v0.21.0 @@ -121,7 +121,7 @@ replace ( github.com/go-playground/assert/v2 => github.com/go-playground/assert/v2 v2.2.0 github.com/go-playground/locales => github.com/go-playground/locales v0.14.1 github.com/go-playground/universal-translator => github.com/go-playground/universal-translator v0.18.1 - github.com/go-playground/validator/v10 => github.com/go-playground/validator/v10 v10.20.0 + github.com/go-playground/validator/v10 => github.com/go-playground/validator/v10 v10.22.0 github.com/go-redis/redis/v8 => github.com/go-redis/redis/v8 v8.11.5 github.com/go-sql-driver/mysql => github.com/go-sql-driver/mysql v1.8.1 github.com/go-task/slim-sprig => github.com/go-task/slim-sprig v2.20.0+incompatible @@ -131,7 +131,7 @@ replace ( github.com/gobwas/httphead => github.com/gobwas/httphead v0.1.0 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.2 + 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/gocraft/dbr/v2 => github.com/gocraft/dbr/v2 v2.7.6 github.com/godbus/dbus/v5 => github.com/godbus/dbus/v5 v5.1.0 @@ -141,7 +141,7 @@ replace ( github.com/golang-sql/civil => github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 github.com/golang-sql/sqlexp => github.com/golang-sql/sqlexp v0.1.0 github.com/golang/freetype => github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 - github.com/golang/glog => github.com/golang/glog v1.2.1 + github.com/golang/glog => github.com/golang/glog v1.2.2 github.com/golang/groupcache => github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da github.com/golang/mock => github.com/golang/mock v1.6.0 github.com/golang/protobuf => github.com/golang/protobuf v1.5.4 @@ -149,25 +149,26 @@ replace ( github.com/google/btree => github.com/google/btree v1.1.2 github.com/google/gnostic => github.com/google/gnostic v0.7.0 github.com/google/go-cmp => github.com/google/go-cmp v0.6.0 - github.com/google/go-replayers/grpcreplay => github.com/google/go-replayers/grpcreplay v1.1.0 + github.com/google/go-replayers/grpcreplay => github.com/google/go-replayers/grpcreplay v1.3.0 github.com/google/go-replayers/httpreplay => github.com/google/go-replayers/httpreplay v1.2.0 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-20240507183855-6f11f98ebb1c + github.com/google/pprof => github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8 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 github.com/google/wire => github.com/google/wire v0.6.0 - github.com/googleapis/gax-go/v2 => github.com/googleapis/gax-go/v2 v2.12.4 + github.com/googleapis/gax-go/v2 => github.com/googleapis/gax-go/v2 v2.13.0 github.com/gorilla/mux => github.com/gorilla/mux v1.8.1 - github.com/gorilla/websocket => github.com/gorilla/websocket v1.5.1 + github.com/gorilla/websocket => github.com/gorilla/websocket v1.5.3 + github.com/grafana/pyroscope-go/godeltaprof => github.com/grafana/pyroscope-go/godeltaprof v0.1.7 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.19.1 + github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.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/hashicorp/go-uuid => github.com/hashicorp/go-uuid v1.0.3 - github.com/hashicorp/go-version => github.com/hashicorp/go-version v1.6.0 + github.com/hashicorp/go-version => github.com/hashicorp/go-version v1.7.0 github.com/iancoleman/strcase => github.com/iancoleman/strcase v0.3.0 github.com/ianlancetaylor/demangle => github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 github.com/inconshreveable/mousetrap => github.com/inconshreveable/mousetrap v1.1.0 @@ -177,11 +178,11 @@ replace ( github.com/jackc/pgmock => github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 github.com/jackc/pgpassfile => github.com/jackc/pgpassfile v1.0.0 github.com/jackc/pgproto3/v2 => github.com/jackc/pgproto3/v2 v2.3.3 - github.com/jackc/pgservicefile => github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 + github.com/jackc/pgservicefile => github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 github.com/jackc/pgtype => github.com/jackc/pgtype v1.14.3 github.com/jackc/pgx/v4 => github.com/jackc/pgx/v4 v4.18.3 github.com/jackc/puddle => github.com/jackc/puddle v1.3.0 - github.com/jessevdk/go-flags => github.com/jessevdk/go-flags v1.5.0 + github.com/jessevdk/go-flags => github.com/jessevdk/go-flags v1.6.1 github.com/jmespath/go-jmespath => github.com/jmespath/go-jmespath v0.4.0 github.com/jmespath/go-jmespath/internal/testify => github.com/jmespath/go-jmespath/internal/testify v1.5.1 github.com/jmoiron/sqlx => github.com/jmoiron/sqlx v1.4.0 @@ -191,8 +192,8 @@ 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.9-0.20240412100233-8bd3916ec655 - github.com/klauspost/cpuid/v2 => github.com/klauspost/cpuid/v2 v2.2.7 + github.com/klauspost/compress => github.com/klauspost/compress v1.17.10-0.20240719110028-cfab8bd586ec + 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 github.com/kpango/gache/v2 => github.com/kpango/gache/v2 v2.0.9 @@ -213,8 +214,8 @@ replace ( github.com/mattn/go-sqlite3 => github.com/mattn/go-sqlite3 v1.14.22 github.com/matttproud/golang_protobuf_extensions => github.com/matttproud/golang_protobuf_extensions v1.0.4 github.com/mitchellh/colorstring => github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db - github.com/moby/spdystream => github.com/moby/spdystream v0.2.0 - github.com/moby/sys/mountinfo => github.com/moby/sys/mountinfo v0.7.1 + github.com/moby/spdystream => github.com/moby/spdystream v0.5.0 + github.com/moby/sys/mountinfo => github.com/moby/sys/mountinfo v0.7.2 github.com/modern-go/concurrent => github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd github.com/modern-go/reflect2 => github.com/modern-go/reflect2 v1.0.2 github.com/modocache/gover => github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5 @@ -224,8 +225,8 @@ replace ( github.com/niemeyer/pretty => github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e github.com/nxadm/tail => github.com/nxadm/tail v1.4.11 github.com/onsi/ginkgo => github.com/onsi/ginkgo v1.16.5 - github.com/onsi/ginkgo/v2 => github.com/onsi/ginkgo/v2 v2.17.3 - github.com/onsi/gomega => github.com/onsi/gomega v1.33.1 + github.com/onsi/ginkgo/v2 => github.com/onsi/ginkgo/v2 v2.19.0 + github.com/onsi/gomega => github.com/onsi/gomega v1.34.0 github.com/peterbourgon/diskv => github.com/peterbourgon/diskv v2.0.1+incompatible github.com/phpdave11/gofpdf => github.com/phpdave11/gofpdf v1.4.2 github.com/phpdave11/gofpdi => github.com/phpdave11/gofpdi v1.0.13 @@ -236,10 +237,10 @@ replace ( github.com/pkg/sftp => github.com/pkg/sftp v1.13.6 github.com/pmezard/go-difflib => github.com/pmezard/go-difflib v1.0.0 github.com/prashantv/gostub => github.com/prashantv/gostub v1.1.0 - github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.19.0 + github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.19.1 github.com/prometheus/client_model => github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common => github.com/prometheus/common v0.53.0 - github.com/prometheus/procfs => github.com/prometheus/procfs v0.14.0 + github.com/prometheus/common => github.com/prometheus/common v0.55.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 github.com/quasilyte/go-ruleguard/dsl => github.com/quasilyte/go-ruleguard/dsl v0.3.22 @@ -248,7 +249,7 @@ replace ( github.com/rogpeppe/fastuuid => github.com/rogpeppe/fastuuid v1.2.0 github.com/rogpeppe/go-internal => github.com/rogpeppe/go-internal v1.12.0 github.com/rs/xid => github.com/rs/xid v1.5.0 - github.com/rs/zerolog => github.com/rs/zerolog v1.32.0 + github.com/rs/zerolog => github.com/rs/zerolog v1.33.0 github.com/russross/blackfriday/v2 => github.com/russross/blackfriday/v2 v2.1.0 github.com/ruudk/golang-pdf417 => github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245 github.com/schollz/progressbar/v2 => github.com/schollz/progressbar/v2 v2.15.0 @@ -260,7 +261,7 @@ replace ( github.com/shurcooL/vfsgen => github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92 github.com/sirupsen/logrus => github.com/sirupsen/logrus v1.9.3 github.com/spf13/afero => github.com/spf13/afero v1.11.0 - github.com/spf13/cobra => github.com/spf13/cobra v1.8.0 + github.com/spf13/cobra => github.com/spf13/cobra v1.8.1 github.com/spf13/pflag => github.com/spf13/pflag v1.0.5 github.com/stoewer/go-strcase => github.com/stoewer/go-strcase v1.3.0 github.com/stretchr/objx => github.com/stretchr/objx v0.5.2 @@ -274,53 +275,53 @@ replace ( github.com/zeebo/xxh3 => github.com/zeebo/xxh3 v1.0.2 go.etcd.io/bbolt => go.etcd.io/bbolt v1.3.10 go.opencensus.io => go.opencensus.io v0.24.0 - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc => go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 - go.opentelemetry.io/otel => go.opentelemetry.io/otel v1.26.0 + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc => go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0 + go.opentelemetry.io/otel => go.opentelemetry.io/otel v1.28.0 go.opentelemetry.io/otel/exporters/otlp/internal/retry => go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.17.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric => go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.43.0 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.26.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace => go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0 - go.opentelemetry.io/otel/metric => go.opentelemetry.io/otel/metric v1.26.0 - go.opentelemetry.io/otel/sdk => go.opentelemetry.io/otel/sdk v1.26.0 - go.opentelemetry.io/otel/sdk/metric => go.opentelemetry.io/otel/sdk/metric v1.26.0 - go.opentelemetry.io/otel/trace => go.opentelemetry.io/otel/trace v1.26.0 - go.opentelemetry.io/proto/otlp => go.opentelemetry.io/proto/otlp v1.2.0 - go.starlark.net => go.starlark.net v0.0.0-20240507195648-35fe9f26b4bc + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace => go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 + go.opentelemetry.io/otel/metric => go.opentelemetry.io/otel/metric v1.28.0 + go.opentelemetry.io/otel/sdk => go.opentelemetry.io/otel/sdk v1.28.0 + go.opentelemetry.io/otel/sdk/metric => go.opentelemetry.io/otel/sdk/metric v1.28.0 + go.opentelemetry.io/otel/trace => go.opentelemetry.io/otel/trace v1.28.0 + go.opentelemetry.io/proto/otlp => go.opentelemetry.io/proto/otlp v1.3.1 + go.starlark.net => go.starlark.net v0.0.0-20240725214946-42030a7cedce go.uber.org/atomic => go.uber.org/atomic v1.11.0 go.uber.org/automaxprocs => go.uber.org/automaxprocs v1.5.3 go.uber.org/goleak => go.uber.org/goleak v1.3.0 go.uber.org/multierr => go.uber.org/multierr v1.11.0 go.uber.org/zap => go.uber.org/zap v1.27.0 - gocloud.dev => gocloud.dev v0.37.0 - golang.org/x/crypto => golang.org/x/crypto v0.23.0 - golang.org/x/exp => golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 - golang.org/x/exp/typeparams => golang.org/x/exp/typeparams v0.0.0-20240506185415-9bf2ced13842 - golang.org/x/image => golang.org/x/image v0.16.0 + gocloud.dev => gocloud.dev v0.38.0 + golang.org/x/crypto => golang.org/x/crypto v0.25.0 + golang.org/x/exp => golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 + golang.org/x/exp/typeparams => golang.org/x/exp/typeparams v0.0.0-20240719175910-8a7402abbf56 + golang.org/x/image => golang.org/x/image v0.18.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-20240506190922-a1a533f289d3 - golang.org/x/mod => golang.org/x/mod v0.17.0 - golang.org/x/net => golang.org/x/net v0.25.0 - golang.org/x/oauth2 => golang.org/x/oauth2 v0.20.0 + golang.org/x/mobile => golang.org/x/mobile v0.0.0-20240716161057-1ad2df20a8b6 + golang.org/x/mod => golang.org/x/mod v0.19.0 + golang.org/x/net => golang.org/x/net v0.27.0 + golang.org/x/oauth2 => golang.org/x/oauth2 v0.21.0 golang.org/x/sync => golang.org/x/sync v0.7.0 - golang.org/x/sys => golang.org/x/sys v0.20.0 - golang.org/x/term => golang.org/x/term v0.20.0 - golang.org/x/text => golang.org/x/text v0.15.0 + golang.org/x/sys => golang.org/x/sys v0.22.0 + golang.org/x/term => golang.org/x/term v0.22.0 + golang.org/x/text => golang.org/x/text v0.16.0 golang.org/x/time => golang.org/x/time v0.5.0 - golang.org/x/tools => golang.org/x/tools v0.21.0 - golang.org/x/xerrors => golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 + golang.org/x/tools => golang.org/x/tools v0.23.0 + golang.org/x/xerrors => golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 gomodules.xyz/jsonpatch/v2 => gomodules.xyz/jsonpatch/v2 v2.4.0 gonum.org/v1/gonum => gonum.org/v1/gonum v0.15.0 gonum.org/v1/hdf5 => gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 gonum.org/v1/plot => gonum.org/v1/plot v0.14.0 - google.golang.org/api => google.golang.org/api v0.178.0 + google.golang.org/api => google.golang.org/api v0.189.0 google.golang.org/appengine => google.golang.org/appengine v1.6.8 - google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240506185236-b8a5c65736ae - google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae - google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae - google.golang.org/grpc => google.golang.org/grpc v1.63.2 - google.golang.org/grpc/cmd/protoc-gen-go-grpc => google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 - google.golang.org/protobuf => google.golang.org/protobuf v1.34.1 + google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240725223205-93522f1f2a9f + google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f + google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f + google.golang.org/grpc => google.golang.org/grpc v1.65.0 + google.golang.org/grpc/cmd/protoc-gen-go-grpc => google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.4.0 + google.golang.org/protobuf => google.golang.org/protobuf v1.34.2 gopkg.in/check.v1 => gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c gopkg.in/inconshreveable/log15.v2 => gopkg.in/inconshreveable/log15.v2 v2.16.0 gopkg.in/inf.v0 => gopkg.in/inf.v0 v0.9.1 @@ -328,19 +329,19 @@ replace ( gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1 honnef.co/go/tools => honnef.co/go/tools v0.4.7 - k8s.io/api => k8s.io/api v0.30.0 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.30.0 - k8s.io/apimachinery => k8s.io/apimachinery v0.30.0 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.30.0 - k8s.io/client-go => k8s.io/client-go v0.30.0 - k8s.io/component-base => k8s.io/component-base v0.30.0 - k8s.io/klog/v2 => k8s.io/klog/v2 v2.120.1 - k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f - k8s.io/kubernetes => k8s.io/kubernetes v0.30.0 - k8s.io/metrics => k8s.io/metrics v0.30.0 + k8s.io/api => k8s.io/api v0.30.2 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.30.2 + k8s.io/apimachinery => k8s.io/apimachinery v0.30.2 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.30.2 + k8s.io/client-go => k8s.io/client-go v0.30.2 + k8s.io/component-base => k8s.io/component-base v0.30.2 + k8s.io/klog/v2 => k8s.io/klog/v2 v2.130.1 + k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20240709000822-3c01b740850f + k8s.io/kubernetes => k8s.io/kubernetes v0.30.2 + k8s.io/metrics => k8s.io/metrics v0.30.2 nhooyr.io/websocket => nhooyr.io/websocket v1.8.11 rsc.io/pdf => rsc.io/pdf v0.1.1 - sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.18.2 + sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.18.4 sigs.k8s.io/json => sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd sigs.k8s.io/kustomize => sigs.k8s.io/kustomize v2.0.3+incompatible sigs.k8s.io/structured-merge-diff/v4 => sigs.k8s.io/structured-merge-diff/v4 v4.4.1 @@ -348,23 +349,24 @@ replace ( ) require ( - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.1-20240401165935-b983156c5e99.1 - cloud.google.com/go/storage v1.40.0 + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2 + cloud.google.com/go/storage v1.42.0 code.cloudfoundry.org/bytefmt v0.0.0-20190710193110-1eb035ffe2b6 github.com/akrylysov/pogreb v0.0.0-00010101000000-000000000000 - github.com/aws/aws-sdk-go v1.50.36 + github.com/aws/aws-sdk-go v1.51.30 github.com/felixge/fgprof v0.9.4 github.com/fsnotify/fsnotify v1.7.0 github.com/go-redis/redis/v8 v8.0.0-00010101000000-000000000000 - github.com/go-sql-driver/mysql v1.8.0 + github.com/go-sql-driver/mysql v1.8.1 github.com/goccy/go-json v0.10.2 github.com/gocql/gocql v0.0.0-20200131111108-92af2e088537 github.com/gocraft/dbr/v2 v2.0.0-00010101000000-000000000000 github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 github.com/gorilla/mux v0.0.0-00010101000000-000000000000 + github.com/grafana/pyroscope-go/godeltaprof v0.0.0-00010101000000-000000000000 github.com/hashicorp/go-version v0.0.0-00010101000000-000000000000 - github.com/klauspost/compress v1.16.7 + github.com/klauspost/compress v1.17.3 github.com/kpango/fastime v1.1.9 github.com/kpango/fuid v0.0.0-00010101000000-000000000000 github.com/kpango/gache/v2 v2.0.0-00010101000000-000000000000 @@ -380,50 +382,50 @@ require ( github.com/stretchr/testify v1.9.0 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.49.0 - go.opentelemetry.io/otel v1.26.0 + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 + go.opentelemetry.io/otel v1.28.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.0.0-00010101000000-000000000000 - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 - go.opentelemetry.io/otel/metric v1.26.0 - go.opentelemetry.io/otel/sdk v1.26.0 - go.opentelemetry.io/otel/sdk/metric v1.26.0 - go.opentelemetry.io/otel/trace v1.26.0 + go.opentelemetry.io/otel/metric v1.28.0 + go.opentelemetry.io/otel/sdk v1.28.0 + go.opentelemetry.io/otel/sdk/metric v1.28.0 + go.opentelemetry.io/otel/trace v1.28.0 go.uber.org/automaxprocs v0.0.0-00010101000000-000000000000 go.uber.org/goleak v1.3.0 go.uber.org/ratelimit v0.3.1 go.uber.org/zap v1.27.0 gocloud.dev v0.0.0-00010101000000-000000000000 - golang.org/x/net v0.25.0 - golang.org/x/oauth2 v0.20.0 + golang.org/x/net v0.27.0 + golang.org/x/oauth2 v0.21.0 golang.org/x/sync v0.7.0 - golang.org/x/sys v0.20.0 - golang.org/x/text v0.15.0 + golang.org/x/sys v0.22.0 + golang.org/x/text v0.16.0 golang.org/x/time v0.5.0 - golang.org/x/tools v0.21.0 + golang.org/x/tools v0.23.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-20240429193739-8cf5692501f6 - google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 - google.golang.org/grpc v1.63.2 - google.golang.org/protobuf v1.34.1 + google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a + google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a + google.golang.org/grpc v1.65.0 + google.golang.org/protobuf v1.34.2 gopkg.in/yaml.v2 v2.4.0 - k8s.io/api v0.30.0 - k8s.io/apimachinery v0.30.0 + k8s.io/api v0.30.2 + k8s.io/apimachinery v0.30.2 k8s.io/cli-runtime v0.0.0-00010101000000-000000000000 - k8s.io/client-go v0.30.0 + k8s.io/client-go v0.30.2 k8s.io/metrics v0.0.0-00010101000000-000000000000 - k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 + k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 sigs.k8s.io/controller-runtime v0.0.0-00010101000000-000000000000 sigs.k8s.io/yaml v1.3.0 ) require ( - cloud.google.com/go v0.112.2 // indirect - cloud.google.com/go/auth v0.3.0 // indirect - cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect - cloud.google.com/go/compute/metadata v0.3.0 // indirect - cloud.google.com/go/iam v1.1.8 // indirect + cloud.google.com/go v0.115.0 // indirect + cloud.google.com/go/auth v0.7.2 // indirect + cloud.google.com/go/auth/oauth2adapt v0.2.3 // indirect + cloud.google.com/go/compute/metadata v0.5.0 // indirect + cloud.google.com/go/iam v1.1.11 // indirect filippo.io/edwards25519 v1.1.0 // indirect git.sr.ht/~sbinet/gg v0.5.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect @@ -432,7 +434,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/campoy/embedmd v1.0.0 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect @@ -440,9 +442,9 @@ require ( github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-errors/errors v1.4.2 // indirect - github.com/go-fonts/liberation v0.3.2 // indirect + github.com/go-fonts/liberation v0.3.3 // indirect github.com/go-latex/latex v0.0.0-20231108140139-5c1ce85aa4ea // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect @@ -456,18 +458,18 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/btree v1.0.1 // indirect + github.com/google/btree v1.1.2 // 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-20240430035430-e4905b036c4e // indirect + github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/wire v0.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.4 // indirect + github.com/googleapis/gax-go/v2 v2.13.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect github.com/imdario/mergo v0.3.6 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -487,10 +489,10 @@ 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.19.0 // indirect - github.com/prometheus/client_model v0.6.0 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.48.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/quasilyte/gogrep v0.5.0 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect github.com/scylladb/go-reflectx v1.0.1 // indirect @@ -499,23 +501,23 @@ require ( github.com/stretchr/objx v0.5.2 // indirect github.com/xlab/treeprint v1.2.0 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/proto/otlp v1.2.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect + go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.23.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect golang.org/x/exp/typeparams v0.0.0-20240213143201-ec583247a57a // indirect - golang.org/x/image v0.16.0 // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/term v0.20.0 // indirect + golang.org/x/image v0.18.0 // indirect + golang.org/x/mod v0.19.0 // indirect + golang.org/x/term v0.22.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/api v0.177.0 // indirect - google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect + google.golang.org/api v0.189.0 // indirect + google.golang.org/genproto v0.0.0-20240725213756-90e476079158 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.30.0 // indirect + k8s.io/apiextensions-apiserver v0.30.1 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect diff --git a/go.sum b/go.sum index 268541e1d4..5e3d7727bb 100644 --- a/go.sum +++ b/go.sum @@ -1,149 +1,163 @@ -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.1-20240401165935-b983156c5e99.1 h1:npqzxtoNbSdWs7XBDzqvqA1ANrQQGc8QpN0zFq9sVHA= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.1-20240401165935-b983156c5e99.1/go.mod h1:XF+P8+RmfdufmIYpGUC+6bF7S+IlmHDEnCrO3OXaUAQ= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2 h1:SZRVx928rbYZ6hEKUIN+vtGDkl7uotABRWGY4OAg5gM= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2/go.mod h1:ylS4c28ACSI59oJrOdW4pHS4n0Hw4TgSPHn8rpHl4Yw= cel.dev/expr v0.15.0 h1:O1jzfJCQBfL5BFoYktaxwIhuttaQPsVWerH9/EEKx0w= cel.dev/expr v0.15.0/go.mod h1:TRSuuV7DlVCE/uwv5QbAiW/v8l5O8C4eEPHeu7gf7Sg= -cloud.google.com/go v0.112.2 h1:ZaGT6LiG7dBzi6zNOvVZwacaXlmf3lRqnC4DQzqyRQw= -cloud.google.com/go v0.112.2/go.mod h1:iEqjp//KquGIJV/m+Pk3xecgKNhV+ry+vVTsy4TbDms= -cloud.google.com/go/accessapproval v1.7.7/go.mod h1:10ZDPYiTm8tgxuMPid8s2DL93BfCt6xBh/Vg0Xd8pU0= -cloud.google.com/go/accesscontextmanager v1.8.6/go.mod h1:rMC0Z8pCe/JR6yQSksprDc6swNKjMEvkfCbaesh+OS0= -cloud.google.com/go/accesscontextmanager v1.8.7/go.mod h1:jSvChL1NBQ+uLY9zUBdPy9VIlozPoHptdBnRYeWuQoM= -cloud.google.com/go/aiplatform v1.67.0/go.mod h1:s/sJ6btBEr6bKnrNWdK9ZgHCvwbZNdP90b3DDtxxw+Y= -cloud.google.com/go/analytics v0.23.2/go.mod h1:vtE3olAXZ6edJYk1UOndEs6EfaEc9T2B28Y4G5/a7Fo= -cloud.google.com/go/apigateway v1.6.7/go.mod h1:7wAMb/33Rzln+PrGK16GbGOfA1zAO5Pq6wp19jtIt7c= -cloud.google.com/go/apigeeconnect v1.6.7/go.mod h1:hZxCKvAvDdKX8+eT0g5eEAbRSS9Gkzi+MPWbgAMAy5U= -cloud.google.com/go/apigeeregistry v0.8.5/go.mod h1:ZMg60hq2K35tlqZ1VVywb9yjFzk9AJ7zqxrysOxLi3o= -cloud.google.com/go/appengine v1.8.7/go.mod h1:1Fwg2+QTgkmN6Y+ALGwV8INLbdkI7+vIvhcKPZCML0g= -cloud.google.com/go/area120 v0.8.7/go.mod h1:L/xTq4NLP9mmxiGdcsVz7y1JLc9DI8pfaXRXbnjkR6w= -cloud.google.com/go/artifactregistry v1.14.9/go.mod h1:n2OsUqbYoUI2KxpzQZumm6TtBgtRf++QulEohdnlsvI= -cloud.google.com/go/asset v1.19.1/go.mod h1:kGOS8DiCXv6wU/JWmHWCgaErtSZ6uN5noCy0YwVaGfs= -cloud.google.com/go/assuredworkloads v1.11.7/go.mod h1:CqXcRH9N0KCDtHhFisv7kk+cl//lyV+pYXGi1h8rCEU= +cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14= +cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU= +cloud.google.com/go/accessapproval v1.7.10/go.mod h1:iOXZj2B/c3N8nf2PYOB3iuRKCbnkn19/F6fqaa2zhn8= +cloud.google.com/go/accesscontextmanager v1.8.9/go.mod h1:IXvQesVgOC7aXgK9OpYFn5eWnzz8fazegIiJ5WnCOVw= +cloud.google.com/go/accesscontextmanager v1.8.10/go.mod h1:hdwcvyIn3NXgjSiUanbL7drFlOl39rAoj5SKBrNVtyA= +cloud.google.com/go/aiplatform v1.68.0/go.mod h1:105MFA3svHjC3Oazl7yjXAmIR89LKhRAeNdnDKJczME= +cloud.google.com/go/analytics v0.23.5/go.mod h1:J54PE6xjbmbTA5mOOfX5ibafOs9jyY7sFKTTiAnIIY4= +cloud.google.com/go/apigateway v1.6.10/go.mod h1:3bRZnd+TDYONxRw2W8LB1jG3pDONS7GHJXMm5+BtQ+k= +cloud.google.com/go/apigeeconnect v1.6.10/go.mod h1:MZf8FZK+0JZBcncSSnUkzWw2n2fQnEdIvfI6J7hGcEY= +cloud.google.com/go/apigeeregistry v0.8.8/go.mod h1:0pDUUsNGiqCuBlD0VoPX2ssug6/vJ6BBPg8o4qPkE4k= +cloud.google.com/go/appengine v1.8.10/go.mod h1:4jh9kPp01PeN//i+yEHjIQ5153f/F9q/CDbNTMYBlU4= +cloud.google.com/go/area120 v0.8.10/go.mod h1:vTEko4eg1VkkkEzWDjLtMwBHgm7L4x8HgWE8fgEUd5k= +cloud.google.com/go/artifactregistry v1.14.12/go.mod h1:00qcBxCdu0SKIYPhFOymrsJpdacjBHVSiCsRkyqlRUA= +cloud.google.com/go/asset v1.19.4/go.mod h1:zSEhgb9eNLeBcl4eSO/nsrh1MyUNCBynvyRaFnXMaeY= +cloud.google.com/go/assuredworkloads v1.11.10/go.mod h1:x6pCPBbTVjXbAWu35spKLY3AU4Pmcn4GeXnkZGxOVhU= cloud.google.com/go/auth v0.2.1/go.mod h1:khQRBNrvNoHiHhV1iu2x8fSnlNbCaVHilznW5MAI5GY= -cloud.google.com/go/auth v0.2.2/go.mod h1:2bDNJWtWziDT3Pu1URxHHbkHE/BbOCuyUiKIGcNvafo= -cloud.google.com/go/auth v0.3.0 h1:PRyzEpGfx/Z9e8+lHsbkoUVXD0gnu4MNmm7Gp8TQNIs= cloud.google.com/go/auth v0.3.0/go.mod h1:lBv6NKTWp8E3LPzmO1TbiiRKc4drLOfHsgmlH9ogv5w= -cloud.google.com/go/auth/oauth2adapt v0.2.1/go.mod h1:tOdK/k+D2e4GEwfBRA48dKNQiDsqIXxLh7VU319eV0g= -cloud.google.com/go/auth/oauth2adapt v0.2.2 h1:+TTV8aXpjeChS9M+aTtN/TjdQnzJvmzKFt//oWu7HX4= +cloud.google.com/go/auth v0.4.1/go.mod h1:QVBuVEKpCn4Zp58hzRGvL0tjRGU0YqdRTdCHM1IHnro= +cloud.google.com/go/auth v0.4.2/go.mod h1:Kqvlz1cf1sNA0D+sYJnkPQOP+JMHkuHeIgVmCRtZOLc= +cloud.google.com/go/auth v0.5.1/go.mod h1:vbZT8GjzDf3AVqCcQmqeeM32U9HBFc32vVVAbwDsa6s= +cloud.google.com/go/auth v0.6.0/go.mod h1:b4acV+jLQDyjwm4OXHYjNvRi4jvGBzHWJRtJcy+2P4g= +cloud.google.com/go/auth v0.6.1/go.mod h1:eFHG7zDzbXHKmjJddFG/rBlcGp6t25SwRUiEQSlO4x4= +cloud.google.com/go/auth v0.7.0/go.mod h1:D+WqdrpcjmiCgWrXmLLxOVq1GACoE36chW6KXoEvuIw= +cloud.google.com/go/auth v0.7.2 h1:uiha352VrCDMXg+yoBtaD0tUF4Kv9vrtrWPYXwutnDE= +cloud.google.com/go/auth v0.7.2/go.mod h1:VEc4p5NNxycWQTMQEDQF0bd6aTMb6VgYDXEwiJJQAbs= cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q= -cloud.google.com/go/automl v1.13.7/go.mod h1:E+s0VOsYXUdXpq0y4gNZpi0A/s6y9+lAarmV5Eqlg40= -cloud.google.com/go/baremetalsolution v1.2.6/go.mod h1:KkS2BtYXC7YGbr42067nzFr+ABFMs6cxEcA1F+cedIw= -cloud.google.com/go/batch v1.8.5/go.mod h1:YSWU2RTIeoHWVwieZJDTLEfWWUsuk10uhAr5K1dTMiw= -cloud.google.com/go/beyondcorp v1.0.6/go.mod h1:wRkenqrVRtnGFfnyvIg0zBFUdN2jIfeojFF9JJDwVIA= -cloud.google.com/go/bigquery v1.61.0/go.mod h1:PjZUje0IocbuTOdq4DBOJLNYB0WF3pAKBHzAYyxCwFo= -cloud.google.com/go/billing v1.18.5/go.mod h1:lHw7fxS6p7hLWEPzdIolMtOd0ahLwlokW06BzbleKP8= -cloud.google.com/go/binaryauthorization v1.8.3/go.mod h1:Cul4SsGlbzEsWPOz2sH8m+g2Xergb6ikspUyQ7iOThE= -cloud.google.com/go/certificatemanager v1.8.1/go.mod h1:hDQzr50Vx2gDB+dOfmDSsQzJy/UPrYRdzBdJ5gAVFIc= -cloud.google.com/go/channel v1.17.7/go.mod h1:b+FkgBrhMKM3GOqKUvqHFY/vwgp+rwsAuaMd54wCdN4= -cloud.google.com/go/cloudbuild v1.16.1/go.mod h1:c2KUANTtCBD8AsRavpPout6Vx8W+fsn5zTsWxCpWgq4= -cloud.google.com/go/clouddms v1.7.6/go.mod h1:8HWZ2tznZ0mNAtTpfnRNT0QOThqn9MBUqTj0Lx8npIs= -cloud.google.com/go/cloudtasks v1.12.8/go.mod h1:aX8qWCtmVf4H4SDYUbeZth9C0n9dBj4dwiTYi4Or/P4= -cloud.google.com/go/compute v1.26.0/go.mod h1:T9RIRap4pVHCGUkVFRJ9hygT3KCXjip41X1GgWtBBII= +cloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI= +cloud.google.com/go/auth/oauth2adapt v0.2.3/go.mod h1:tMQXOfZzFuNuUxOypHlQEXgdfX5cuhwU+ffUuXRJE8I= +cloud.google.com/go/automl v1.13.10/go.mod h1:I5nlZ4sBYIX90aBwv3mm5A0W6tlGbzrJ4nkaErdsmAk= +cloud.google.com/go/baremetalsolution v1.2.9/go.mod h1:eFlsoR4Im039D+EVn1fKXEKWNPoMW2ewXBTHmjEZxlM= +cloud.google.com/go/batch v1.9.1/go.mod h1:UGOBIGCUNo9NPeJ4VvmGpnTbE8vTewNhFaI/ZcQZaHk= +cloud.google.com/go/beyondcorp v1.0.9/go.mod h1:xa0eU8tIbYVraMOpRh5V9PirdYROvTUcPayJW9UlSNs= +cloud.google.com/go/bigquery v1.62.0/go.mod h1:5ee+ZkF1x/ntgCsFQJAQTM3QkAZOecfCmvxhkJsWRSA= +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.27.2-0.20240725222120-ce31365acc54/go.mod h1:NmJ2jfoB34NxQyk4w7UCchopqE9r+a186ewvGrM79TI= +cloud.google.com/go/billing v1.18.8/go.mod h1:oFsuKhKiuxK7dDQ4a8tt5/1cScEo4IzhssWj6TTdi6k= +cloud.google.com/go/binaryauthorization v1.8.6/go.mod h1:GAfktMiQW14Y67lIK5q9QSbzYc4NE/xIpQemVRhIVXc= +cloud.google.com/go/certificatemanager v1.8.4/go.mod h1:knD4QGjaogN6hy/pk1f2Cz1fhU8oYeYSF710RRf+d6k= +cloud.google.com/go/channel v1.17.10/go.mod h1:TzcYuXlpeex8O483ofkxbY/DKRF49NBumZTJPvjstVA= +cloud.google.com/go/cloudbuild v1.16.4/go.mod h1:YSNmtWgg9lmL4st4+lej1XywNEUQnbyA/F+DdXPBevA= +cloud.google.com/go/clouddms v1.7.9/go.mod h1:U2j8sOFtsIovea96mz2joyNMULl43TGadf7tOAUKKzs= +cloud.google.com/go/cloudtasks v1.12.11/go.mod h1:uDR/oUmPZqL2rNz9M9MXvm07hkkLnvvUORbud8MA5p4= +cloud.google.com/go/compute v1.27.4/go.mod h1:7JZS+h21ERAGHOy5qb7+EPyXlQwzshzrx1x6L9JhTqU= cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= -cloud.google.com/go/contactcenterinsights v1.13.2/go.mod h1:AfkSB8t7mt2sIY6WpfO61nD9J9fcidIchtxm9FqJVXk= -cloud.google.com/go/container v1.35.1/go.mod h1:udm8fgLm3TtpnjFN4QLLjZezAIIp/VnMo316yIRVRQU= -cloud.google.com/go/containeranalysis v0.11.6/go.mod h1:YRf7nxcTcN63/Kz9f86efzvrV33g/UV8JDdudRbYEUI= -cloud.google.com/go/datacatalog v1.20.0/go.mod h1:fSHaKjIroFpmRrYlwz9XBB2gJBpXufpnxyAKaT4w6L0= -cloud.google.com/go/datacatalog v1.20.1/go.mod h1:Jzc2CoHudhuZhpv78UBAjMEg3w7I9jHA11SbRshWUjk= -cloud.google.com/go/dataflow v0.9.7/go.mod h1:3BjkOxANrm1G3+/EBnEsTEEgJu1f79mFqoOOZfz3v+E= -cloud.google.com/go/dataform v0.9.4/go.mod h1:jjo4XY+56UrNE0wsEQsfAw4caUs4DLJVSyFBDelRDtQ= -cloud.google.com/go/datafusion v1.7.7/go.mod h1:qGTtQcUs8l51lFA9ywuxmZJhS4ozxsBSus6ItqCUWMU= -cloud.google.com/go/datalabeling v0.8.7/go.mod h1:/PPncW5gxrU15UzJEGQoOT3IobeudHGvoExrtZ8ZBwo= -cloud.google.com/go/dataplex v1.15.1/go.mod h1:+cUJLSCSIWfH53dIXOS5gLErCSz3MP0mZiswVVI8YTA= -cloud.google.com/go/dataproc/v2 v2.4.2/go.mod h1:smGSj1LZP3wtnsM9eyRuDYftNAroAl6gvKp/Wk64XDE= -cloud.google.com/go/dataqna v0.8.7/go.mod h1:hvxGaSvINAVH5EJJsONIwT1y+B7OQogjHPjizOFoWOo= -cloud.google.com/go/datastore v1.16.0/go.mod h1:WIGbYyZE4GUJC+RLuVgpl6myNMKZGzlfbtN3Tch4R+8= -cloud.google.com/go/datastream v1.10.6/go.mod h1:lPeXWNbQ1rfRPjBFBLUdi+5r7XrniabdIiEaCaAU55o= -cloud.google.com/go/deploy v1.18.0/go.mod h1:7Nv2yKPQG5Lv3sscLUuY58DlrEMqPlq6nedtpb1Prcg= -cloud.google.com/go/dialogflow v1.53.0/go.mod h1:LqAvxq7bXiiGC3/DWIz9XXCxth2z2qpSnBAAmlNOj6U= -cloud.google.com/go/dlp v1.12.2/go.mod h1:AkJim14g+g5JqE4tTr9IJYQp2HHKhBYw/r/G6KQLQi0= -cloud.google.com/go/documentai v1.28.0/go.mod h1:ZTt9RkTRmqOn5GQgU4JxHJxbobemOoo6FSy0byEQHqY= -cloud.google.com/go/domains v0.9.7/go.mod h1:u/yVf3BgfPJW3QDZl51qTJcDXo9PLqnEIxfGmGgbHEc= -cloud.google.com/go/edgecontainer v1.2.1/go.mod h1:OE2D0lbkmGDVYLCvpj8Y0M4a4K076QB7E2JupqOR/qU= -cloud.google.com/go/errorreporting v0.3.0/go.mod h1:xsP2yaAp+OAW4OIm60An2bbLpqIhKXdWR/tawvl7QzU= -cloud.google.com/go/essentialcontacts v1.6.8/go.mod h1:EHONVDSum2xxG2p+myyVda/FwwvGbY58ZYC4XqI/lDQ= -cloud.google.com/go/eventarc v1.13.6/go.mod h1:QReOaYnDNdjwAQQWNC7nfr63WnaKFUw7MSdQ9PXJYj0= -cloud.google.com/go/filestore v1.8.3/go.mod h1:QTpkYpKBF6jlPRmJwhLqXfJQjVrQisplyb4e2CwfJWc= -cloud.google.com/go/firestore v1.15.0/go.mod h1:GWOxFXcv8GZUtYpWHw/w6IuYNux/BtmeVTMmjrm4yhk= -cloud.google.com/go/functions v1.16.2/go.mod h1:+gMvV5E3nMb9EPqX6XwRb646jTyVz8q4yk3DD6xxHpg= -cloud.google.com/go/gkebackup v1.4.1/go.mod h1:tVwSKC1/UxEA011ijRG8vlXaZThzTSy6vReO9fTOlX8= -cloud.google.com/go/gkeconnect v0.8.7/go.mod h1:iUH1jgQpTyNFMK5LgXEq2o0beIJ2p7KKUUFerkf/eGc= -cloud.google.com/go/gkehub v0.14.7/go.mod h1:NLORJVTQeCdxyAjDgUwUp0A6BLEaNLq84mCiulsM4OE= -cloud.google.com/go/gkemulticloud v1.1.3/go.mod h1:4WzfPnsOfdCIj6weekE5FIGCaeQKZ1HzGNUVZ1PpIxw= -cloud.google.com/go/grafeas v0.3.5/go.mod h1:y54iTBcI+lgUdI+kAPKb8jtPqeTkA2dsYzWSrQtpc5s= -cloud.google.com/go/gsuiteaddons v1.6.7/go.mod h1:u+sGBvr07OKNnOnQiB/Co1q4U2cjo50ERQwvnlcpNis= -cloud.google.com/go/iam v1.1.8 h1:r7umDwhj+BQyz0ScZMp4QrGXjSTI3ZINnpgU2nlB/K0= -cloud.google.com/go/iam v1.1.8/go.mod h1:GvE6lyMmfxXauzNq8NbgJbeVQNspG+tcdL/W8QO1+zE= -cloud.google.com/go/iap v1.9.6/go.mod h1:YiK+tbhDszhaVifvzt2zTEF2ch9duHtp6xzxj9a0sQk= -cloud.google.com/go/ids v1.4.7/go.mod h1:yUkDC71u73lJoTaoONy0dsA0T7foekvg6ZRg9IJL0AA= -cloud.google.com/go/iot v1.7.7/go.mod h1:tr0bCOSPXtsg64TwwZ/1x+ReTWKlQRVXbM+DnrE54yM= -cloud.google.com/go/kms v1.15.9/go.mod h1:5v/R/RRuBUVO+eJioGcqENr3syh8ZqNn1y1Wc9DjM+4= -cloud.google.com/go/language v1.12.5/go.mod h1:w/6a7+Rhg6Bc2Uzw6thRdKKNjnOzfKTJuxzD0JZZ0nM= -cloud.google.com/go/lifesciences v0.9.7/go.mod h1:FQ713PhjAOHqUVnuwsCe1KPi9oAdaTfh58h1xPiW13g= -cloud.google.com/go/logging v1.9.0/go.mod h1:1Io0vnZv4onoUnsVUQY3HZ3Igb1nBchky0A0y7BBBhE= +cloud.google.com/go/compute/metadata v0.4.0/go.mod h1:SIQh1Kkb4ZJ8zJ874fqVkslA29PRXuleyj6vOzlbK7M= +cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY= +cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY= +cloud.google.com/go/contactcenterinsights v1.13.5/go.mod h1:/27aGOSszuoT547CX4kTbF+4nMv3EIXN8+z+dJcMZco= +cloud.google.com/go/container v1.37.3/go.mod h1:XKwtVfsTBsnZ9Ve1Pw2wkjk5kSjJqsHl3oBrbbi4w/M= +cloud.google.com/go/containeranalysis v0.12.0/go.mod h1:a3Yo1yk1Dv4nVmlxcJWOJDqsnzy5I1HmETg2UGlERhs= +cloud.google.com/go/datacatalog v1.20.3/go.mod h1:AKC6vAy5urnMg5eJK3oUjy8oa5zMbiY33h125l8lmlo= +cloud.google.com/go/datacatalog v1.20.4/go.mod h1:71PDwywIYkNgSXdUU3H0mkTp3j15aahfYJ1CY3DogtU= +cloud.google.com/go/dataflow v0.9.10/go.mod h1:lkhCwyVAOR4cKx+TzaxFbfh0tJcBVqxyIN97TDc/OJ8= +cloud.google.com/go/dataform v0.9.7/go.mod h1:zJp0zOSCKHgt2IxTQ90vNeDfT7mdqFA8ZzrYIsxTEM0= +cloud.google.com/go/datafusion v1.7.10/go.mod h1:MYRJjIUs2kVTbYySSp4+foNyq2MfgKTLMcsquEjbapM= +cloud.google.com/go/datalabeling v0.8.10/go.mod h1:8+IBTdU0te7w9b7BoZzUl05XgPvgqOrxQMzoP47skGM= +cloud.google.com/go/dataplex v1.18.1/go.mod h1:G5+muC3D5rLSHG9uKACs5WfRtthIVwyUJSIXi2Wzp30= +cloud.google.com/go/dataproc/v2 v2.5.2/go.mod h1:KCr6aYKulU4Am8utvRoXKe1L2hPkfX9Ox0m/rvenUjU= +cloud.google.com/go/dataqna v0.8.10/go.mod h1:e6Ula5UmCrbT7jOI6zZDwHHtAsDdKHKDrHSkj0pDlAQ= +cloud.google.com/go/datastore v1.17.1/go.mod h1:mtzZ2HcVtz90OVrEXXGDc2pO4NM1kiBQy8YV4qGe0ZM= +cloud.google.com/go/datastream v1.10.9/go.mod h1:LvUG7tBqMn9zDkgj5HlefDzaOth8ohVITF8qTtqAINw= +cloud.google.com/go/deploy v1.19.3/go.mod h1:Ut73ILRKoxtcIWeRJyYwuhBAckuSE1KJXlSX38hf4B0= +cloud.google.com/go/dialogflow v1.54.3/go.mod h1:Sm5uznNq8Vrj7R+Uc84qz41gW2AXRZeWgvJ9owKZw9g= +cloud.google.com/go/dlp v1.14.3/go.mod h1:iyhOlJCSAGNP2z5YPoBjV+M9uhyiUuxjZDYqbvO3WMM= +cloud.google.com/go/documentai v1.30.4/go.mod h1:1UqovvxIySy/sQwZcU1O+tm4qA/jnzAwzZLRIhFmhSk= +cloud.google.com/go/domains v0.9.10/go.mod h1:8yArcduQ2fDThBQlnDSwxrkGRgduW8KK2Y/nlL1IU2o= +cloud.google.com/go/edgecontainer v1.2.4/go.mod h1:QiHvO/Xc/8388oPuYZfHn9BpKx3dz1jWSi8Oex5MX6w= +cloud.google.com/go/errorreporting v0.3.1/go.mod h1:6xVQXU1UuntfAf+bVkFk6nld41+CPyF2NSPCyXE3Ztk= +cloud.google.com/go/essentialcontacts v1.6.11/go.mod h1:qpdkYSdPY4C69zprW20nKu+5DsED/Gwf1KtFHUSzrC0= +cloud.google.com/go/eventarc v1.13.9/go.mod h1:Jn2EBCgvGXeqndphk0nUVgJm4ZJOhxx4yYcSasvNrh4= +cloud.google.com/go/filestore v1.8.6/go.mod h1:ztH4U+aeH5vWtiyEd4+Dc56L2yRk7EIm0+PAR+9m5Jc= +cloud.google.com/go/firestore v1.16.0/go.mod h1:+22v/7p+WNBSQwdSwP57vz47aZiY+HrDkrOsJNhk7rg= +cloud.google.com/go/functions v1.16.5/go.mod h1:ds5f+dyMN4kCkTWTLpQl8wMi0sLRuJWrQaWr5eFlUnQ= +cloud.google.com/go/gkebackup v1.5.3/go.mod h1:fzWJXO5v0AzcC3J5KgCTpEcB0uvcC+e0YqIRVYQR4sE= +cloud.google.com/go/gkeconnect v0.8.10/go.mod h1:2r9mjewv4bAEg0VXNqc7uJA2vWuDHy/44IzstIikFH8= +cloud.google.com/go/gkehub v0.14.10/go.mod h1:+bqT9oyCDQG2Dc2pUJKYVNJGvrKgIfm7c+hk9IlDzJU= +cloud.google.com/go/gkemulticloud v1.2.3/go.mod h1:CR97Vcd9XdDLZQtMPfXtbFWRxfIFuO9K6q7oF6+moco= +cloud.google.com/go/grafeas v0.3.6/go.mod h1:to6ECAPgRO2xeqD8ISXHc70nObJuaKZThreQOjeOH3o= +cloud.google.com/go/gsuiteaddons v1.6.10/go.mod h1:daIpNyqugkch134oS116DXGEVrLUt0kSdqvgi0U1DD8= +cloud.google.com/go/iam v1.1.12 h1:JixGLimRrNGcxvJEQ8+clfLxPlbeZA6MuRJ+qJNQ5Xw= +cloud.google.com/go/iam v1.1.12/go.mod h1:9LDX8J7dN5YRyzVHxwQzrQs9opFFqn0Mxs9nAeB+Hhg= +cloud.google.com/go/iap v1.9.9/go.mod h1:7I7ftlLPPU8du0E8jW3koaYkNcX1NLqSDU9jQFRwF04= +cloud.google.com/go/ids v1.4.10/go.mod h1:438ouAjmw7c4/3Q+KbQxuJTU3jek5xo6cVH7EduiKXs= +cloud.google.com/go/iot v1.7.10/go.mod h1:rVBZ3srfCH4yPr2CPkxu3tB/c0avx0KV9K68zVNAh4Q= +cloud.google.com/go/kms v1.18.4/go.mod h1:SG1bgQ3UWW6/KdPo9uuJnzELXY5YTTMJtDYvajiQ22g= +cloud.google.com/go/language v1.12.8/go.mod h1:3706JYCNJKvNXZZzcf7PGUMR2IuEYXQ0o7KqyOLqw+s= +cloud.google.com/go/lifesciences v0.9.10/go.mod h1:zm5Y46HXN/ZoVdQ8HhXJvXG+m4De1HoJye62r/DFXoU= +cloud.google.com/go/logging v1.10.0/go.mod h1:EHOwcxlltJrYGqMGfghSet736KR3hX1MAj614mrMk9I= +cloud.google.com/go/longrunning v0.1.1/go.mod h1:UUFxuDWkv22EuY93jjmDMFT5GPQKeFVJBIF6QlTqdsE= cloud.google.com/go/longrunning v0.4.1/go.mod h1:4iWDqhBZ70CvZ6BfETbvam3T8FMvLK+eFj0E6AaRQTo= +cloud.google.com/go/longrunning v0.5.1/go.mod h1:spvimkwdz6SPWKEt/XBij79E9fiTkHSQl/fRUUQJYJc= cloud.google.com/go/longrunning v0.5.2/go.mod h1:nqo6DQbNV2pXhGDbDMoN2bWz68MjZUzqv2YttZiveCs= -cloud.google.com/go/longrunning v0.5.5/go.mod h1:WV2LAxD8/rg5Z1cNW6FJ/ZpX4E4VnDnoTk0yawPBB7s= -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/managedidentities v1.6.7/go.mod h1:UzslJgHnc6luoyx2JV19cTCi2Fni/7UtlcLeSYRzTV8= -cloud.google.com/go/maps v1.7.3/go.mod h1:Jfe+h0i3YdG8Cc0wuNI+Q+WglTt7YnQ3PbKCqpBdTwc= -cloud.google.com/go/mediatranslation v0.8.7/go.mod h1:6eJbPj1QJwiCP8R4K413qMx6ZHZJUi9QFpApqY88xWU= -cloud.google.com/go/memcache v1.10.7/go.mod h1:SrU6+QBhvXJV0TA59+B3oCHtLkPx37eqdKmRUlmSE1k= -cloud.google.com/go/metastore v1.13.6/go.mod h1:OBCVMCP7X9vA4KKD+5J4Q3d+tiyKxalQZnksQMq5MKY= -cloud.google.com/go/monitoring v1.19.0/go.mod h1:25IeMR5cQ5BoZ8j1eogHE5VPJLlReQ7zFp5OiLgiGZw= -cloud.google.com/go/networkconnectivity v1.14.6/go.mod h1:/azB7+oCSmyBs74Z26EogZ2N3UcXxdCHkCPcz8G32bU= -cloud.google.com/go/networkmanagement v1.13.2/go.mod h1:24VrV/5HFIOXMEtVQEUoB4m/w8UWvUPAYjfnYZcBc4c= -cloud.google.com/go/networksecurity v0.9.7/go.mod h1:aB6UiPnh/l32+TRvgTeOxVRVAHAFFqvK+ll3idU5BoY= -cloud.google.com/go/notebooks v1.11.5/go.mod h1:pz6P8l2TvhWqAW3sysIsS0g2IUJKOzEklsjWJfi8sd4= -cloud.google.com/go/optimization v1.6.5/go.mod h1:eiJjNge1NqqLYyY75AtIGeQWKO0cvzD1ct/moCFaP2Q= -cloud.google.com/go/orchestration v1.9.2/go.mod h1:8bGNigqCQb/O1kK7PeStSNlyi58rQvZqDiuXT9KAcbg= -cloud.google.com/go/orgpolicy v1.12.2/go.mod h1:XycP+uWN8Fev47r1XibYjOgZod8SjXQtZGsO2I8KXX8= -cloud.google.com/go/orgpolicy v1.12.3/go.mod h1:6BOgIgFjWfJzTsVcib/4QNHOAeOjCdaBj69aJVs//MA= -cloud.google.com/go/osconfig v1.12.6/go.mod h1:2dcXGl5qNbKo6Hjsnqbt5t6H2GX7UCAaPjF6BwDlFq8= -cloud.google.com/go/osconfig v1.12.7/go.mod h1:ID7Lbqr0fiihKMwAOoPomWRqsZYKWxfiuafNZ9j1Y1M= -cloud.google.com/go/oslogin v1.13.3/go.mod h1:WW7Rs1OJQ1iSUckZDilvNBSNPE8on740zF+4ZDR4o8U= -cloud.google.com/go/phishingprotection v0.8.7/go.mod h1:FtYaOyGc/HQQU7wY4sfwYZBFDKAL+YtVBjUj8E3A3/I= -cloud.google.com/go/policytroubleshooter v1.10.5/go.mod h1:bpOf94YxjWUqsVKokzPBibMSAx937Jp2UNGVoMAtGYI= -cloud.google.com/go/privatecatalog v0.9.7/go.mod h1:NWLa8MCL6NkRSt8jhL8Goy2A/oHkvkeAxiA0gv0rIXI= -cloud.google.com/go/pubsub v1.38.0/go.mod h1:IPMJSWSus/cu57UyR01Jqa/bNOQA+XnPF6Z4dKW4fAA= -cloud.google.com/go/pubsublite v1.8.1/go.mod h1:fOLdU4f5xldK4RGJrBMm+J7zMWNj/k4PxwEZXy39QS0= -cloud.google.com/go/recaptchaenterprise/v2 v2.13.0/go.mod h1:jNYyn2ScR4DTg+VNhjhv/vJQdaU8qz+NpmpIzEE7HFQ= -cloud.google.com/go/recommendationengine v0.8.7/go.mod h1:YsUIbweUcpm46OzpVEsV5/z+kjuV6GzMxl7OAKIGgKE= -cloud.google.com/go/recommender v1.12.3/go.mod h1:OgN0MjV7/6FZUUPgF2QPQtYErtZdZc4u+5onvurcGEI= -cloud.google.com/go/redis v1.14.4/go.mod h1:EnHDflqTNQmCBPCN4FQPZdM28vLdweAgxe6avAZpqug= -cloud.google.com/go/resourcemanager v1.9.7/go.mod h1:cQH6lJwESufxEu6KepsoNAsjrUtYYNXRwxm4QFE5g8A= -cloud.google.com/go/resourcesettings v1.6.7/go.mod h1:zwRL5ZoNszs1W6+eJYMk6ILzgfnTj13qfU4Wvfupuqk= -cloud.google.com/go/retail v1.16.2/go.mod h1:T7UcBh4/eoxRBpP3vwZCoa+PYA9/qWRTmOCsV8DRdZ0= -cloud.google.com/go/run v1.3.7/go.mod h1:iEUflDx4Js+wK0NzF5o7hE9Dj7QqJKnRj0/b6rhVq20= -cloud.google.com/go/scheduler v1.10.8/go.mod h1:0YXHjROF1f5qTMvGTm4o7GH1PGAcmu/H/7J7cHOiHl0= -cloud.google.com/go/secretmanager v1.13.0/go.mod h1:yWdfNmM2sLIiyv6RM6VqWKeBV7CdS0SO3ybxJJRhBEs= -cloud.google.com/go/security v1.16.1/go.mod h1:UoF8QXvvJlV9ORs4YW/izW5GmDQtFUoq2P6TJgPlif8= -cloud.google.com/go/securitycenter v1.30.0/go.mod h1:/tmosjS/dfTnzJxOzZhTXdX3MXWsCmPWfcYOgkJmaJk= -cloud.google.com/go/servicedirectory v1.11.6/go.mod h1:peVGYNc1xArhcqSuhPP+NXp8kdl22XhB5E8IiNBNfZY= -cloud.google.com/go/shell v1.7.7/go.mod h1:7OYaMm3TFMSZBh8+QYw6Qef+fdklp7CjjpxYAoJpZbQ= -cloud.google.com/go/spanner v1.61.0/go.mod h1:+hdNE+zL7EWNfOWRetw01jxz8H5qsE/ayZvF/pfrAl8= -cloud.google.com/go/speech v1.23.1/go.mod h1:UNgzNxhNBuo/OxpF1rMhA/U2rdai7ILL6PBXFs70wq0= -cloud.google.com/go/storage v1.40.0 h1:VEpDQV5CJxFmJ6ueWNsKxcr1QAYOXEgxDa+sBbJahPw= -cloud.google.com/go/storage v1.40.0/go.mod h1:Rrj7/hKlG87BLqDJYtwR0fbPld8uJPbQ2ucUMY7Ir0g= -cloud.google.com/go/storagetransfer v1.10.6/go.mod h1:3sAgY1bx1TpIzfSzdvNGHrGYldeCTyGI/Rzk6Lc6A7w= -cloud.google.com/go/talent v1.6.8/go.mod h1:kqPAJvhxmhoUTuqxjjk2KqA8zUEeTDmH+qKztVubGlQ= -cloud.google.com/go/texttospeech v1.7.7/go.mod h1:XO4Wr2VzWHjzQpMe3gS58Oj68nmtXMyuuH+4t0wy9eA= -cloud.google.com/go/tpu v1.6.7/go.mod h1:o8qxg7/Jgt7TCgZc3jNkd4kTsDwuYD3c4JTMqXZ36hU= -cloud.google.com/go/trace v1.10.7/go.mod h1:qk3eiKmZX0ar2dzIJN/3QhY2PIFh1eqcIdaN5uEjQPM= -cloud.google.com/go/translate v1.10.3/go.mod h1:GW0vC1qvPtd3pgtypCv4k4U8B7EdgK9/QEF2aJEUovs= -cloud.google.com/go/video v1.20.6/go.mod h1:d5AOlIfWXpDg15wvztHmjFvKTTImWJU7EnMVWkoiEAk= -cloud.google.com/go/videointelligence v1.11.7/go.mod h1:iMCXbfjurmBVgKuyLedTzv90kcnppOJ6ttb0+rLDID0= -cloud.google.com/go/vision/v2 v2.8.2/go.mod h1:BHZA1LC7dcHjSr9U9OVhxMtLKd5l2jKPzLRALEJvuaw= -cloud.google.com/go/vmmigration v1.7.7/go.mod h1:qYIK5caZY3IDMXQK+A09dy81QU8qBW0/JDTc39OaKRw= -cloud.google.com/go/vmwareengine v1.1.3/go.mod h1:UoyF6LTdrIJRvDN8uUB8d0yimP5A5Ehkr1SRzL1APZw= -cloud.google.com/go/vpcaccess v1.7.7/go.mod h1:EzfSlgkoAnFWEMznZW0dVNvdjFjEW97vFlKk4VNBhwY= -cloud.google.com/go/webrisk v1.9.7/go.mod h1:7FkQtqcKLeNwXCdhthdXHIQNcFWPF/OubrlyRcLHNuQ= -cloud.google.com/go/websecurityscanner v1.6.7/go.mod h1:EpiW84G5KXxsjtFKK7fSMQNt8JcuLA8tQp7j0cyV458= -cloud.google.com/go/workflows v1.12.6/go.mod h1:oDbEHKa4otYg4abwdw2Z094jB0TLLiFGAPA78EDAKag= -code.cloudfoundry.org/bytefmt v0.0.0-20240507165102-251b29179075 h1:/EIavdKMlm6qZfFDnXJfu2M2R2jFctue9C4BF742EtE= -code.cloudfoundry.org/bytefmt v0.0.0-20240507165102-251b29179075/go.mod h1:KghGLYo7qPX+I2O+IKHD3in3uE/bYcXmuL0jb6I0mRM= +cloud.google.com/go/longrunning v0.5.9/go.mod h1:HD+0l9/OOW0za6UWdKJtXoFAX/BGg/3Wj8p10NeWF7c= +cloud.google.com/go/longrunning v0.5.10 h1:eB/BniENNRKhjz/xgiillrdcH3G74TGSl3BXinGlI7E= +cloud.google.com/go/longrunning v0.5.10/go.mod h1:tljz5guTr5oc/qhlUjBlk7UAIFMOGuPNxkNDZXlLics= +cloud.google.com/go/managedidentities v1.6.10/go.mod h1:Dg+K/AgKJtOyDjrrMGh4wFrEmtlUUcoEtDdC/WsZxw4= +cloud.google.com/go/maps v1.11.4/go.mod h1:RQ2Vv/f2HKGlvCtj8xyJp8gJbVqh/CWy0xR2Nfe8c0s= +cloud.google.com/go/mediatranslation v0.8.10/go.mod h1:sCTNVpO4Yh9LbkjelsGakWBi93u9THKfKQLSGSLS7rA= +cloud.google.com/go/memcache v1.10.10/go.mod h1:UXnN6UYNoNM6RTExZ7/iW9c2mAaeJjy7R7uaplNRmIc= +cloud.google.com/go/metastore v1.13.9/go.mod h1:KgRseDRcS7Um/mNLbRHJjXZQrK8MqlGSyEga7T/Vs1A= +cloud.google.com/go/monitoring v1.20.3/go.mod h1:GPIVIdNznIdGqEjtRKQWTLcUeRnPjZW85szouimiczU= +cloud.google.com/go/networkconnectivity v1.14.9/go.mod h1:J1JgZDeSi/elFfOSLkMoY9REuGhoNXqOFuI0cfyS6WY= +cloud.google.com/go/networkmanagement v1.13.5/go.mod h1:znPuYKLqWJLzLI9feH6ex+Mq+6VlexfiUR8F6sFOtGo= +cloud.google.com/go/networksecurity v0.9.10/go.mod h1:pHy4lna09asqVhLwHVUXn92KGlM5oj1iSLFUwqqGZ2g= +cloud.google.com/go/notebooks v1.11.8/go.mod h1:jkRKhXWSXtzKtoPd9QeDzHrMPTYxf4l1rQP1/+6iR9g= +cloud.google.com/go/optimization v1.6.8/go.mod h1:d/uDAEVA0JYzWO3bCcuC6nnZKTjrSWhNkCTFUOV39g0= +cloud.google.com/go/orchestration v1.9.5/go.mod h1:64czIksdxj1B3pu0JXHVqwSmCZEoJfmuJWssWRXrVsc= +cloud.google.com/go/orgpolicy v1.12.5/go.mod h1:f778/jOHKp6cP6NbbQgjy4SDfQf6BoVGiSWdxky3ONQ= +cloud.google.com/go/orgpolicy v1.12.6/go.mod h1:yEkOiKK4w2tBzxLFvjO9kqoIRBXoF29vFeNqhGiifpE= +cloud.google.com/go/osconfig v1.13.0/go.mod h1:tlACnQi1rtSLnHRYzfw9SH9zXs0M7S1jqiW2EOCn2Y0= +cloud.google.com/go/osconfig v1.13.1/go.mod h1:3EcPSKozSco5jbdv2CZDojH0RVcRKvOdPrkrl+iHwuI= +cloud.google.com/go/oslogin v1.13.6/go.mod h1:7g1whx5UORkP8K8qGFhlc6njxFA35SX1V4dDNpWWku0= +cloud.google.com/go/phishingprotection v0.8.10/go.mod h1:QJKnexvHGqL3u0qshpJBsjqCo+EEy3K/PrvogvcON8Q= +cloud.google.com/go/policytroubleshooter v1.10.8/go.mod h1:d+6phd7MABmER7PCqlHSWGE35NFDMJfu7cLjTr820UE= +cloud.google.com/go/privatecatalog v0.9.10/go.mod h1:RxEAFdbH+8Ogu+1Lfp43KuAC6YIj46zWyoCX1dWB9nk= +cloud.google.com/go/pubsub v1.40.0/go.mod h1:BVJI4sI2FyXp36KFKvFwcfDRDfR8MiLT8mMhmIhdAeA= +cloud.google.com/go/pubsublite v1.8.2/go.mod h1:4r8GSa9NznExjuLPEJlF1VjOPOpgf3IT6k8x/YgaOPI= +cloud.google.com/go/recaptchaenterprise/v2 v2.14.1/go.mod h1:s1dcJEzWpEsgZN8aqHacC3mWUaQPd8q/QoibU/nkr18= +cloud.google.com/go/recommendationengine v0.8.10/go.mod h1:vlLaupkdqL3wuabhhjvrpH7TFswyxO6+P0L3AqrATPU= +cloud.google.com/go/recommender v1.12.6/go.mod h1:BNNC/CEIGV3y6hQNjewrVx80PIidfFtf8D+6SCEgLnA= +cloud.google.com/go/redis v1.16.3/go.mod h1:zqagsFk9fZzFKJB5NzijOUi53BeU5jUiPa4Kz/8Qz+Q= +cloud.google.com/go/resourcemanager v1.9.10/go.mod h1:UJ5zGD2ZD+Ng3MNxkU1fwBbpJQEQE1UctqpvV5pbP1M= +cloud.google.com/go/resourcesettings v1.7.3/go.mod h1:lMSnOoQPDKzcF6LGJOBcQqGCY2Zm8ZhbHEzhqdU61S8= +cloud.google.com/go/retail v1.17.3/go.mod h1:8OWmRAUXg8PKs1ef+VwrBLYBRdYJxq+YyxiytMaUBRI= +cloud.google.com/go/run v1.3.10/go.mod h1:zQGa7V57WWZhyiUYMlYitrBZzR+d2drzJQvrpaQ8YIA= +cloud.google.com/go/scheduler v1.10.11/go.mod h1:irpDaNL41B5q8hX/Ki87hzkxO8FnZEhhZnFk6OP8TnE= +cloud.google.com/go/secretmanager v1.13.5/go.mod h1:/OeZ88l5Z6nBVilV0SXgv6XJ243KP2aIhSWRMrbvDCQ= +cloud.google.com/go/security v1.17.3/go.mod h1:CuKzQq5OD6TXAYaZs/jI0d7CNHoD0LXbpsznIIIn4f4= +cloud.google.com/go/securitycenter v1.33.0/go.mod h1:lkEPItFjC1RRBHniiWR3lJTpUJW+7+EFAb7nP5ZCQxI= +cloud.google.com/go/servicedirectory v1.11.10/go.mod h1:pgbBjH2r73lEd3Y7eNA64fRO3g1zL96PMu+/hAjkH6g= +cloud.google.com/go/shell v1.7.10/go.mod h1:1sKAD5ijarrTLPX0VMQai6jCduRxaU2A6w0JWVGCNag= +cloud.google.com/go/spanner v1.64.0/go.mod h1:TOFx3pb2UwPsDGlE1gTehW+y6YlU4IFk+VdDHSGQS/M= +cloud.google.com/go/speech v1.23.4/go.mod h1:pv5VPKuXsZStCnTBImQP8HDfQHgG4DxJSlDyx5Kcwak= +cloud.google.com/go/storage v1.43.0 h1:CcxnSohZwizt4LCzQHWvBf1/kvtHUn7gk9QERXPyXFs= +cloud.google.com/go/storage v1.43.0/go.mod h1:ajvxEa7WmZS1PxvKRq4bq0tFT3vMd502JwstCcYv0Q0= +cloud.google.com/go/storagetransfer v1.10.9/go.mod h1:QKkg5Wau5jc0iXlPOZyEv3hH9mjCLeYIBiRrZTf6Ehw= +cloud.google.com/go/talent v1.6.11/go.mod h1:tmMptbP5zTw6tjudgip8LObeh7E4xHNC/IYsiGtxnrc= +cloud.google.com/go/texttospeech v1.7.10/go.mod h1:ChThPazSxR7e4qe9ryRlFGU4lRONvL9Oo2geyp7LX4o= +cloud.google.com/go/tpu v1.6.10/go.mod h1:O+N+S0i3bOH6NJ+s9GPsg9LC7jnE1HRSp8CSRYjCrfM= +cloud.google.com/go/trace v1.10.11/go.mod h1:fUr5L3wSXerNfT0f1bBg08W4axS2VbHGgYcfH4KuTXU= +cloud.google.com/go/translate v1.10.6/go.mod h1:vqZOHurggOqpssx/agK9S21UdStpwugMOhlHvWEGAdw= +cloud.google.com/go/video v1.21.3/go.mod h1:tp2KqkcxNEL5k2iF2Hd38aIWlNo/ew+i1yklhlyq6BM= +cloud.google.com/go/videointelligence v1.11.10/go.mod h1:5oW8qq+bk8Me+3fNoQK+27CCw4Nsuk/YN7zMw7vNDTA= +cloud.google.com/go/vision/v2 v2.8.5/go.mod h1:3X2ni4uSzzqpj8zTUD6aia62O1NisD19JH3l5i0CoM4= +cloud.google.com/go/vmmigration v1.7.10/go.mod h1:VkoA4ktmA0C3fr7LqhthGtGWEmgM7WHWg6ObxeXR5lU= +cloud.google.com/go/vmwareengine v1.1.6/go.mod h1:9txHCR2yJ6H9pFsfehTXLte5uvl/wOiM2PCtcVfglvI= +cloud.google.com/go/vpcaccess v1.7.10/go.mod h1:69kdbMh8wvGcM3agEHP1YnHPyxIBSRcZuK+KWZlpVLI= +cloud.google.com/go/webrisk v1.9.10/go.mod h1:wDxtALjJMXlGR2c3qtZaVI5jRKcneIMTYqV1IA1jPmo= +cloud.google.com/go/websecurityscanner v1.6.10/go.mod h1:ndil05bWkG/KDgWAXwFFAuvOYcOKu+mk/wC/nIfLQwE= +cloud.google.com/go/workflows v1.12.9/go.mod h1:g9S8NdA20MnQTReKVrXCDsnPrOsNgwonY7xZn+vr3SY= +code.cloudfoundry.org/bytefmt v0.0.0-20240725181214-870a2a4a34a6 h1:5wA7H4/Uyij80SkebgeIbSSUw14EzaaWw8/VSt/9ke8= +code.cloudfoundry.org/bytefmt v0.0.0-20240725181214-870a2a4a34a6/go.mod h1:0WabI+CfmksKbGuDTQSdOtS0iIfrWLzjLVbgviM82Hg= 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= @@ -152,10 +166,12 @@ filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4 fyne.io/fyne v1.4.3/go.mod h1:8kiPBNSDmuplxs9WnKCkaWYqbcXFy0DeAzwa6PBO9Z8= fyne.io/fyne/v2 v2.3.5/go.mod h1:fbrL+kwOQ6sdVhnURktTHIRIEXwysQSLeejyFyABmNI= fyne.io/systray v1.10.1-0.20230602210930-b6a2d6ca2a7b/go.mod h1:oM2AQqGJ1AMo4nNqZFYU8xYygSBZkW2hmdJ7n4yjedE= +gioui.org v0.0.0-20210822154628-43a7030f6e0b/go.mod h1:jmZ349gZNGWyc5FIv/VWLBQ32Ki/FOvTgEz64kh9lnk= gioui.org v0.2.0/go.mod h1:1H72sKEk/fNFV+l0JNeM2Dt3co3Y4uaQcD+I+/GQ0e4= gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= +gioui.org/shader v1.0.0/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM= gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM= gioui.org/x v0.2.0/go.mod h1:rCGN2nZ8ZHqrtseJoQxCMZpt2xrZUrdZ2WuMRLBJmYs= git.sr.ht/~jackmordaunt/go-toast v1.0.0/go.mod h1:aIuRX/HdBOz7yRS8rOVYQCwJQlFS7DbYBTpUV0SHeeg= @@ -166,14 +182,14 @@ git.sr.ht/~sbinet/gg v0.5.0/go.mod h1:G2C0eRESqlKhS7ErsNey6HHrqU1PwsnCQlekFi9Q2O git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0/go.mod h1:+axXBRUTIDlCeE73IKeD/os7LoEnTKdkp8/gQOFjqyo= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= 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/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-20240329135147-d1f085d9d01e/go.mod h1:RuIzK38BeA036XEv6Cyl34k98GMwIuciL8v5f+yjo0k= -github.com/ajstarks/deck/generate v0.0.0-20240329135147-d1f085d9d01e/go.mod h1:al/X+Mdfx3esXeGnnIVn5aYB6SfwTu+9T0u4EXmKJuk= +github.com/ajstarks/deck v0.0.0-20240717142941-38ed00367aa6/go.mod h1:5o5HzZ3nUiOivE0SPQepE7oNquDd+9yip0PtlFpq888= +github.com/ajstarks/deck/generate v0.0.0-20240717142941-38ed00367aa6/go.mod h1:al/X+Mdfx3esXeGnnIVn5aYB6SfwTu+9T0u4EXmKJuk= github.com/ajstarks/fc v0.0.0-20230606144319-ef5d5cb73a3d/go.mod h1:Qp3TfzbBiIjHwDxIpu+g9nYfNw+xXF2Yqp4WmMlTtwM= github.com/ajstarks/openvg v0.0.0-20191008131700-c6885d824eb8/go.mod h1:jpZHIkd4sQEgrzshrUQrRfv5OUMMq0w/Q1yK6ZYhUlk= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw= @@ -194,53 +210,53 @@ github.com/apache/arrow/go/v15 v15.0.2/go.mod h1:DGXsR3ajT524njufqf95822i+KTh+ye github.com/apache/thrift v0.17.0/go.mod h1:OLxhMRJxomX+1I/KUw03qoV3mMz16BwaKI+d4fPBx7Q= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/aws/aws-sdk-go v1.52.4 h1:9VsBVJ2TKf8xPP3+yIPGSYcEBIEymXsJzQoFgQuyvA0= -github.com/aws/aws-sdk-go v1.52.4/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go-v2 v1.26.1 h1:5554eUqIYVWpU0YmeeYZ0wU64H2VLBs8TlhRB2L+EkA= -github.com/aws/aws-sdk-go-v2 v1.26.1/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 h1:x6xsQXGSmW6frevwDA+vi/wqhp1ct18mVXYN08/93to= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2/go.mod h1:lPprDr1e6cJdyYeGXnRaJoP4Md+cDBvi2eOj00BlGmg= -github.com/aws/aws-sdk-go-v2/config v1.27.11 h1:f47rANd2LQEYHda2ddSCKYId18/8BhSRM4BULGmfgNA= -github.com/aws/aws-sdk-go-v2/config v1.27.11/go.mod h1:SMsV78RIOYdve1vf36z8LmnszlRWkwMQtomCAI0/mIE= -github.com/aws/aws-sdk-go-v2/credentials v1.17.11 h1:YuIB1dJNf1Re822rriUOTxopaHHvIq0l/pX3fwO+Tzs= -github.com/aws/aws-sdk-go-v2/credentials v1.17.11/go.mod h1:AQtFPsDH9bI2O+71anW6EKL+NcD7LG3dpKGMV4SShgo= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 h1:FVJ0r5XTHSmIHJV6KuDmdYhEpvlHpiSd38RQWhut5J4= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1/go.mod h1:zusuAeqezXzAB24LGuzuekqMAEgWkVYukBec3kr3jUg= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.15 h1:7Zwtt/lP3KNRkeZre7soMELMGNoBrutx8nobg1jKWmo= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.15/go.mod h1:436h2adoHb57yd+8W+gYPrrA9U/R/SuAuOO42Ushzhw= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.5 h1:aw39xVGeRWlWx9EzGVnhOR4yOjQDHPQ6o6NmBlscyQg= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.5/go.mod h1:FSaRudD0dXiMPK2UjknVwwTYyZMRsHv3TtkabsZih5I= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.5 h1:PG1F3OD1szkuQPzDw3CIQsRIrtTlUC3lP84taWzHlq0= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.5/go.mod h1:jU1li6RFryMz+so64PpKtudI+QzbKoIEivqdf6LNpOc= +github.com/aws/aws-sdk-go v1.55.3 h1:0B5hOX+mIx7I5XPOrjrHlKSDQV/+ypFZpIHOx5LOk3E= +github.com/aws/aws-sdk-go v1.55.3/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= +github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY= +github.com/aws/aws-sdk-go-v2 v1.30.3/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 h1:tW1/Rkad38LA15X4UQtjXZXNKsCgkshC3EbmcUmghTg= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3/go.mod h1:UbnqO+zjqk3uIt9yCACHJ9IVNhyhOCnYk8yA19SAWrM= +github.com/aws/aws-sdk-go-v2/config v1.27.27 h1:HdqgGt1OAP0HkEDDShEl0oSYa9ZZBSOmKpdpsDMdO90= +github.com/aws/aws-sdk-go-v2/config v1.27.27/go.mod h1:MVYamCg76dFNINkZFu4n4RjDixhVr51HLj4ErWzrVwg= +github.com/aws/aws-sdk-go-v2/credentials v1.17.27 h1:2raNba6gr2IfA0eqqiP2XiQ0UVOpGPgDSi0I9iAP+UI= +github.com/aws/aws-sdk-go-v2/credentials v1.17.27/go.mod h1:gniiwbGahQByxan6YjQUMcW4Aov6bLC3m+evgcoN4r4= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 h1:KreluoV8FZDEtI6Co2xuNk/UqI9iwMrOx/87PBNIKqw= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11/go.mod h1:SeSUYBLsMYFoRvHE0Tjvn7kbxaUhl75CJi1sbfhMxkU= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.9 h1:TC2vjvaAv1VNl9A0rm+SeuBjrzXnrlwk6Yop+gKRi38= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.9/go.mod h1:WPv2FRnkIOoDv/8j2gSUsI4qDc7392w5anFB/I89GZ8= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 h1:SoNJ4RlFEQEbtDcCEt+QG56MY4fm4W8rYirAmq+/DdU= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15/go.mod h1:U9ke74k1n2bf+RIgoX1SXFed1HLs51OgUSs+Ph0KJP8= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 h1:C6WHdGnTDIYETAm5iErQUiVNsclNx9qbJVPIt03B6bI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15/go.mod h1:ZQLZqhcu+JhSrA9/NXRm8SkDvsycE+JkV3WGY41e+IM= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.3 h1:mDnFOE2sVkyphMWtTH+stv0eW3k0OTx94K63xpxHty4= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.3/go.mod h1:V8MuRVcCRt5h1S+Fwu8KbC7l/gBGo3yBAyUbJM2IJOk= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 h1:Ji0DY1xUsUr3I8cHps0G+XM3WWU16lP6yG8qu1GAZAs= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2/go.mod h1:5CsjAbs3NlGQyZNFACh+zztPDI7fU6eW9QsxjfnuBKg= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.7 h1:ZMeFZ5yk+Ek+jNr1+uwCd2tG89t6oTS5yVWpa6yy2es= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.7/go.mod h1:mxV05U+4JiHqIpGqqYXOHLPKUC6bDXC44bsUhNjOEwY= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7 h1:ogRAwT1/gxJBcSWDMZlgyFUM962F51A5CRhDLbxLdmo= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7/go.mod h1:YCsIZhXfRPLFFCl5xxY+1T9RKzOKjCut+28JSX2DnAk= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.5 h1:f9RyWNtS8oH7cZlbn+/JNPpjUk5+5fLd5lM9M0i49Ys= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.5/go.mod h1:h5CoMZV2VF297/VLhRhO1WF+XYWOzXo+4HsObA4HjBQ= -github.com/aws/aws-sdk-go-v2/service/s3 v1.53.1 h1:6cnno47Me9bRykw9AEv9zkXE+5or7jz8TsskTTccbgc= -github.com/aws/aws-sdk-go-v2/service/s3 v1.53.1/go.mod h1:qmdkIIAC+GCLASF7R2whgNrJADz0QZPX+Seiw/i4S3o= -github.com/aws/aws-sdk-go-v2/service/sso v1.20.5 h1:vN8hEbpRnL7+Hopy9dzmRle1xmDc7o8tmY0klsr175w= -github.com/aws/aws-sdk-go-v2/service/sso v1.20.5/go.mod h1:qGzynb/msuZIE8I75DVRCUXw3o3ZyBmUvMwQ2t/BrGM= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.2 h1:pi0Skl6mNl2w8qWZXcdOyg197Zsf4G97U7Sso9JXGZE= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.2/go.mod h1:JYzLoEVeLXk+L4tn1+rrkfhkxl6mLDEVaDSvGq9og90= -github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 h1:cwIxeBttqPN3qkaAjcEcsh8NYr8n2HZPkcKgPAi1phU= -github.com/aws/aws-sdk-go-v2/service/sts v1.28.6/go.mod h1:FZf1/nKNEkHdGGJP/cI2MoIMquumuRK6ol3QQJNDxmw= -github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q= -github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.5 h1:81KE7vaZzrl7yHBYHVEzYB8sypz11NMOZ40YlWvPxsU= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.5/go.mod h1:LIt2rg7Mcgn09Ygbdh/RdIm0rQ+3BNkbP1gyVMFtRK0= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 h1:dT3MqvGhSoaIhRseqw2I0yH81l7wiR2vjs57O51EAm8= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3/go.mod h1:GlAeCkHwugxdHaueRr4nhPuY+WW+gR8UjlcqzPr1SPI= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.17 h1:YPYe6ZmvUfDDDELqEKtAd6bo8zxhkm+XEFEzQisqUIE= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.17/go.mod h1:oBtcnYua/CgzCWYN7NZ5j7PotFDaFSUjCYVTtfyn7vw= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 h1:HGErhhrxZlQ044RiM+WdoZxp0p+EGM62y3L6pwA4olE= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17/go.mod h1:RkZEx4l0EHYDJpWppMJ3nD9wZJAa8/0lq9aVC+r2UII= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.15 h1:246A4lSTXWJw/rmlQI+TT2OcqeDMKBdyjEQrafMaQdA= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.15/go.mod h1:haVfg3761/WF7YPuJOER2MP0k4UAXyHaLclKXB6usDg= +github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2 h1:sZXIzO38GZOU+O0C+INqbH7C2yALwfMWpd64tONS/NE= +github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2/go.mod h1:Lcxzg5rojyVPU/0eFwLtcyTaek/6Mtic5B1gJo7e/zE= +github.com/aws/aws-sdk-go-v2/service/sso v1.22.4 h1:BXx0ZIxvrJdSgSvKTZ+yRBeSqqgPM89VPlulEcl37tM= +github.com/aws/aws-sdk-go-v2/service/sso v1.22.4/go.mod h1:ooyCOXjvJEsUw7x+ZDHeISPMhtwI3ZCB7ggFMcFfWLU= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 h1:Jux+gDDyi1Lruk+KHF91tK2KCuY61kzoCpvtvJJBtOE= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4/go.mod h1:mUYPBhaF2lGiukDEjJX2BLRRKTmoUSitGDUgM4tRxak= +github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 h1:ZsDKRLXGWHk8WdtyYMoGNO7bTudrvuKpDKgMVRlepGE= +github.com/aws/aws-sdk-go-v2/service/sts v1.30.3/go.mod h1:zwySh8fpFyXp9yOr/KVzxOl8SRqgf/IDw5aUt9UKFcQ= +github.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE= +github.com/aws/smithy-go v1.20.3/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= +github.com/boombuler/barcode v1.0.2/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= @@ -249,14 +265,12 @@ github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMr github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= -github.com/chromedp/chromedp v0.9.2/go.mod h1:LkSXJKONWTCHAfQasKFUZI+mxqS4tZqhmtGzzhLsnLs= -github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= -github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b h1:ga8SEFjZ60pxLcmhnThWgvH2wg8376yUJmPhEH4H3kw= -github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= +github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 h1:N+3sFI5GUjRKBi+i0TxYVST9h4Ie192jJWpHvthBBgg= +github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0= github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= @@ -269,8 +283,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/emicklei/go-restful/v3 v3.12.0 h1:y2DdzBAURM29NFF94q6RaY4vjIH1rtwDapwQtU84iWk= -github.com/emicklei/go-restful/v3 v3.12.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU= +github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.12.0 h1:4X+VP1GHd1Mhj6IB5mMeGbLCleqxjletLK6K0rbxyZI= github.com/envoyproxy/go-control-plane v0.12.0/go.mod h1:ZBTaoJ23lqITozF0M6G4/IragXCQKCnYbmlmtHvwRG0= github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= @@ -301,19 +315,19 @@ github.com/fyne-io/mobile v0.1.2/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y9 github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8bk= github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= -github.com/go-fonts/dejavu v0.3.3 h1:YZxbkwCBqVC0BojBvGdDdQuDqtm0oRs95eGhSPYbTvg= -github.com/go-fonts/dejavu v0.3.3/go.mod h1:EpsVvJxpY/lRM2MbkThHF/5161F8YZdBFIC9uT3/Uqc= -github.com/go-fonts/latin-modern v0.3.2 h1:M+Sq24Dp0ZRPf3TctPnG1MZxRblqyWC/cRUL9WmdaFc= -github.com/go-fonts/latin-modern v0.3.2/go.mod h1:9odJt4NbRrbdj4UAMuLVd4zEukf6aAEKnDaQga0whqQ= -github.com/go-fonts/liberation v0.3.2 h1:XuwG0vGHFBPRRI8Qwbi5tIvR3cku9LUfZGq/Ar16wlQ= -github.com/go-fonts/liberation v0.3.2/go.mod h1:N0QsDLVUQPy3UYg9XAc3Uh3UDMp2Z7M1o4+X98dXkmI= +github.com/go-fonts/dejavu v0.3.4 h1:Qqyx9IOs5CQFxyWTdvddeWzrX0VNwUAvbmAzL0fpjbc= +github.com/go-fonts/dejavu v0.3.4/go.mod h1:D1z0DglIz+lmpeNYMYlxW4r22IhcdOYnt+R3PShU/Kg= +github.com/go-fonts/latin-modern v0.3.3 h1:g2xNgI8yzdNzIVm+qvbMryB6yGPe0pSMss8QT3QwlJ0= +github.com/go-fonts/latin-modern v0.3.3/go.mod h1:tHaiWDGze4EPB0Go4cLT5M3QzRY3peya09Z/8KSCrpY= +github.com/go-fonts/liberation v0.3.3 h1:tM/T2vEOhjia6v5krQu8SDDegfH1SfXVRUNNKpq0Usk= +github.com/go-fonts/liberation v0.3.3/go.mod h1:eUAzNRuJnpSnd1sm2EyloQfSOT79pdw7X7++Ri+3MCU= github.com/go-fonts/stix v0.2.2/go.mod h1:SUxggC9dxd/Q+rb5PkJuvfvTbOPtNc2Qaua00fIp9iU= github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-latex/latex v0.0.0-20231108140139-5c1ce85aa4ea h1:DfZQkvEbdmOe+JK2TMtBM+0I9GSdzE2y/L1/AmD8xKc= -github.com/go-latex/latex v0.0.0-20231108140139-5c1ce85aa4ea/go.mod h1:Y7Vld91/HRbTBm7JwoI7HejdDB0u+e9AUBO9MB7yuZk= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-latex/latex v0.0.0-20240709081214-31cef3c7570e h1:xcdj0LWnMSIU1j8+jIeJyfvk6SjgJedFQssSqFthJ2E= +github.com/go-latex/latex v0.0.0-20240709081214-31cef3c7570e/go.mod h1:J4SAGzkcl+28QWi7yz72tyC/4aGnppOvya+AEv4TaAQ= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= @@ -330,7 +344,7 @@ github.com/go-pdf/fpdf v1.4.3/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhO github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= @@ -349,12 +363,9 @@ github.com/go-toolsmith/astequal v1.2.0 h1:3Fs3CYZ1k9Vo4FzFhwwewC3CHISHDnVUPC4x0 github.com/go-toolsmith/astequal v1.2.0/go.mod h1:c8NZ3+kSFtFY/8lPso4v8LuJjdJiUFVnSuU3s0qrrDY= github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQiyP2Bvw= github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ= -github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= -github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc= github.com/goccmack/gocc v0.0.0-20230228185258-2292f9e40198/go.mod h1:DTh/Y2+NbnOVVoypCCQrovMPDKUGp4yZpSbWg5D0XIM= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +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= @@ -372,7 +383,7 @@ github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= @@ -388,17 +399,17 @@ github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYu github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-pkcs11 v0.2.1-0.20230907215043-c6f79328ddf9/go.mod h1:6eQoGcuNJpa7jnd5pMGdkSaQpNDYvPlXWMcjXXThLlY= -github.com/google/go-replayers/grpcreplay v1.1.0 h1:S5+I3zYyZ+GQz68OfbURDdt/+cSMqCK1wrvNx7WBzTE= -github.com/google/go-replayers/grpcreplay v1.1.0/go.mod h1:qzAvJ8/wi57zq7gWqaE6AwLM6miiXUQwP1S+I9icmhk= +github.com/google/go-replayers/grpcreplay v1.3.0 h1:1Keyy0m1sIpqstQmgz307zhiJ1pV4uIlFds5weTmxbo= +github.com/google/go-replayers/grpcreplay v1.3.0/go.mod h1:v6NgKtkijC0d3e3RW8il6Sy5sqRVUwoQa4mHOGEy8DI= github.com/google/go-replayers/httpreplay v1.2.0 h1:VM1wEyyjaoU53BwrOnaf9VhAyQQEEioJvFYxYcLRKzk= github.com/google/go-replayers/httpreplay v1.2.0/go.mod h1:WahEFFZZ7a1P4VM1qEeHy+tME4bwyqPcwWbNlUI1Mcg= 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-20240507183855-6f11f98ebb1c h1:GCixZ7sgey01Kjw8pxBzCD0uVrubxl8SRzRgI0jwP+A= -github.com/google/pprof v0.0.0-20240507183855-6f11f98ebb1c/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= -github.com/google/s2a-go v0.1.0/go.mod h1:OJpEgntRZo8ugHpF9hkoLJbS5dSI20XZeXJ9JVywLlM= +github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8 h1:ssNFCCVmib/GQSzx3uCWyfMgOamLGWuGqlMS77Y1m3Y= +github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +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 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= @@ -409,29 +420,35 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI= github.com/google/wire v0.6.0/go.mod h1:F4QhpQ9EDIdJ1Mbop/NZBRB+5yrR6qg3BnctaoUk6NA= +github.com/googleapis/cloud-bigtable-clients-test v0.0.0-20221104150409-300c96f7b1f5/go.mod h1:Udm7et5Lt9Xtzd4n07/kKP80IdlR4zVDjtlUZEO2Dd8= +github.com/googleapis/cloud-bigtable-clients-test v0.0.0-20230505150253-16eeee810d3a/go.mod h1:2n/InOx7Q1jaqXZJ0poJmsZxb6K+OfHEbhA/+LPJrII= +github.com/googleapis/cloud-bigtable-clients-test v0.0.2/go.mod h1:mk3CrkrouRgtnhID6UZQDK3DrFFa7cYCAJcEmNsHYrY= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/enterprise-certificate-proxy v0.2.4/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/googleapis/enterprise-certificate-proxy v0.3.1/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs= github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= -github.com/googleapis/gax-go/v2 v2.12.4 h1:9gWcmF85Wvq4ryPFvGFaOgPIs1AQX0d0bcbGw4Z96qg= -github.com/googleapis/gax-go/v2 v2.12.4/go.mod h1:KYEYLorsnIGDi/rPC8b5TdlB9kbKoFubselGIoBMCwI= +github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s= +github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A= github.com/googleapis/google-cloud-go-testing v0.0.0-20210719221736-1c9a4c676720/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20211219123610-ec9572f70e60/go.mod h1:cz9oNYuRUWGdHmLF2IodMLkAhcPtXeULvcBNagUrxTI= github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/goxjs/gl v0.0.0-20210104184919-e3fafc6f8f2a/go.mod h1:dy/f2gjY09hwVfIyATps4G2ai7/hLwLkc5TrPqONuXY= github.com/goxjs/glfw v0.0.0-20191126052801-d2efb5f20838/go.mod h1:oS8P8gVOT4ywTcjV6wZlOU4GuVFQ8F5328KY3MJ79CY= +github.com/grafana/pyroscope-go/godeltaprof v0.1.7 h1:C11j63y7gymiW8VugJ9ZW0pWfxTZugdSJyC48olk5KY= +github.com/grafana/pyroscope-go/godeltaprof v0.1.7/go.mod h1:Tk376Nbldo4Cha9RgiU7ik8WKFkNpfds98aUzS8omLE= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 h1:CWyXh/jylQWp2dtiV33mY4iSSp6yf4lmn+c7/tN+ObI= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0/go.mod h1:nCLIt0w3Ept2NwF8ThLmrppXsfT07oC8k0XNDxd8sVU= github.com/hamba/avro/v2 v2.17.2/go.mod h1:Q9YK+qxAhtVrNqOhwlZTATLgLA8qxG2vtvkhK8fJ7Jo= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= @@ -441,8 +458,9 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jackmordaunt/icns v0.0.0-20181231085925-4f16af745526/go.mod h1:UQkeMHVoNcyXYq9otUupF7/h/2tmHlhrS2zw7ZVvUqc= github.com/jackmordaunt/icns/v2 v2.2.1/go.mod h1:6aYIB9eSzyfHHMKqDf17Xrs1zetQPReAkiUSHzdw4cI= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= +github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc= github.com/jezek/xgb v1.0.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk= +github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= @@ -462,10 +480,10 @@ 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.9-0.20240412100233-8bd3916ec655 h1:8Wwu7TntAfVPzPYVkCUGw5YrA8ohgXPg9nJTtk/VbA8= -github.com/klauspost/compress v1.17.9-0.20240412100233-8bd3916ec655/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/compress v1.17.10-0.20240719110028-cfab8bd586ec h1:S0mztzoHWmIpI4VuqO7MPIf3DQQxWwW5e3Uurb+HMHA= +github.com/klauspost/compress v1.17.10-0.20240719110028-cfab8bd586ec/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +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= github.com/kpango/fastime v1.1.9/go.mod h1:vyD7FnUn08zxY4b/QFBZVG+9EWMYsNl+QF0uE46urD4= github.com/kpango/fuid v0.0.0-20221203053508-503b5ad89aa1 h1:rxyM+7uaZQ35P9fbixdnld/h4AgEhODoubuy6A4nDdk= @@ -485,7 +503,6 @@ github.com/kubernetes-csi/external-snapshotter/client/v6 v6.3.0 h1:qS4r4ljINLWKJ github.com/kubernetes-csi/external-snapshotter/client/v6 v6.3.0/go.mod h1:oGXx2XTEzs9ikW2V6IC1dD8trgjRsS/Mvc2JRiC618Y= github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4= github.com/leanovate/gopter v0.2.11/go.mod h1:aK3tzZP/C+p1m3SPRE4SYZFGP7jjkuSI4f7Xvpt0S9c= -github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -508,8 +525,8 @@ github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcs github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= -github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= +github.com/moby/spdystream v0.5.0 h1:7r0J1Si3QO/kjRitvSLVVFUjxMEb/YLj6S9FF62JBCU= +github.com/moby/spdystream v0.5.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI= github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= @@ -530,11 +547,10 @@ github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.17.3 h1:oJcvKpIb7/8uLpDDtnQuf18xVnwKp8DTD7DQ6gTd/MU= -github.com/onsi/ginkgo/v2 v2.17.3/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= -github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= -github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= -github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= +github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= +github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= +github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= +github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= @@ -552,14 +568,14 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= -github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= -github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= 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.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= -github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= -github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s= -github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +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= github.com/quasilyte/go-ruleguard v0.4.2/go.mod h1:GJLgqsLeo4qgavUoL8JeGFNS7qcisx3awV/w9eWTmNI= github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe60+5DqOpCjPE= @@ -590,8 +606,8 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec= github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/srwiley/oksvg v0.0.0-20200311192757-870daf9aa564/go.mod h1:afMbS0qvv1m5tfENCwnOdZGOF8RGR/FsZ7bvBxQGZG4= @@ -623,32 +639,31 @@ go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0= go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ= 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/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 h1:A3SayB3rNyt+1S6qpI9mHPkeHTZbD7XILEqWnYZb2l0= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0/go.mod h1:27iA5uvhuRNmalO+iEUdVn5ZMj2qy10Mm+XRIpRmyuU= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0/go.mod h1:SK2UL73Zy1quvRPonmOmRDiWk1KBV3LyIeeIxcEApWw= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0/go.mod h1:rdENBZMT2OE6Ne/KLwpiXudnAsbdrdBaqBvTN8M8BgA= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0 h1:9G6E0TXzGFVfTnawRzrPl83iHOAV7L8NJiR8RSGYV1g= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0/go.mod h1:azvtTADFQJA8mX80jIH/akaE7h+dbm/sVuaHqN13w74= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= -go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.26.0 h1:+hm+I+KigBy3M24/h1p/NHkUx/evbLH0PNcjpMyCHc4= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.26.0/go.mod h1:NjC8142mLvvNT6biDpaMjyz78kyEHIwAJlSX0N9P5KI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 h1:1u/AyyOqAWzy+SkPxDpahCNZParHV8Vid1RnI2clyDE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0/go.mod h1:z46paqbJ9l7c9fIPCXTqTGwhQZ5XoTIsfeFYWboizjs= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0 h1:Waw9Wfpo/IXzOI8bCB7DIk+0JZcqqsyn1JFnAc+iam8= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0/go.mod h1:wnJIG4fOqyynOnnQF/eQb4/16VlX2EJAHhHgqIqWfAo= -go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30= -go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= -go.opentelemetry.io/otel/sdk v1.26.0 h1:Y7bumHf5tAiDlRYFmGqetNcLaVUZmh4iYfmGxtmz7F8= -go.opentelemetry.io/otel/sdk v1.26.0/go.mod h1:0p8MXpqLeJ0pzcszQQN4F0S5FVjBLgypeGSngLsmirs= -go.opentelemetry.io/otel/sdk/metric v1.26.0 h1:cWSks5tfriHPdWFnl+qpX3P681aAYqlZHcAyHw5aU9Y= -go.opentelemetry.io/otel/sdk/metric v1.26.0/go.mod h1:ClMFFknnThJCksebJwz7KIyEDHO+nTB6gK8obLy8RyE= -go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= -go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= -go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94= -go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A= -go.starlark.net v0.0.0-20240507195648-35fe9f26b4bc h1:WMJEq47tB89BoJ5HUfoMZVtN+0u6f32LgIfQlu3mMF8= -go.starlark.net v0.0.0-20240507195648-35fe9f26b4bc/go.mod h1:YKMCv9b1WrfWmeqdV5MAuEHWsu5iC+fe6kYl2sQjdI8= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 h1:Xs2Ncz0gNihqu9iosIZ5SkBbWo5T8JhhLJFMQL1qmLI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0/go.mod h1:s75jGIWA9OfCMzF0xr+ZgfrB5FEbbV7UuYo32ahUiFI= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 h1:R3X6ZXmNPRR8ul6i3WgFURCHzaXjHdm0karRG/+dj3s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0/go.mod h1:QWFXnDavXWwMx2EEcZsf3yxgEKAqsxQ+Syjp+seyInw= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= +go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= +go.starlark.net v0.0.0-20240725214946-42030a7cedce h1:YyGqCjZtGZJ+mRPaenEiB87afEO2MFRzLiJNZ0Z0bPw= +go.starlark.net v0.0.0-20240725214946-42030a7cedce/go.mod h1:YKMCv9b1WrfWmeqdV5MAuEHWsu5iC+fe6kYl2sQjdI8= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8= @@ -661,42 +676,43 @@ go.uber.org/ratelimit v0.3.1 h1:K4qVE+byfv/B3tC+4nYWP7v/6SimcO7HzHekoMNBma0= go.uber.org/ratelimit v0.3.1/go.mod h1:6euWsTB6U/Nb3X++xEUXA8ciPJvr19Q/0h1+oDcJhRk= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -gocloud.dev v0.37.0 h1:XF1rN6R0qZI/9DYjN16Uy0durAmSlf58DHOcb28GPro= -gocloud.dev v0.37.0/go.mod h1:7/O4kqdInCNsc6LqgmuFnS0GRew4XNNYWpA44yQnwco= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= +gocloud.dev v0.38.0 h1:SpxfaOc/Fp4PeO8ui7wRcCZV0EgXZ+IWcVSLn6ZMSw0= +gocloud.dev v0.38.0/go.mod h1:3XjKvd2E5iVNu/xFImRzjN0d/fkNHe4s0RiKidpEUMQ= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91/go.mod h1:VjAR7z0ngyATZTELrBSkxOOHhhlnVUxDye4mcjx5h/8= golang.org/x/exp/shiny v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0= golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0= -golang.org/x/exp/typeparams v0.0.0-20240506185415-9bf2ced13842 h1:S62OJe0/hUkTgveY1HXZMHWBOy21DVrobMYz2cMCO64= -golang.org/x/exp/typeparams v0.0.0-20240506185415-9bf2ced13842/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/image v0.16.0 h1:9kloLAKhUufZhA12l5fwnx2NZW39/we1UhBesW433jw= -golang.org/x/image v0.16.0/go.mod h1:ugSZItdV4nOxyqp56HmXwH0Ry0nBCpjnZdpDaIHdoPs= +golang.org/x/exp/shiny v0.0.0-20240707233637-46b078467d37/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o= +golang.org/x/exp/typeparams v0.0.0-20240719175910-8a7402abbf56 h1:i+QrZdyNyfLEnWjd5T6LQZvQP3xk2XiNs3sQgN7QDGE= +golang.org/x/exp/typeparams v0.0.0-20240719175910-8a7402abbf56/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= +golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ= +golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20240506190922-a1a533f289d3/go.mod h1:EiXZlVfUTaAyySFVJb9rsODuiO+WXu8HrUuySb7nYFw= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/mobile v0.0.0-20240716161057-1ad2df20a8b6/go.mod h1:TCsc78+c4cqb8IKEosz2LwJ6YRNkIjMuAYeHYjchGDE= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= -golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= -golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= +golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 h1:LLhsEBxRTBLuKlQxFBYUOU8xyFgXv6cOTp2HASDlsDk= +golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= gonum.org/v1/gonum v0.15.0 h1:2lYxjRbTYyxkJxlhC+LvJIx3SsANPdRybu1tGj9/OrQ= @@ -705,20 +721,20 @@ gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 h1:vJpL69PeUullhJyKtTjHjENE gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946/go.mod h1:BQUWDHIAygjdt1HnUPQ0eWqLN2n5FwJycrpYUVUOx2I= gonum.org/v1/plot v0.14.0 h1:+LBDVFYwFe4LHhdP8coW6296MBEY4nQ+Y4vuUpJopcE= gonum.org/v1/plot v0.14.0/go.mod h1:MLdR9424SJed+5VqC6MsouEpig9pZX2VZ57H9ko2bXU= -google.golang.org/api v0.178.0 h1:yoW/QMI4bRVCHF+NWOTa4cL8MoWL3Jnuc7FlcFF91Ok= -google.golang.org/api v0.178.0/go.mod h1:84/k2v8DFpDRebpGcooklv/lais3MEfqpaBLA12gl2U= +google.golang.org/api v0.189.0 h1:equMo30LypAkdkLMBqfeIqtyAnlyig1JSZArl4XPwdI= +google.golang.org/api v0.189.0/go.mod h1:FLWGJKb0hb+pU2j+rJqwbnsF+ym+fQs73rbJ+KAUgy8= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20240506185236-b8a5c65736ae h1:HjgkYCl6cWQEKSHkpUp4Q8VB74swzyBwTz1wtTzahm0= -google.golang.org/genproto v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:i4np6Wrjp8EujFAUn0CM0SH+iZhY1EbrfzEIJbFkHFM= -google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae h1:AH34z6WAGVNkllnKs5raNq3yRq93VnjBG6rpfub/jYk= -google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:FfiGhwUm6CJviekPrc0oJ+7h29e+DmWU6UtjX0ZvI7Y= -google.golang.org/genproto/googleapis/bytestream v0.0.0-20240429193739-8cf5692501f6/go.mod h1:ULqtoQMxDLNRfW+pJbKA68wtIy1OiYjdIsJs3PMpzh8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae h1:c55+MER4zkBS14uJhSZMGGmya0yJx5iHV4x/fpOSNRk= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/genproto v0.0.0-20240725223205-93522f1f2a9f h1:htT2I9bZvGm+110zq8bIErMX+WgBWxCzV3ChwbvnKnc= +google.golang.org/genproto v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:Sk3mLpoDFTAp6R4OvlcUgaG4ISTspKeFsIAXMn9Bm4Y= +google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f h1:b1Ln/PG8orm0SsBbHZWke8dDp2lrCD4jSmfglFpTZbk= +google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys= +google.golang.org/genproto/googleapis/bytestream v0.0.0-20240722135656-d784300faade/go.mod h1:5/MT647Cn/GGhwTpXC7QqcaR5Cnee4v4MKCU1/nwnIQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f h1:RARaIm8pxYuxyNPbBQf5igT7XdOyCNtat1qAT2ZxjU4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +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= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= @@ -732,24 +748,24 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2/go.mod h1:sUMDUKNB2ZcVjt92UnLy3cdGs+wDAcrPdV3JP6sVgA4= honnef.co/go/tools v0.4.7/go.mod h1:+rnGS1THNh8zMwnd2oVOTL9QF6vmfyG6ZXBULae2uc0= -k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA= -k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE= -k8s.io/apiextensions-apiserver v0.30.0 h1:jcZFKMqnICJfRxTgnC4E+Hpcq8UEhT8B2lhBcQ+6uAs= -k8s.io/apiextensions-apiserver v0.30.0/go.mod h1:N9ogQFGcrbWqAY9p2mUAL5mGxsLqwgtUce127VtRX5Y= -k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= -k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/cli-runtime v0.30.0 h1:0vn6/XhOvn1RJ2KJOC6IRR2CGqrpT6QQF4+8pYpWQ48= -k8s.io/cli-runtime v0.30.0/go.mod h1:vATpDMATVTMA79sZ0YUCzlMelf6rUjoBzlp+RnoM+cg= -k8s.io/client-go v0.30.0 h1:sB1AGGlhY/o7KCyCEQ0bPWzYDL0pwOZO4vAtTSh/gJQ= -k8s.io/client-go v0.30.0/go.mod h1:g7li5O5256qe6TYdAMyX/otJqMhIiGgTapdLchhmOaY= -k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= -k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f h1:0LQagt0gDpKqvIkAMPaRGcXawNMouPECM1+F9BVxEaM= -k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f/go.mod h1:S9tOR0FxgyusSNR+MboCuiDpVWkAifZvaYI1Q2ubgro= -k8s.io/metrics v0.30.0 h1:tqB+T0GJY288KahaO3Eb41HaDVeLR18gBmyPo0R417s= -k8s.io/metrics v0.30.0/go.mod h1:nSDA8V19WHhCTBhRYuyzJT9yPJBxSpqbyrGCCQ4jPj4= -k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCIXHaathvJg1C3ak= -k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI= +k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI= +k8s.io/apiextensions-apiserver v0.30.2 h1:l7Eue2t6QiLHErfn2vwK4KgF4NeDgjQkCXtEbOocKIE= +k8s.io/apiextensions-apiserver v0.30.2/go.mod h1:lsJFLYyK40iguuinsb3nt+Sj6CmodSI4ACDLep1rgjw= +k8s.io/apimachinery v0.30.2 h1:fEMcnBj6qkzzPGSVsAZtQThU62SmQ4ZymlXRC5yFSCg= +k8s.io/apimachinery v0.30.2/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/cli-runtime v0.30.2 h1:ooM40eEJusbgHNEqnHziN9ZpLN5U4WcQGsdLKVxpkKE= +k8s.io/cli-runtime v0.30.2/go.mod h1:Y4g/2XezFyTATQUbvV5WaChoUGhojv/jZAtdp5Zkm0A= +k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50= +k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20240709000822-3c01b740850f h1:2sXuKesAYbRHxL3aE2PN6zX/gcJr22cjrsej+W784Tc= +k8s.io/kube-openapi v0.0.0-20240709000822-3c01b740850f/go.mod h1:UxDHUPsUwTOOxSU+oXURfFBcAS6JwiRXTYqYwfuGowc= +k8s.io/metrics v0.30.2 h1:zj4kIPTCfEbY0RHEogpA7QtlItU7xaO11+Gz1zVDxlc= +k8s.io/metrics v0.30.2/go.mod h1:GpoO5XTy/g8CclVLtgA5WTrr2Cy5vCsqr5Xa/0ETWIk= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= lukechampine.com/uint128 v1.3.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= @@ -781,10 +797,11 @@ modernc.org/tcl v1.15.1/go.mod h1:aEjeGJX2gz1oWKOLDVZ2tnEWLUrIn8H+GFu+akoDhqs= modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.7.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= -sigs.k8s.io/controller-runtime v0.18.2 h1:RqVW6Kpeaji67CY5nPEfRz6ZfFMk0lWQlNrLqlNpx+Q= -sigs.k8s.io/controller-runtime v0.18.2/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw= +sigs.k8s.io/controller-runtime v0.18.4 h1:87+guW1zhvuPLh1PHybKdYFLU0YJp4FhJRmiHvm5BZw= +sigs.k8s.io/controller-runtime v0.18.4/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 h1:XX3Ajgzov2RKUdc5jW3t5jwY7Bo7dcRm+tFxT+NfgY0= diff --git a/hack/benchmark/assets/x1b/loader.go b/hack/benchmark/assets/x1b/loader.go index 54a51f3f81..ecb126bd9e 100644 --- a/hack/benchmark/assets/x1b/loader.go +++ b/hack/benchmark/assets/x1b/loader.go @@ -32,7 +32,7 @@ var ( ) type BillionScaleVectors interface { - Load(i int) (interface{}, error) + Load(i int) (any, error) Dimension() int Size() int Close() error @@ -133,7 +133,7 @@ func (bv *bvecs) LoadUint8(i int) ([]uint8, error) { return ((*[1 << 26]uint8)(unsafe.Pointer(&buf[0])))[:bv.dim:bv.dim], nil } -func (bv *bvecs) Load(i int) (interface{}, error) { +func (bv *bvecs) Load(i int) (any, error) { return bv.LoadUint8(i) } @@ -146,7 +146,7 @@ func (fv *fvecs) LoadFloat32(i int) ([]float32, error) { return ((*[1 << 26]float32)(unsafe.Pointer(&buf[0])))[:fv.dim:fv.dim], nil } -func (fv *fvecs) Load(i int) (interface{}, error) { +func (fv *fvecs) Load(i int) (any, error) { return fv.LoadFloat32(i) } @@ -159,7 +159,7 @@ func (iv *ivecs) LoadInt32(i int) ([]int32, error) { return ((*[1 << 26]int32)(unsafe.Pointer(&buf[0])))[:iv.dim:iv.dim], nil } -func (iv *ivecs) Load(i int) (interface{}, error) { +func (iv *ivecs) Load(i int) (any, error) { return iv.LoadInt32(i) } diff --git a/hack/benchmark/assets/x1b/loader_bench_test.go b/hack/benchmark/assets/x1b/loader_bench_test.go index b570cd29f6..486e6d4054 100644 --- a/hack/benchmark/assets/x1b/loader_bench_test.go +++ b/hack/benchmark/assets/x1b/loader_bench_test.go @@ -13,9 +13,7 @@ // limitations under the License. package x1b -import ( - "testing" -) +import "testing" const ( bvecsFile = "../large/sift1b/bigann_base.bvecs" diff --git a/hack/benchmark/assets/x1b/loader_test.go b/hack/benchmark/assets/x1b/loader_test.go index a9c184cb1d..6b0f0a9d12 100644 --- a/hack/benchmark/assets/x1b/loader_test.go +++ b/hack/benchmark/assets/x1b/loader_test.go @@ -103,7 +103,6 @@ package x1b // if err := checkFunc(test.want, gotF, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -204,7 +203,6 @@ package x1b // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -319,7 +317,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -420,7 +417,6 @@ package x1b // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -521,7 +517,6 @@ package x1b // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -624,7 +619,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -637,7 +631,7 @@ package x1b // file *file // } // type want struct { -// want interface{} +// want any // err error // } // type test struct { @@ -645,11 +639,11 @@ package x1b // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got interface{}, err error) error { +// defaultCheckFunc := func(w want, got any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -727,7 +721,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -830,7 +823,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -843,7 +835,7 @@ package x1b // file *file // } // type want struct { -// want interface{} +// want any // err error // } // type test struct { @@ -851,11 +843,11 @@ package x1b // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got interface{}, err error) error { +// defaultCheckFunc := func(w want, got any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -933,7 +925,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1036,7 +1027,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1049,7 +1039,7 @@ package x1b // file *file // } // type want struct { -// want interface{} +// want any // err error // } // type test struct { @@ -1057,11 +1047,11 @@ package x1b // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got interface{}, err error) error { +// defaultCheckFunc := func(w want, got any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -1139,7 +1129,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1229,7 +1218,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1319,7 +1307,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1409,7 +1396,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1499,7 +1485,6 @@ package x1b // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/benchmark_test.go b/hack/benchmark/core/benchmark/benchmark_test.go index 07dbcd16fb..f5a7d43def 100644 --- a/hack/benchmark/core/benchmark/benchmark_test.go +++ b/hack/benchmark/core/benchmark/benchmark_test.go @@ -103,7 +103,6 @@ package benchmark // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -118,8 +117,7 @@ package benchmark // dataset assets.Dataset // strategies []Strategy // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/hack/benchmark/core/benchmark/option_test.go b/hack/benchmark/core/benchmark/option_test.go index cd7cb433d9..0d4f153cc5 100644 --- a/hack/benchmark/core/benchmark/option_test.go +++ b/hack/benchmark/core/benchmark/option_test.go @@ -100,7 +100,6 @@ package benchmark // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package benchmark // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/strategy/bulk_insert.go b/hack/benchmark/core/benchmark/strategy/bulk_insert.go index de5d820398..2c833bc923 100644 --- a/hack/benchmark/core/benchmark/strategy/bulk_insert.go +++ b/hack/benchmark/core/benchmark/strategy/bulk_insert.go @@ -34,7 +34,7 @@ func NewBulkInsert(opts ...StrategyOption) benchmark.Strategy { return newStrategy(append([]StrategyOption{ WithPropName("BulkInsert"), WithProp32( - func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { size := func() int { if maxBulkSize < dataset.TrainSize() { return maxBulkSize @@ -60,7 +60,7 @@ func NewBulkInsert(opts ...StrategyOption) benchmark.Strategy { }, ), WithProp64( - func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { size := func() int { if maxBulkSize < dataset.TrainSize() { return maxBulkSize diff --git a/hack/benchmark/core/benchmark/strategy/bulk_insert_commit.go b/hack/benchmark/core/benchmark/strategy/bulk_insert_commit.go index ba587dafc1..34e3bd0abd 100644 --- a/hack/benchmark/core/benchmark/strategy/bulk_insert_commit.go +++ b/hack/benchmark/core/benchmark/strategy/bulk_insert_commit.go @@ -30,7 +30,7 @@ func NewBulkInsertCommit(poolSize uint32, opts ...StrategyOption) benchmark.Stra return newStrategy(append([]StrategyOption{ WithPropName("BulkInsertCommit"), WithProp32( - func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { size := func() int { if maxBulkSize < dataset.TrainSize() { return maxBulkSize @@ -56,7 +56,7 @@ func NewBulkInsertCommit(poolSize uint32, opts ...StrategyOption) benchmark.Stra }, ), WithProp64( - func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { size := func() int { if maxBulkSize < dataset.TrainSize() { return maxBulkSize diff --git a/hack/benchmark/core/benchmark/strategy/bulk_insert_commit_test.go b/hack/benchmark/core/benchmark/strategy/bulk_insert_commit_test.go index d3d2a89365..1eba85c54c 100644 --- a/hack/benchmark/core/benchmark/strategy/bulk_insert_commit_test.go +++ b/hack/benchmark/core/benchmark/strategy/bulk_insert_commit_test.go @@ -103,7 +103,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/strategy/bulk_insert_test.go b/hack/benchmark/core/benchmark/strategy/bulk_insert_test.go index f16091c1ce..17aa992f58 100644 --- a/hack/benchmark/core/benchmark/strategy/bulk_insert_test.go +++ b/hack/benchmark/core/benchmark/strategy/bulk_insert_test.go @@ -100,7 +100,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/strategy/get_vector.go b/hack/benchmark/core/benchmark/strategy/get_vector.go index a37f2c592f..b251a26e61 100644 --- a/hack/benchmark/core/benchmark/strategy/get_vector.go +++ b/hack/benchmark/core/benchmark/strategy/get_vector.go @@ -36,7 +36,7 @@ func NewGetVector(opts ...StrategyOption) benchmark.Strategy { }, ), WithProp32( - func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { return c.GetVector(ids[int(atomic.LoadUint64(cnt))%len(ids)]) }, ), @@ -46,7 +46,7 @@ func NewGetVector(opts ...StrategyOption) benchmark.Strategy { }, ), WithProp64( - func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { return c.GetVector(ids[int(atomic.LoadUint64(cnt))%len(ids)]) }, ), diff --git a/hack/benchmark/core/benchmark/strategy/get_vector_test.go b/hack/benchmark/core/benchmark/strategy/get_vector_test.go index d4ddbea51e..88c822b781 100644 --- a/hack/benchmark/core/benchmark/strategy/get_vector_test.go +++ b/hack/benchmark/core/benchmark/strategy/get_vector_test.go @@ -100,7 +100,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/strategy/insert.go b/hack/benchmark/core/benchmark/strategy/insert.go index 85cadc1f4b..476f90e07b 100644 --- a/hack/benchmark/core/benchmark/strategy/insert.go +++ b/hack/benchmark/core/benchmark/strategy/insert.go @@ -31,7 +31,7 @@ func NewInsert(opts ...StrategyOption) benchmark.Strategy { return newStrategy(append([]StrategyOption{ WithPropName("Insert"), WithProp32( - func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { v, err := dataset.Train(int(atomic.LoadUint64(cnt)) % dataset.TrainSize()) if err != nil { return nil, err @@ -42,7 +42,7 @@ func NewInsert(opts ...StrategyOption) benchmark.Strategy { }, ), WithProp64( - func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { v, err := dataset.Train(int(atomic.LoadUint64(cnt)) % dataset.TrainSize()) if err != nil { return nil, err diff --git a/hack/benchmark/core/benchmark/strategy/insert_commit.go b/hack/benchmark/core/benchmark/strategy/insert_commit.go index 3314bfb096..dc0897fd4e 100644 --- a/hack/benchmark/core/benchmark/strategy/insert_commit.go +++ b/hack/benchmark/core/benchmark/strategy/insert_commit.go @@ -31,7 +31,7 @@ func NewInsertCommit(poolSize uint32, opts ...StrategyOption) benchmark.Strategy return newStrategy(append([]StrategyOption{ WithPropName("InsertCommit"), WithProp32( - func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { v, err := dataset.Train(int(atomic.LoadUint64(cnt)) % dataset.TrainSize()) if err != nil { return nil, err @@ -42,7 +42,7 @@ func NewInsertCommit(poolSize uint32, opts ...StrategyOption) benchmark.Strategy }, ), WithProp64( - func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { v, err := dataset.Train(int(atomic.LoadUint64(cnt)) % dataset.TrainSize()) if err != nil { return nil, err diff --git a/hack/benchmark/core/benchmark/strategy/insert_commit_test.go b/hack/benchmark/core/benchmark/strategy/insert_commit_test.go index 0fb9b41013..ea7c8f9357 100644 --- a/hack/benchmark/core/benchmark/strategy/insert_commit_test.go +++ b/hack/benchmark/core/benchmark/strategy/insert_commit_test.go @@ -103,7 +103,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/strategy/insert_test.go b/hack/benchmark/core/benchmark/strategy/insert_test.go index 3634a6ce69..44bb5924bb 100644 --- a/hack/benchmark/core/benchmark/strategy/insert_test.go +++ b/hack/benchmark/core/benchmark/strategy/insert_test.go @@ -100,7 +100,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/strategy/remove.go b/hack/benchmark/core/benchmark/strategy/remove.go index effa4577a0..e0a4776744 100644 --- a/hack/benchmark/core/benchmark/strategy/remove.go +++ b/hack/benchmark/core/benchmark/strategy/remove.go @@ -36,7 +36,7 @@ func NewRemove(opts ...StrategyOption) benchmark.Strategy { }, ), WithProp32( - func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (obj interface{}, err error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (obj any, err error) { err = c.Remove(ids[int(atomic.LoadUint64(cnt))%len(ids)]) return }, @@ -47,7 +47,7 @@ func NewRemove(opts ...StrategyOption) benchmark.Strategy { }, ), WithProp64( - func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (obj interface{}, err error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (obj any, err error) { err = c.Remove(ids[int(atomic.LoadUint64(cnt))%len(ids)]) return }, diff --git a/hack/benchmark/core/benchmark/strategy/remove_test.go b/hack/benchmark/core/benchmark/strategy/remove_test.go index e5b35ced91..c56fed5871 100644 --- a/hack/benchmark/core/benchmark/strategy/remove_test.go +++ b/hack/benchmark/core/benchmark/strategy/remove_test.go @@ -100,7 +100,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/strategy/search.go b/hack/benchmark/core/benchmark/strategy/search.go index fd6c090ffb..ecf3bda13a 100644 --- a/hack/benchmark/core/benchmark/strategy/search.go +++ b/hack/benchmark/core/benchmark/strategy/search.go @@ -36,7 +36,7 @@ func NewSearch(size int, epsilon, radius float32, opts ...StrategyOption) benchm }, ), WithProp32( - func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit32, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { v, err := dataset.Query(int(atomic.LoadUint64(cnt)) % dataset.TrainSize()) if err != nil { return nil, err @@ -52,7 +52,7 @@ func NewSearch(size int, epsilon, radius float32, opts ...StrategyOption) benchm }, ), WithProp64( - func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (interface{}, error) { + func(ctx context.Context, b *testing.B, c algorithm.Bit64, dataset assets.Dataset, ids []uint, cnt *uint64) (any, error) { v, err := dataset.Train(int(atomic.LoadUint64(cnt)) % dataset.TrainSize()) if err != nil { return nil, err diff --git a/hack/benchmark/core/benchmark/strategy/search_test.go b/hack/benchmark/core/benchmark/strategy/search_test.go index 4d3aaa1a90..e1edc1a5d5 100644 --- a/hack/benchmark/core/benchmark/strategy/search_test.go +++ b/hack/benchmark/core/benchmark/strategy/search_test.go @@ -109,7 +109,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/strategy/strategy.go b/hack/benchmark/core/benchmark/strategy/strategy.go index 82c2e030c4..49b007b5f8 100644 --- a/hack/benchmark/core/benchmark/strategy/strategy.go +++ b/hack/benchmark/core/benchmark/strategy/strategy.go @@ -38,8 +38,8 @@ type strategy struct { preProp32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset) ([]uint, error) preProp64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset) ([]uint, error) mode algorithm.Mode - prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (interface{}, error) - prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (interface{}, error) + prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (any, error) + prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (any, error) parallel bool } @@ -78,7 +78,9 @@ func (s *strategy) Init(ctx context.Context, b *testing.B, dataset assets.Datase return nil } -func (s *strategy) PreProp(ctx context.Context, b *testing.B, dataset assets.Dataset) ([]uint, error) { +func (s *strategy) PreProp( + ctx context.Context, b *testing.B, dataset assets.Dataset, +) ([]uint, error) { b.Helper() switch s.mode { @@ -120,7 +122,9 @@ func (s *strategy) Close() { s.closer.Close() } -func (s *strategy) float32(ctx context.Context, b *testing.B, dataset assets.Dataset, ids []uint, cnt *uint64) { +func (s *strategy) float32( + ctx context.Context, b *testing.B, dataset assets.Dataset, ids []uint, cnt *uint64, +) { b.Helper() b.StopTimer() @@ -151,7 +155,9 @@ func (s *strategy) float32(ctx context.Context, b *testing.B, dataset assets.Dat b.StopTimer() } -func (s *strategy) float64(ctx context.Context, b *testing.B, dataset assets.Dataset, ids []uint, cnt *uint64) { +func (s *strategy) float64( + ctx context.Context, b *testing.B, dataset assets.Dataset, ids []uint, cnt *uint64, +) { b.Helper() b.StopTimer() diff --git a/hack/benchmark/core/benchmark/strategy/strategy_option.go b/hack/benchmark/core/benchmark/strategy/strategy_option.go index af1a1f3735..32235037ce 100644 --- a/hack/benchmark/core/benchmark/strategy/strategy_option.go +++ b/hack/benchmark/core/benchmark/strategy/strategy_option.go @@ -48,7 +48,7 @@ func WithPreProp32( } func WithProp32( - fn func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (interface{}, error), + fn func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (any, error), ) StrategyOption { return func(s *strategy) error { if fn != nil { @@ -70,7 +70,7 @@ func WithPreProp64( } func WithProp64( - fn func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (interface{}, error), + fn func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (any, error), ) StrategyOption { return func(s *strategy) error { if fn != nil { diff --git a/hack/benchmark/core/benchmark/strategy/strategy_option_test.go b/hack/benchmark/core/benchmark/strategy/strategy_option_test.go index 30105ee777..1fe64495e6 100644 --- a/hack/benchmark/core/benchmark/strategy/strategy_option_test.go +++ b/hack/benchmark/core/benchmark/strategy/strategy_option_test.go @@ -100,14 +100,13 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func TestWithProp32(t *testing.T) { // type args struct { -// fn func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (interface{}, error) +// fn func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (any, error) // } // type want struct { // want StrategyOption @@ -186,7 +185,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,14 +270,13 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func TestWithProp64(t *testing.T) { // type args struct { -// fn func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (interface{}, error) +// fn func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (any, error) // } // type want struct { // want StrategyOption @@ -358,7 +355,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -692,7 +685,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/benchmark/strategy/strategy_test.go b/hack/benchmark/core/benchmark/strategy/strategy_test.go index 6163981226..6635f4bf04 100644 --- a/hack/benchmark/core/benchmark/strategy/strategy_test.go +++ b/hack/benchmark/core/benchmark/strategy/strategy_test.go @@ -100,7 +100,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -121,8 +120,8 @@ package strategy // preProp32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset) ([]uint, error) // preProp64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset) ([]uint, error) // mode algorithm.Mode -// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (interface{}, error) -// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (interface{}, error) +// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (any, error) +// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (any, error) // parallel bool // } // type want struct { @@ -249,7 +248,6 @@ package strategy // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -270,8 +268,8 @@ package strategy // preProp32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset) ([]uint, error) // preProp64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset) ([]uint, error) // mode algorithm.Mode -// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (interface{}, error) -// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (interface{}, error) +// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (any, error) +// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (any, error) // parallel bool // } // type want struct { @@ -402,7 +400,6 @@ package strategy // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -424,12 +421,11 @@ package strategy // preProp32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset) ([]uint, error) // preProp64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset) ([]uint, error) // mode algorithm.Mode -// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (interface{}, error) -// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (interface{}, error) +// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (any, error) +// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (any, error) // parallel bool // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -565,12 +561,11 @@ package strategy // preProp32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset) ([]uint, error) // preProp64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset) ([]uint, error) // mode algorithm.Mode -// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (interface{}, error) -// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (interface{}, error) +// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (any, error) +// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (any, error) // parallel bool // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields @@ -700,12 +695,11 @@ package strategy // preProp32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset) ([]uint, error) // preProp64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset) ([]uint, error) // mode algorithm.Mode -// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (interface{}, error) -// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (interface{}, error) +// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (any, error) +// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (any, error) // parallel bool // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -850,12 +844,11 @@ package strategy // preProp32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset) ([]uint, error) // preProp64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset) ([]uint, error) // mode algorithm.Mode -// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (interface{}, error) -// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (interface{}, error) +// prop32 func(context.Context, *testing.B, algorithm.Bit32, assets.Dataset, []uint, *uint64) (any, error) +// prop64 func(context.Context, *testing.B, algorithm.Bit64, assets.Dataset, []uint, *uint64) (any, error) // parallel bool // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/hack/benchmark/core/benchmark/strategy/util.go b/hack/benchmark/core/benchmark/strategy/util.go index c8eeec982f..d3cbd71a12 100644 --- a/hack/benchmark/core/benchmark/strategy/util.go +++ b/hack/benchmark/core/benchmark/strategy/util.go @@ -42,7 +42,9 @@ func wrapErrors(errs []error) (wrapped error) { return } -func insertAndCreateIndex32(ctx context.Context, c algorithm.Bit32, dataset assets.Dataset) (ids []uint, err error) { +func insertAndCreateIndex32( + ctx context.Context, c algorithm.Bit32, dataset assets.Dataset, +) (ids []uint, err error) { ids = make([]uint, 0, dataset.TrainSize()*bulkInsertCnt) n := 0 @@ -72,7 +74,9 @@ func insertAndCreateIndex32(ctx context.Context, c algorithm.Bit32, dataset asse return } -func insertAndCreateIndex64(ctx context.Context, c algorithm.Bit64, dataset assets.Dataset) (ids []uint, err error) { +func insertAndCreateIndex64( + ctx context.Context, c algorithm.Bit64, dataset assets.Dataset, +) (ids []uint, err error) { ids = make([]uint, 0, dataset.TrainSize()*bulkInsertCnt) n := 0 diff --git a/hack/benchmark/core/benchmark/strategy/util_test.go b/hack/benchmark/core/benchmark/strategy/util_test.go index 7391fe61a6..16776a6606 100644 --- a/hack/benchmark/core/benchmark/strategy/util_test.go +++ b/hack/benchmark/core/benchmark/strategy/util_test.go @@ -100,7 +100,6 @@ package strategy // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -196,7 +195,6 @@ package strategy // if err := checkFunc(test.want, gotIds, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -292,7 +290,6 @@ package strategy // if err := checkFunc(test.want, gotIds, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -378,7 +375,6 @@ package strategy // if err := checkFunc(test.want, gotY); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/core/ngt/ngt_bench_test.go b/hack/benchmark/core/ngt/ngt_bench_test.go index 8f3712fa39..e431b89eba 100644 --- a/hack/benchmark/core/ngt/ngt_bench_test.go +++ b/hack/benchmark/core/ngt/ngt_bench_test.go @@ -50,7 +50,9 @@ func init() { targets = strings.Split(strings.TrimSpace(dataset), ",") } -func initCore(ctx context.Context, b *testing.B, dataset assets.Dataset) (algorithm.Bit32, algorithm.Closer, error) { +func initCore( + ctx context.Context, b *testing.B, dataset assets.Dataset, +) (algorithm.Bit32, algorithm.Closer, error) { ngt, err := ngt.New( ngt.WithDimension(dataset.Dimension()), ngt.WithObjectType(dataset.ObjectType()), diff --git a/hack/benchmark/internal/assets/dataset_test.go b/hack/benchmark/internal/assets/dataset_test.go index 49daf75799..3706aaf442 100644 --- a/hack/benchmark/internal/assets/dataset_test.go +++ b/hack/benchmark/internal/assets/dataset_test.go @@ -96,7 +96,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/internal/core/algorithm/algorithm.go b/hack/benchmark/internal/core/algorithm/algorithm.go index 1100c35e17..b8e5e4412e 100644 --- a/hack/benchmark/internal/core/algorithm/algorithm.go +++ b/hack/benchmark/internal/core/algorithm/algorithm.go @@ -31,7 +31,7 @@ type Closer interface { } type Bit32 interface { - Search(ctx context.Context, vec []float32, size int, epsilon, radius float32) (interface{}, error) + Search(ctx context.Context, vec []float32, size int, epsilon, radius float32) (any, error) Insert(vec []float32) (uint, error) InsertCommit(vec []float32, poolSize uint32) (uint, error) BulkInsert(vecs [][]float32) ([]uint, []error) @@ -46,7 +46,7 @@ type Bit32 interface { } type Bit64 interface { - Search(ctx context.Context, vec []float64, size int, epsilon, radius float32) (interface{}, error) + Search(ctx context.Context, vec []float64, size int, epsilon, radius float32) (any, error) Insert(vec []float64) (uint, error) InsertCommit(vec []float64, poolSize uint32) (uint, error) BulkInsert(vecs [][]float64) ([]uint, []error) diff --git a/hack/benchmark/internal/core/algorithm/ngt/ngt.go b/hack/benchmark/internal/core/algorithm/ngt/ngt.go index a90d4a7778..f61af649f8 100644 --- a/hack/benchmark/internal/core/algorithm/ngt/ngt.go +++ b/hack/benchmark/internal/core/algorithm/ngt/ngt.go @@ -75,7 +75,9 @@ func New(opts ...Option) (c.Bit32, error) { return c, nil } -func (c *core) Search(ctx context.Context, vec []float32, size int, epsilon, radius float32) (interface{}, error) { +func (c *core) Search( + ctx context.Context, vec []float32, size int, epsilon, radius float32, +) (any, error) { return c.NGT.Search(ctx, vec, size, epsilon, radius) } diff --git a/hack/benchmark/internal/core/algorithm/ngt/ngt_test.go b/hack/benchmark/internal/core/algorithm/ngt/ngt_test.go index b46356f052..227af21b9c 100644 --- a/hack/benchmark/internal/core/algorithm/ngt/ngt_test.go +++ b/hack/benchmark/internal/core/algorithm/ngt/ngt_test.go @@ -104,7 +104,6 @@ package ngt // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -125,7 +124,7 @@ package ngt // NGT ngt.NGT // } // type want struct { -// want interface{} +// want any // err error // } // type test struct { @@ -133,11 +132,11 @@ package ngt // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got interface{}, err error) error { +// defaultCheckFunc := func(w want, got any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -235,7 +234,6 @@ package ngt // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -248,8 +246,7 @@ package ngt // dimension int // NGT ngt.NGT // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields diff --git a/hack/benchmark/internal/core/algorithm/ngt/option_test.go b/hack/benchmark/internal/core/algorithm/ngt/option_test.go index 09f40ca5b5..e6a2cb5a9d 100644 --- a/hack/benchmark/internal/core/algorithm/ngt/option_test.go +++ b/hack/benchmark/internal/core/algorithm/ngt/option_test.go @@ -100,7 +100,6 @@ package ngt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package ngt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package ngt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/internal/db/nosql/cassandra/cassandra_test.go b/hack/benchmark/internal/db/nosql/cassandra/cassandra_test.go index 5255c610f3..9f3eb41bc9 100644 --- a/hack/benchmark/internal/db/nosql/cassandra/cassandra_test.go +++ b/hack/benchmark/internal/db/nosql/cassandra/cassandra_test.go @@ -155,7 +155,7 @@ func initTable(b *testing.B, metas []MetaVector) { ib := cassandra.Insert(metaTable).Columns(metaColumnSlice...) bt := cassandra.Batch() - entities := make(map[string]interface{}, len(metas)*4) + entities := make(map[string]any, len(metas)*4) for i, m := range metas { prefix := "p" + strconv.Itoa(i) bt = bt.AddWithPrefix(prefix, ib) @@ -175,9 +175,9 @@ func BenchmarkGocqlxSelectBindMap(b *testing.B) { metas := loadData() initTable(b, metas) - keys := make([]map[string]interface{}, 0, len(metas)) + keys := make([]map[string]any, 0, len(metas)) for _, m := range metas { - keys = append(keys, map[string]interface{}{ + keys = append(keys, map[string]any{ uuidColumn: m.UUID, }) } diff --git a/hack/benchmark/internal/operation/insert_test.go b/hack/benchmark/internal/operation/insert_test.go index 1e484e1c07..5b507b3fe3 100644 --- a/hack/benchmark/internal/operation/insert_test.go +++ b/hack/benchmark/internal/operation/insert_test.go @@ -119,7 +119,6 @@ package operation // if err := checkFunc(test.want, gotInsertedNum); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -228,7 +227,6 @@ package operation // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/internal/operation/operation_test.go b/hack/benchmark/internal/operation/operation_test.go index 8f19645d0d..2e1dbfc347 100644 --- a/hack/benchmark/internal/operation/operation_test.go +++ b/hack/benchmark/internal/operation/operation_test.go @@ -96,7 +96,6 @@ package operation // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -110,8 +109,7 @@ package operation // client client.Client // indexerC client.Indexer // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/hack/benchmark/internal/operation/option_test.go b/hack/benchmark/internal/operation/option_test.go index e6adfa333e..7b40c8515d 100644 --- a/hack/benchmark/internal/operation/option_test.go +++ b/hack/benchmark/internal/operation/option_test.go @@ -96,7 +96,6 @@ package operation // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package operation // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/benchmark/internal/operation/remove_test.go b/hack/benchmark/internal/operation/remove_test.go index d58c53e470..67d48d5bad 100644 --- a/hack/benchmark/internal/operation/remove_test.go +++ b/hack/benchmark/internal/operation/remove_test.go @@ -25,8 +25,7 @@ package operation // client client.Client // indexerC client.Indexer // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -129,8 +128,7 @@ package operation // client client.Client // indexerC client.Indexer // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/hack/benchmark/internal/operation/search_test.go b/hack/benchmark/internal/operation/search_test.go index 99536ef13d..dffcc532e6 100644 --- a/hack/benchmark/internal/operation/search_test.go +++ b/hack/benchmark/internal/operation/search_test.go @@ -25,8 +25,7 @@ package operation // client client.Client // indexerC client.Indexer // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -129,8 +128,7 @@ package operation // client client.Client // indexerC client.Indexer // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -233,8 +231,7 @@ package operation // client client.Client // indexerC client.Indexer // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -337,8 +334,7 @@ package operation // client client.Client // indexerC client.Indexer // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/hack/benchmark/internal/operation/util.go b/hack/benchmark/internal/operation/util.go index f924e5a814..a35c14454f 100644 --- a/hack/benchmark/internal/operation/util.go +++ b/hack/benchmark/internal/operation/util.go @@ -38,7 +38,7 @@ func grpcError(tb testing.TB, err error) { ) } -func statusError(tb testing.TB, code int32, message string, details ...interface{}) { +func statusError(tb testing.TB, code int32, message string, details ...any) { tb.Helper() tb.Errorf("code: %d\tmessage: %s\tdetails: %s", code, diff --git a/hack/benchmark/internal/operation/util_test.go b/hack/benchmark/internal/operation/util_test.go index e948032010..31b3bb5473 100644 --- a/hack/benchmark/internal/operation/util_test.go +++ b/hack/benchmark/internal/operation/util_test.go @@ -20,8 +20,7 @@ package operation // tb testing.TB // err error // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -104,10 +103,9 @@ package operation // tb testing.TB // code int32 // message string -// details []interface{} -// } -// type want struct { +// details []any // } +// type want struct{} // type test struct { // name string // args args diff --git a/hack/benchmark/src/singleflight/singleflight_bench_test.go b/hack/benchmark/src/singleflight/singleflight_bench_test.go index 9a3f4029d3..a767e1672c 100644 --- a/hack/benchmark/src/singleflight/singleflight_bench_test.go +++ b/hack/benchmark/src/singleflight/singleflight_bench_test.go @@ -118,7 +118,7 @@ func Benchmark_group_Do_with_sync_singleflight(b *testing.B) { initDoFn: func() func(ctx context.Context, key string, fn func(context.Context) (string, error)) { g := new(stdsingleflight.Group) return func(ctx context.Context, key string, fn func(context.Context) (string, error)) { - g.Do(key, func() (interface{}, error) { return fn(context.Background()) }) + g.Do(key, func() (any, error) { return fn(context.Background()) }) } }, sleepDur: dur, diff --git a/hack/docker/gen/main.go b/hack/docker/gen/main.go new file mode 100644 index 0000000000..34c9425864 --- /dev/null +++ b/hack/docker/gen/main.go @@ -0,0 +1,746 @@ +// +// 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 + +import ( + "bytes" + "context" + "io/fs" + "os" + "os/signal" + "regexp" + "slices" + "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" +) + +const tmpl = `# syntax = docker/dockerfile:latest +# +# Copyright (C) 2019-{{.Year}} {{.Maintainer}} +# +# 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. +# + +# DO_NOT_EDIT this Dockerfile is generated by hack/docker/gen/main.go + +ARG UPX_OPTIONS=-9 + +{{- range $key, $value := .Arguments }} +ARG {{$key}}={{$value}} +{{- end}} +{{- range $image := .ExtraImages }} +# skipcq: DOK-DL3026 +FROM {{$image}} +{{- end}} +# skipcq: DOK-DL3026 +FROM {{.BuilderImage}}:{{.BuilderTag}}{{- if not .DevContainer}} AS builder {{- end}} +ARG MAINTAINER="{{.Maintainer}}" +LABEL maintainer="${MAINTAINER}" + +ARG TARGETARCH +ARG TARGETOS +ARG GO_VERSION +ARG RUST_VERSION + +{{- range $keyValue := .EnvironmentsSlice }} +ENV {{$keyValue}} +{{- end}} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# skipcq: DOK-DL3008 +RUN apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends --fix-missing \ + build-essential \ + ca-certificates \ + curl \ + git \ +{{- range $epkg := .ExtraPackages }} + {{$epkg}} \ +{{- end}} + && ldconfig \ + && apt-get clean \ + && rm -rf \ + /var/lib/apt/lists/* \ + /var/cache/* \ + && apt-get autoremove + +WORKDIR {{.RootDir}}/${ORG}/${REPO} +COPY Makefile . +COPY .git . +{{- if not .DevContainer}} +{{- if eq .ContainerType 0 }} +COPY go.mod . +COPY go.sum . +{{- else if eq .ContainerType 3 }} +COPY go.mod . +COPY go.sum . +{{- end}} +{{- if .ConfigExists }} +COPY cmd/${PKG}/sample.yaml {{$.TmpConfigPath}} +{{- end}} + +{{- range $files := .CopyDirectories }} +WORKDIR {{$.RootDir}}/${ORG}/${REPO}/{{$files}} +COPY {{$files}} . +{{- end}} +{{- range $files := .ExtraCopies }} +COPY {{$files}} +{{- end}} + +{{- else}} +WORKDIR {{.RootDir}}/${ORG}/${REPO} +COPY . . +{{- end}} + +WORKDIR {{.RootDir}}/${ORG}/${REPO} +{{- if .RunCommands}} +#skipcq: DOK-W1001, DOK-SC2086 +RUN {{RunCommands .RunCommands}} +{{- end}} + +{{- if not .DevContainer}} +# skipcq: DOK-DL3026 +FROM {{.RuntimeImage}}:{{.RuntimeTag}} +ARG MAINTAINER="{{.Maintainer}}" +LABEL maintainer="${MAINTAINER}" + +ENV APP_NAME={{.AppName}} + +COPY --from=builder {{.BinDir}}/${APP_NAME} {{.BinDir}}/${APP_NAME} +{{- if .ConfigExists }} +COPY --from=builder {{$.TmpConfigPath}} /etc/server/config.yaml +{{- end}} +{{- range $from, $file := .StageFiles }} +COPY --from=builder {{$file}} {{$file}} +{{- end}} +USER nonroot:nonroot + +{{- if .Entrypoints}} +ENTRYPOINT [{{Entrypoint .Entrypoints}}] +{{- else}} +ENTRYPOINT ["{{.BinDir}}/{{.AppName}}"] +{{- end}} +{{- end}}` + +var docker = template.Must(template.New("Dockerfile").Funcs(template.FuncMap{ + "RunCommands": func(commands []string) string { + if len(commands) == 0 { + return "" + } + var b strings.Builder + for i, cmd := range commands { + if i > 0 { + b.WriteString(" \\\n && ") + } + b.WriteString(cmd) + } + return b.String() + }, + "Entrypoint": func(entries []string) string { + if len(entries) == 0 { + return "\"{{.BinDir}}/{{.AppName}}\"" + } + return "\"" + strings.Join(entries, "\", \"") + "\"" + }, +}).Parse(tmpl)) + +type Data struct { + ConfigExists bool + DevContainer bool + Year int + ContainerType ContainerType + AppName string + BinDir string + BuilderImage string + BuilderTag string + Maintainer string + PackageDir string + RootDir string + RuntimeImage string + RuntimeTag string + TmpConfigPath string + Arguments map[string]string + Environments map[string]string + Entrypoints []string + EnvironmentsSlice []string + CopyDirectories []string + ExtraCopies []string + ExtraImages []string + ExtraPackages []string + Preprocess []string + RunCommands []string + StageFiles []string +} + +type ContainerType int + +const ( + organization = "vdaas" + repository = "vald" + minimumArgumentLength = 2 + defaultMaintainer = organization + ".org " + repository + " team <" + repository + "@" + organization + ".org>" + maintainerKey = "MAINTAINER" + defaultRuntimeImage = "gcr.io/distroless/static" + defaultRuntimeTag = "nonroot" + defaultBuilderImage = "ghcr.io/vdaas/vald/vald-buildbase" + defaultBuilderTag = "nightly" + defaultBinaryDir = "/usr/bin" + defaultTmpConfigPath = "/tmp/config.yaml" + + goWorkdir = "${GOPATH}/src/github.com" + rustWorkdir = "${HOME}/rust/src/github.com" + + agentInernalPackage = "pkg/agent/internal" + + ngtPreprocess = "make ngt/install" + faissPreprocess = "make faiss/install" + + helmOperatorRootdir = "/opt/helm" + helmOperatorWatchFile = helmOperatorRootdir + "/watches.yaml" + helmOperatorChartsDir = helmOperatorRootdir + "/charts" +) + +const ( + Go ContainerType = iota + Rust + DevContainer + HelmOperator + Other +) + +var ( + defaultEnvironments = map[string]string{ + "DEBIAN_FRONTEND": "noninteractive", + "HOME": "/root", + "INITRD": "No", + "LANG": "en_US.UTF-8", + "ORG": organization, + "PATH": "${PATH}:/usr/local/bin", + "REPO": repository, + } + goDefaultEnvironments = map[string]string{ + "GOROOT": "/opt/go", + "GOPATH": "/go", + "GO111MODULE": "on", + "PATH": "${PATH}:${GOROOT}/bin:${GOPATH}/bin:/usr/local/bin", + } + rustDefaultEnvironments = map[string]string{ + "RUST_HOME": "/usr/loacl/lib/rust", + "RUSTUP_HOME": "${RUST_HOME}/rustup", + "CARGO_HOME": "${RUST_HOME}/cargo", + "PATH": "${PATH}:${RUSTUP_HOME}/bin:${CARGO_HOME}/bin:/usr/local/bin", + } + + defaultCopyDirectories = []string{ + "Makefile.d", + "versions", + } + goDefaultCopyDirectories = []string{ + "internal", + "apis/grpc", + "pkg/${PKG}", + "cmd/${PKG}", + } + rustDefaultCopyDirectories = []string{ + "rust", + } + + goInstallCommands = []string{ + `--mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \ + --mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \ + make GO_VERSION="${GO_VERSION}" go/install`, + "make go/download", + } + rustInstallCommands = []string{ + "make RUST_VERSION=\"${RUST_VERSION}\" rust/install", + } + goBuildCommands = []string{ + "make GOARCH=\"${TARGETARCH}\" GOOS=\"${TARGETOS}\" REPO=\"${ORG}\" NAME=\"${REPO}\" cmd/${PKG}/${APP_NAME}", + "mv \"cmd/${PKG}/${APP_NAME}\" \"{{$.BinDir}}/${APP_NAME}\"", + } + rustBuildCommands = []string{ + "make rust/target/release/${APP_NAME}", + "mv \"rust/target/release/${APP_NAME}\" \"{{$.BinDir}}/${APP_NAME}\"", + "rm -rf rust/target", + } + + clangBuildDeps = []string{ + "cmake", + "g++", + "gcc", + "unzip", + } + ngtBuildDeps = []string{ + "liblapack-dev", + "libomp-dev", + "libopenblas-dev", + } + faissBuildDeps = []string{ + "gfortran", + } + devContainerDeps = []string{ + "curl", + "gawk", + "git", + "gnupg2", + "graphviz", + "jq", + "libhdf5-dev", + "libaec-dev", + "nodejs", + "npm", + "sed", + "zip", + } + + ciContainerPreprocess = []string{ + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} deps GO_CLEAN_DEPS=false", + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} golangci-lint/install", + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} gotestfmt/install", + "make buf/install", + "make hdf5/install", + "make helm-docs/install", + "make helm/install", + "make k3d/install", + "make k9s/install", + "make kind/install", + "make kubectl/install", + "make kubelinter/install", + "make reviewdog/install", + "make tparse/install", + "make valdcli/install", + "make yq/install", + "make minikube/install", + "make stern/install", + "make telepresence/install", + } + + devContainerPreprocess = []string{ + "echo \"installing golang vscode extension dependencies\"", + "make delve/install", + "make gomodifytags/install", + "make gopls/install", + "make gotests/install", + "make impl/install", + "make staticcheck/install", + } +) + +func appendM[K comparable](maps ...map[K]string) map[K]string { + if len(maps) == 0 { + return nil + } + result := maps[0] + for _, m := range maps[1:] { + for k, v := range m { + ev, ok := result[k] + if ok { + v += ":" + ev + } + result[k] = v + } + } + + for k, v := range result { + vs := strings.Split(v, ":") + slices.Sort(vs) + v = strings.Join(slices.Compact(vs), ":") + if strings.Contains(v, "${PATH}:") { + v = strings.TrimPrefix(strings.ReplaceAll(strings.ReplaceAll(v, "${PATH}", ""), "::", ":")+":${PATH}", ":") + } + result[k] = v + } + return result +} + +var re = regexp.MustCompile(`\$\{?(\w+)\}?`) + +func extractVariables(value string) []string { + matches := re.FindAllStringSubmatch(value, -1) + vars := make([]string, 0, len(matches)) + for _, match := range matches { + vars = append(vars, match[1]) + } + return vars +} + +func topologicalSort(envMap map[string]string) []string { + // Graph structures + inDegree := make(map[string]int) + graph := make(map[string][]string) + + // Initialize the graph + for key, value := range envMap { + vars := extractVariables(value) + for _, refKey := range vars { + if refKey != key { + graph[refKey] = append(graph[refKey], key) + inDegree[key]++ + } + } + } + + queue := make([]string, 0, len(envMap)-len(graph)) + for key := range envMap { + if inDegree[key] == 0 { + queue = append(queue, key) + } + } + + slices.Sort(queue) + + // Topological sort + result := make([]string, 0, len(envMap)) + for len(queue) > 0 { + node := queue[0] + queue = queue[1:] + if value, exists := envMap[node]; exists { + result = append(result, node+"="+value) + } + for _, neighbor := range graph[node] { + inDegree[neighbor]-- + if inDegree[neighbor] == 0 { + queue = append(queue, neighbor) + } + } + } + + return result +} + +func main() { + log.Init() + if len(os.Args) < minimumArgumentLength { + // skipcq: RVV-A0003 + log.Fatal(errors.New("invalid argument")) + } + + ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, + syscall.SIGQUIT, + syscall.SIGHUP, + syscall.SIGALRM, + syscall.SIGKILL, + syscall.SIGTERM) + defer cancel() + + maintainer := os.Getenv(maintainerKey) + if len(maintainer) == 0 { + maintainer = defaultMaintainer + } + year := time.Now().Year() + eg, egctx := errgroup.New(ctx) + for n, d := range map[string]Data{ + "vald-agent-ngt": { + AppName: "ngt", + PackageDir: "agent/core/ngt", + CopyDirectories: []string{agentInernalPackage}, + ExtraPackages: append(clangBuildDeps, ngtBuildDeps...), + Preprocess: []string{ngtPreprocess}, + }, + "vald-agent-faiss": { + AppName: "faiss", + PackageDir: "agent/core/faiss", + CopyDirectories: []string{agentInernalPackage}, + ExtraPackages: append(clangBuildDeps, + append(ngtBuildDeps, + faissBuildDeps...)...), + Preprocess: []string{faissPreprocess}, + }, + "vald-agent": { + AppName: "agent", + PackageDir: "agent/core/agent", + ContainerType: Rust, + RuntimeImage: "gcr.io/distroless/cc-debian12", + ExtraPackages: append(clangBuildDeps, + append(ngtBuildDeps, + faissBuildDeps...)...), + Preprocess: []string{ + ngtPreprocess, + faissPreprocess, + }, + }, + "vald-agent-sidecar": { + AppName: "sidecar", + PackageDir: "agent/sidecar", + CopyDirectories: []string{agentInernalPackage}, + }, + "vald-discoverer-k8s": { + AppName: "discoverer", + PackageDir: "discoverer/k8s", + }, + "vald-gateway-lb": { + AppName: "lb", + PackageDir: "gateway/lb", + }, + "vald-gateway-filter": { + AppName: "filter", + PackageDir: "gateway/filter", + }, + "vald-gateway-mirror": { + AppName: "mirror", + PackageDir: "gateway/mirror", + }, + "vald-manager-index": { + AppName: "index", + PackageDir: "manager/index", + }, + "vald-index-correction": { + AppName: "index-correction", + PackageDir: "index/job/correction", + }, + "vald-index-creation": { + AppName: "index-creation", + PackageDir: "index/job/creation", + }, + "vald-index-save": { + AppName: "index-save", + PackageDir: "index/job/save", + }, + "vald-readreplica-rotate": { + AppName: "readreplica-rotate", + PackageDir: "index/job/readreplica/rotate", + }, + "vald-index-operator": { + AppName: "index-operator", + PackageDir: "index/operator", + }, + "vald-benchmark-job": { + AppName: "job", + PackageDir: "tools/benchmark/job", + ExtraPackages: append(clangBuildDeps, "libhdf5-dev", "libaec-dev"), + Preprocess: []string{ + "make hdf5/install", + }, + }, + "vald-benchmark-operator": { + AppName: "operator", + PackageDir: "tools/benchmark/operator", + }, + "vald-helm-operator": { + AppName: "helm-operator", + PackageDir: "operator/helm", + ContainerType: HelmOperator, + Arguments: map[string]string{ + "OPERATOR_SDK_VERSION": "latest", + }, + CopyDirectories: []string{ + "internal", + "charts", + "hack", + }, + ExtraCopies: []string{ + "--from=operator /usr/local/bin/${APP_NAME} {{$.BinDir}}/${APP_NAME}", + }, + ExtraImages: []string{ + "quay.io/operator-framework/helm-operator:${OPERATOR_SDK_VERSION} AS operator", + }, + ExtraPackages: []string{"upx"}, + Preprocess: []string{ + "mkdir -p " + helmOperatorChartsDir, + `{ \ + echo "---"; \ + echo "- version: v1"; \ + echo " group: vald.vdaas.org"; \ + echo " kind: ValdRelease"; \ + echo " chart: ` + helmOperatorChartsDir + `/vald"; \ + echo "- version: v1"; \ + echo " group: vald.vdaas.org"; \ + echo " kind: ValdHelmOperatorRelease"; \ + echo " chart: ` + helmOperatorChartsDir + `/vald-helm-operator"; \ + } > ` + helmOperatorWatchFile, + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} helm/schema/vald", + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} helm/schema/vald-helm-operator", + "cp -r charts/* " + helmOperatorChartsDir + "/", + "upx \"{{$.BinDir}}/${APP_NAME}\"", + }, + StageFiles: []string{ + helmOperatorWatchFile, + helmOperatorChartsDir + "/vald", + helmOperatorChartsDir + "/vald-helm-operator", + }, + Entrypoints: []string{"{{$.BinDir}}/{{.AppName}}", "run", "--watches-file=" + helmOperatorWatchFile}, + }, + "vald-cli-loadtest": { + AppName: "loadtest", + PackageDir: "tools/cli/loadtest", + ExtraPackages: append(clangBuildDeps, "libhdf5-dev", "libaec-dev"), + CopyDirectories: []string{ + "hack/benchmark/assets/x1b", + }, + Preprocess: []string{ + "make hdf5/install", + }, + }, + "vald-ci-container": { + AppName: "ci-container", + DevContainer: true, + ContainerType: DevContainer, + PackageDir: "ci/base", + ExtraPackages: append(clangBuildDeps, + append(ngtBuildDeps, + append(faissBuildDeps, + devContainerDeps...)...)...), + Preprocess: append([]string{ + "sysctl -w net.ipv6.conf.all.disable_ipv6=1", + "sysctl -w net.ipv6.conf.default.disable_ipv6=1", + "sysctl -w net.ipv6.conf.lo.disable_ipv6=1", + "sysctl -p", + }, append(ciContainerPreprocess, ngtPreprocess, faissPreprocess)...), + }, + "vald-dev-container": { + AppName: "dev-container", + BuilderImage: "mcr.microsoft.com/vscode/devcontainers/base", + BuilderTag: "debian", + DevContainer: true, + ContainerType: DevContainer, + PackageDir: "dev", + ExtraPackages: append(clangBuildDeps, + append(ngtBuildDeps, + append(faissBuildDeps, + devContainerDeps...)...)...), + Preprocess: append(ciContainerPreprocess, + append(devContainerPreprocess, + ngtPreprocess, + faissPreprocess)...), + }, + } { + name := n + data := d + + eg.Go(safety.RecoverFunc(func() error { + data.Maintainer = maintainer + data.Year = year + if data.BinDir == "" { + data.BinDir = defaultBinaryDir + } + if data.TmpConfigPath == "" { + data.TmpConfigPath = defaultTmpConfigPath + } + if data.RuntimeImage == "" { + data.RuntimeImage = defaultRuntimeImage + } + if data.RuntimeTag == "" { + data.RuntimeTag = defaultRuntimeTag + } + if data.BuilderImage == "" { + data.BuilderImage = defaultBuilderImage + } + if data.BuilderTag == "" { + data.BuilderTag = defaultBuilderTag + } + + if data.CopyDirectories != nil { + data.CopyDirectories = append(defaultCopyDirectories, data.CopyDirectories...) + } else { + data.CopyDirectories = make([]string, len(defaultCopyDirectories)) + copy(data.CopyDirectories, defaultCopyDirectories) + } + if data.Environments != nil { + data.Environments = appendM(data.Environments, defaultEnvironments) + } else { + data.Environments = make(map[string]string, len(defaultEnvironments)) + data.Environments = appendM(data.Environments, defaultEnvironments) + } + switch data.ContainerType { + case Go: + data.CopyDirectories = append(data.CopyDirectories, goDefaultCopyDirectories...) + data.Environments = appendM(data.Environments, goDefaultEnvironments) + data.RootDir = goWorkdir + commands := make([]string, 0, len(goInstallCommands)+len(data.Preprocess)+len(goBuildCommands)) + commands = append(commands, goInstallCommands...) + if data.Preprocess != nil { + commands = append(commands, data.Preprocess...) + } + if file.Exists(file.Join(os.Args[1], "cmd", data.PackageDir)) { + commands = append(commands, goBuildCommands...) + } + data.RunCommands = commands + case Rust: + data.CopyDirectories = append(data.CopyDirectories, rustDefaultCopyDirectories...) + data.Environments = appendM(data.Environments, rustDefaultEnvironments) + data.RootDir = rustWorkdir + commands := make([]string, 0, len(rustInstallCommands)+len(data.Preprocess)+len(rustBuildCommands)) + commands = append(commands, rustInstallCommands...) + if data.Preprocess != nil { + commands = append(commands, data.Preprocess...) + } + data.RunCommands = append(commands, rustBuildCommands...) + case DevContainer: + data.CopyDirectories = append(data.CopyDirectories, append(goDefaultCopyDirectories, rustDefaultCopyDirectories...)...) + data.Environments = appendM(data.Environments, goDefaultEnvironments, rustDefaultEnvironments) + data.RootDir = goWorkdir + commands := make([]string, 0, len(goInstallCommands)+len(rustInstallCommands)+len(data.Preprocess)) + commands = append(commands, append(goInstallCommands, rustInstallCommands...)...) + if data.Preprocess != nil { + commands = append(commands, data.Preprocess...) + } + commands = append(commands, "rm -rf {{.RootDir}}/${ORG}/${REPO}/*") + data.RunCommands = commands + case HelmOperator: + data.Environments = appendM(data.Environments, goDefaultEnvironments) + data.RootDir = goWorkdir + commands := make([]string, 0, len(goInstallCommands)+len(data.Preprocess)) + commands = append(commands, goInstallCommands...) + if data.Preprocess != nil { + commands = append(commands, data.Preprocess...) + } + data.RunCommands = commands + default: + data.RootDir = "${HOME}" + data.Environments["ROOTDIR"] = os.Args[1] + } + + data.Environments["APP_NAME"] = data.AppName + data.Environments["PKG"] = data.PackageDir + data.EnvironmentsSlice = topologicalSort(data.Environments) + data.ConfigExists = file.Exists(file.Join(os.Args[1], "cmd", data.PackageDir, "sample.yaml")) + + buf := bytes.NewBuffer(make([]byte, 0, len(tmpl))) + log.Infof("generating %s's docker file", name) + docker.Execute(buf, data) + tpl := buf.String() + buf.Reset() + template.Must(template.New("Dockerfile").Parse(tpl)).Execute(buf, data) + file.OverWriteFile(egctx, file.Join(os.Args[1], "dockers", data.PackageDir, "Dockerfile"), buf, fs.ModePerm) + return nil + })) + } + eg.Wait() +} diff --git a/hack/git/hooks/pre-commit b/hack/git/hooks/pre-commit index fce9fcff2a..0405069719 100644 --- a/hack/git/hooks/pre-commit +++ b/hack/git/hooks/pre-commit @@ -20,25 +20,9 @@ if git diff HEAD^ --name-only | grep ".go$" > /dev/null; then cp go.mod ${TMPDIR} cp go.sum ${TMPDIR} - # golines - echo "Run golines..." - find ./ -type d -name .git -prune -o -type f -regex '.*[^\.pb]\.go' -print | xargs golines -w -m 200 - echo "golines finished." - - # gofumpt - echo "Run gofumpt..." - find ./ -type d -name .git -prune -o -type f -regex '.*[^\.pb]\.go' -print | xargs gofumpt -w - echo "gofumpt finished." - - # goimports - echo "Run strictgoimports..." - find ./ -type d -name .git -prune -o -type f -regex '.*\.go' -print | xargs strictgoimports -w - echo "strictgoimports finished." - - # goimports - echo "Run goimports..." - find ./ -type d -name .git -prune -o -type f -regex '.*\.go' -print | xargs goimports -w - echo "goimports finished." + # format go code + make format/go + make format/go/test # go build echo "Run go build..." @@ -48,7 +32,7 @@ if git diff HEAD^ --name-only | grep ".go$" > /dev/null; then if [ `git rev-parse --abbrev-ref HEAD` = "main" ]; then # golangci-lint echo "Run golangci-lint..." - golangci-lint run --fast --disable=gochecknoglobals --fix --color always -j 16 --skip-dirs apis/grpc --exclude-use-default=false ./... + make go/lint echo "golangci-lint finished." fi mv -f ${TMPDIR}/go.mod . diff --git a/hack/go.mod.default b/hack/go.mod.default index a6b76d935c..c33a973129 100644 --- a/hack/go.mod.default +++ b/hack/go.mod.default @@ -1,6 +1,6 @@ module github.com/vdaas/vald -go 1.22.3 +go 1.22.5 replace ( cloud.google.com/go => cloud.google.com/go upgrade @@ -162,6 +162,7 @@ replace ( github.com/googleapis/gax-go/v2 => github.com/googleapis/gax-go/v2 upgrade github.com/gorilla/mux => github.com/gorilla/mux upgrade github.com/gorilla/websocket => github.com/gorilla/websocket upgrade + github.com/grafana/pyroscope-go/godeltaprof => github.com/grafana/pyroscope-go/godeltaprof upgrade github.com/gregjones/httpcache => github.com/gregjones/httpcache upgrade github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/grpc-ecosystem/grpc-gateway/v2 upgrade github.com/hailocab/go-hostpool => github.com/kpango/go-hostpool upgrade @@ -328,19 +329,19 @@ replace ( gopkg.in/yaml.v2 => gopkg.in/yaml.v2 upgrade gopkg.in/yaml.v3 => gopkg.in/yaml.v3 upgrade honnef.co/go/tools => honnef.co/go/tools upgrade - k8s.io/api => k8s.io/api v0.30.0 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.30.0 - k8s.io/apimachinery => k8s.io/apimachinery v0.30.0 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.30.0 - k8s.io/client-go => k8s.io/client-go v0.30.0 - k8s.io/component-base => k8s.io/component-base v0.30.0 + k8s.io/api => k8s.io/api v0.30.2 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.30.2 + k8s.io/apimachinery => k8s.io/apimachinery v0.30.2 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.30.2 + k8s.io/client-go => k8s.io/client-go v0.30.2 + k8s.io/component-base => k8s.io/component-base v0.30.2 k8s.io/klog/v2 => k8s.io/klog/v2 upgrade k8s.io/kube-openapi => k8s.io/kube-openapi master - k8s.io/kubernetes => k8s.io/kubernetes v0.30.0 - k8s.io/metrics => k8s.io/metrics v0.30.0 + k8s.io/kubernetes => k8s.io/kubernetes v0.30.2 + k8s.io/metrics => k8s.io/metrics v0.30.2 nhooyr.io/websocket => nhooyr.io/websocket upgrade rsc.io/pdf => rsc.io/pdf upgrade - sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.18.2 + sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.18.4 sigs.k8s.io/json => sigs.k8s.io/json upgrade sigs.k8s.io/kustomize => sigs.k8s.io/kustomize upgrade sigs.k8s.io/structured-merge-diff/v4 => sigs.k8s.io/structured-merge-diff/v4 upgrade diff --git a/hack/gorules/rules.go b/hack/gorules/rules.go index d077ad669b..d130fe4a06 100644 --- a/hack/gorules/rules.go +++ b/hack/gorules/rules.go @@ -13,9 +13,7 @@ // limitations under the License. package gorules -import ( - "github.com/quasilyte/go-ruleguard/dsl" -) +import "github.com/quasilyte/go-ruleguard/dsl" func CheckPayloadObjectAccess(m dsl.Matcher) { m.Import("github.com/vdaas/vald/apis/grpc/v1/payload") diff --git a/hack/helm/schema/crd/main_test.go b/hack/helm/schema/crd/main_test.go index 1dc2c352f0..91b28a9f8c 100644 --- a/hack/helm/schema/crd/main_test.go +++ b/hack/helm/schema/crd/main_test.go @@ -19,8 +19,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want @@ -173,7 +172,6 @@ package main // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -263,7 +261,6 @@ package main // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -353,7 +350,6 @@ package main // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -439,7 +435,6 @@ package main // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -528,7 +523,6 @@ package main // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/helm/schema/gen/main_test.go b/hack/helm/schema/gen/main_test.go index 5e53c4e484..6731c9a3b7 100644 --- a/hack/helm/schema/gen/main_test.go +++ b/hack/helm/schema/gen/main_test.go @@ -19,8 +19,7 @@ package main // NOT IMPLEMENTED BELOW // // func Test_main(t *testing.T) { -// type want struct { -// } +// type want struct{} // type test struct { // name string // want want @@ -170,7 +169,6 @@ package main // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -263,7 +261,6 @@ package main // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -356,7 +353,6 @@ package main // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -442,7 +438,6 @@ package main // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/hack/license/gen/main.go b/hack/license/gen/main.go index 68f28a86d0..a13db09c43 100644 --- a/hack/license/gen/main.go +++ b/hack/license/gen/main.go @@ -287,6 +287,10 @@ func readAndRewrite(path string) error { "semaphore_example_test.go", "semaphore_test.go": tmpl = goStandard + case "error_details.pb.go", + "error_details.pb.json.go", + "error_details_vtproto.pb.go": + tmpl = googleProtoApache default: } case ".proto": diff --git a/internal/backoff/backoff.go b/internal/backoff/backoff.go index 8e8b219a9f..04c1355739 100644 --- a/internal/backoff/backoff.go +++ b/internal/backoff/backoff.go @@ -55,7 +55,7 @@ type backoff struct { // Backoff represents an interface to handle backoff operation. type Backoff interface { - Do(context.Context, func(ctx context.Context) (interface{}, bool, error)) (interface{}, error) + Do(context.Context, func(ctx context.Context) (any, bool, error)) (any, error) Close() } @@ -77,7 +77,9 @@ func New(opts ...Option) Backoff { } // Do tries to backoff using the input function and returns the response and error. -func (b *backoff) Do(ctx context.Context, f func(ctx context.Context) (val interface{}, retryable bool, err error)) (res interface{}, err error) { +func (b *backoff) Do( + ctx context.Context, f func(ctx context.Context) (val any, retryable bool, err error), +) (res any, err error) { if f == nil { return } @@ -133,7 +135,7 @@ func (b *backoff) Do(ctx context.Context, f func(ctx context.Context) (val inter return nil, errors.Join(err, dctx.Err()) } default: - res, ret, err = func() (val interface{}, retryable bool, err error) { + res, ret, err = func() (val any, retryable bool, err error) { ssctx, span := trace.StartSpan(dctx, traceTag+"/"+strconv.Itoa(cnt+1)) defer func() { if span != nil { diff --git a/internal/backoff/backoff_test.go b/internal/backoff/backoff_test.go index b907b19725..0549983bbb 100644 --- a/internal/backoff/backoff_test.go +++ b/internal/backoff/backoff_test.go @@ -219,7 +219,7 @@ func Test_backoff_Do(t *testing.T) { t.Parallel() type args struct { ctx context.Context - f func(ctx context.Context) (val interface{}, retryable bool, err error) + f func(ctx context.Context) (val any, retryable bool, err error) } type fields struct { backoffFactor float64 @@ -233,7 +233,7 @@ func Test_backoff_Do(t *testing.T) { errLog bool } type want struct { - wantRes interface{} + wantRes any err error } type test struct { @@ -241,11 +241,11 @@ func Test_backoff_Do(t *testing.T) { args args fields fields want want - checkFunc func(want, interface{}, error) error + checkFunc func(want, any, error) error beforeFunc func(args) afterFunc func(args) } - defaultCheckFunc := func(w want, gotRes interface{}, err error) error { + defaultCheckFunc := func(w want, gotRes any, err error) error { if !errors.Is(err, w.err) { return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) } @@ -258,7 +258,7 @@ func Test_backoff_Do(t *testing.T) { func() test { ctx := context.Background() err := errors.New("error is occurred") - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { return nil, false, err } return test{ @@ -274,7 +274,7 @@ func Test_backoff_Do(t *testing.T) { }(), func() test { ctx := context.Background() - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { return nil, true, nil } return test{ @@ -289,7 +289,7 @@ func Test_backoff_Do(t *testing.T) { func() test { ctx := context.Background() err := errors.New("erros is occurred") - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { return nil, false, err } return test{ @@ -318,7 +318,7 @@ func Test_backoff_Do(t *testing.T) { func() test { ctx := context.Background() err := errors.New("erros is occurred") - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { return str, true, err } return test{ @@ -348,7 +348,7 @@ func Test_backoff_Do(t *testing.T) { ctx := context.Background() err := errors.New("erros is occurred") cnt := 0 - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { cnt++ if cnt == 2 { return str, false, err @@ -382,7 +382,7 @@ func Test_backoff_Do(t *testing.T) { ctx := context.Background() err := errors.New("erros is occurred") cnt := 0 - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { cnt++ if cnt == 2 { return str, true, nil @@ -414,7 +414,7 @@ func Test_backoff_Do(t *testing.T) { func() test { ctx := context.Background() err := errors.New("erros is occurred") - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { return str, true, err } return test{ @@ -443,7 +443,7 @@ func Test_backoff_Do(t *testing.T) { func() test { ctx := context.Background() err := errors.New("erros is occurred") - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { return str, true, err } return test{ @@ -471,7 +471,7 @@ func Test_backoff_Do(t *testing.T) { func() test { ctx, cancel := context.WithCancel(context.Background()) err := errors.New("erros is occurred") - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { cancel() return str, true, err } @@ -501,7 +501,7 @@ func Test_backoff_Do(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) err := errors.New("erros is occurred") cnt := 0 - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { cnt++ if cnt > 1 { cancel() @@ -534,7 +534,7 @@ func Test_backoff_Do(t *testing.T) { ctx := context.Background() err := errors.New("erros is occurred") cnt := 0 - f := func(context.Context) (interface{}, bool, error) { + f := func(context.Context) (any, bool, error) { cnt++ if cnt > 1 { time.Sleep(10 * time.Millisecond) @@ -683,7 +683,6 @@ func Test_backoff_Do(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/backoff/context_test.go b/internal/backoff/context_test.go index 5ed2da0e74..018eac8a4b 100644 --- a/internal/backoff/context_test.go +++ b/internal/backoff/context_test.go @@ -99,7 +99,6 @@ package backoff // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -185,7 +184,6 @@ package backoff // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -275,7 +273,6 @@ package backoff // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/cache/gache/gache.go b/internal/cache/gache/gache.go index 24709f6d9c..246d70ae95 100644 --- a/internal/cache/gache/gache.go +++ b/internal/cache/gache/gache.go @@ -52,7 +52,7 @@ func (c *cache[V]) Start(ctx context.Context) { c.gache.StartExpired(ctx, c.expireCheckDur) } -// Get calls StartExpired func of c.gache and returns (interface{}, bool) according to key. +// Get calls StartExpired func of c.gache and returns (any, bool) according to key. func (c *cache[V]) Get(key string) (V, bool) { return c.gache.Get(key) } @@ -67,7 +67,7 @@ func (c *cache[V]) Delete(key string) { c.gache.Delete(key) } -// GetAndDelete returns (interface{}, bool) and delete value according to key when value of key is set. +// GetAndDelete returns (any, bool) and delete value according to key when value of key is set. // When value of key is not set, returns (nil, false). func (c *cache[V]) GetAndDelete(key string) (V, bool) { v, ok := c.gache.Get(key) diff --git a/internal/cache/gache/gache_test.go b/internal/cache/gache/gache_test.go index 215ce14870..5a9fac4863 100644 --- a/internal/cache/gache/gache_test.go +++ b/internal/cache/gache/gache_test.go @@ -202,7 +202,7 @@ func Test_cache_Get(t *testing.T) { expiredHook func(context.Context, string) } type want struct { - want interface{} + want any want1 bool } type test struct { @@ -210,11 +210,11 @@ func Test_cache_Get(t *testing.T) { args args fields fields want want - checkFunc func(want, interface{}, bool) error + checkFunc func(want, any, bool) error beforeFunc func(*testing.T, args, *cache[any]) afterFunc func(args) } - defaultCheckFunc := func(w want, got interface{}, got1 bool) error { + defaultCheckFunc := func(w want, got any, got1 bool) error { if !reflect.DeepEqual(got, w.want) { return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) } @@ -293,7 +293,7 @@ func Test_cache_Get(t *testing.T) { func Test_cache_Set(t *testing.T) { type args struct { key string - val interface{} + val any } type fields struct { gache gache.Gache[any] @@ -303,7 +303,7 @@ func Test_cache_Set(t *testing.T) { } type want struct { key string - want interface{} + want any want1 bool } type test struct { @@ -387,7 +387,7 @@ func Test_cache_Delete(t *testing.T) { } type want struct { key string - want interface{} + want any want1 bool } type test struct { @@ -490,7 +490,7 @@ func Test_cache_GetAndDelete(t *testing.T) { expiredHook func(context.Context, string) } type want struct { - want interface{} + want any want1 bool } type test struct { @@ -498,11 +498,11 @@ func Test_cache_GetAndDelete(t *testing.T) { args args fields fields want want - checkFunc func(want, interface{}, bool) error + checkFunc func(want, any, bool) error beforeFunc func(*testing.T, args, *cache[any]) afterFunc func(args) } - defaultCheckFunc := func(w want, got interface{}, got1 bool) error { + defaultCheckFunc := func(w want, got any, got1 bool) error { if !reflect.DeepEqual(got, w.want) { return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) } diff --git a/internal/cache/gache/option_test.go b/internal/cache/gache/option_test.go index d09aa79350..1e35584599 100644 --- a/internal/cache/gache/option_test.go +++ b/internal/cache/gache/option_test.go @@ -462,7 +462,6 @@ func TestWithExpireCheckDuration(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/cache/option_test.go b/internal/cache/option_test.go index d8d01ad723..4699f6d35a 100644 --- a/internal/cache/option_test.go +++ b/internal/cache/option_test.go @@ -414,7 +414,6 @@ func TestWithExpireCheckDuration(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/circuitbreaker/breaker.go b/internal/circuitbreaker/breaker.go index 4f11ec5889..29c499c000 100644 --- a/internal/circuitbreaker/breaker.go +++ b/internal/circuitbreaker/breaker.go @@ -72,7 +72,9 @@ func newBreaker(key string, opts ...BreakerOption) (*breaker, error) { // do executes the function given argument when the current breaker state is "Closed" or "Half-Open". // If the current breaker state is "Open", this function returns ErrCircuitBreakerOpenState. -func (b *breaker) do(ctx context.Context, fn func(ctx context.Context) (val interface{}, err error)) (val interface{}, st State, err error) { +func (b *breaker) do( + ctx context.Context, fn func(ctx context.Context) (val any, err error), +) (val any, st State, err error) { if st, err := b.isReady(); err != nil { b.count.onIgnore() return nil, st, err diff --git a/internal/circuitbreaker/breaker_test.go b/internal/circuitbreaker/breaker_test.go index f02d299c4b..234e6c2cb6 100644 --- a/internal/circuitbreaker/breaker_test.go +++ b/internal/circuitbreaker/breaker_test.go @@ -544,7 +544,6 @@ func Test_breaker_fail(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -552,7 +551,7 @@ func Test_breaker_fail(t *testing.T) { // func Test_breaker_do(t *testing.T) { // type args struct { // ctx context.Context -// fn func(ctx context.Context) (val interface{}, err error) +// fn func(ctx context.Context) (val any, err error) // } // type fields struct { // key string @@ -569,7 +568,7 @@ func Test_breaker_fail(t *testing.T) { // closedRefreshExp int64 // } // type want struct { -// wantVal interface{} +// wantVal any // wantSt State // err error // } @@ -578,11 +577,11 @@ func Test_breaker_fail(t *testing.T) { // args args // fields fields // want want -// checkFunc func(want, interface{}, State, error) error +// checkFunc func(want, any, State, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotVal interface{}, gotSt State, err error) error { +// defaultCheckFunc := func(w want, gotVal any, gotSt State, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -698,7 +697,6 @@ func Test_breaker_fail(t *testing.T) { // if err := checkFunc(test.want, gotVal, gotSt, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -831,7 +829,6 @@ func Test_breaker_fail(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -851,8 +848,7 @@ func Test_breaker_fail(t *testing.T) { // cloedRefreshTimeout time.Duration // closedRefreshExp int64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields @@ -979,8 +975,7 @@ func Test_breaker_fail(t *testing.T) { // cloedRefreshTimeout time.Duration // closedRefreshExp int64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields @@ -1220,7 +1215,6 @@ func Test_breaker_fail(t *testing.T) { // if err := checkFunc(test.want, gotOk); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/circuitbreaker/counter_test.go b/internal/circuitbreaker/counter_test.go index 39d532c707..91297871c3 100644 --- a/internal/circuitbreaker/counter_test.go +++ b/internal/circuitbreaker/counter_test.go @@ -107,7 +107,6 @@ package circuitbreaker // if err := checkFunc(test.want, gotN); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -204,7 +203,6 @@ package circuitbreaker // if err := checkFunc(test.want, gotN); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -301,7 +299,6 @@ package circuitbreaker // if err := checkFunc(test.want, gotN); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -398,7 +395,6 @@ package circuitbreaker // if err := checkFunc(test.want, gotN); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -409,8 +405,7 @@ package circuitbreaker // successes int64 // failures int64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields @@ -501,8 +496,7 @@ package circuitbreaker // successes int64 // failures int64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields @@ -593,8 +587,7 @@ package circuitbreaker // successes int64 // failures int64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields @@ -685,8 +678,7 @@ package circuitbreaker // successes int64 // failures int64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields diff --git a/internal/circuitbreaker/manager.go b/internal/circuitbreaker/manager.go index 34bffe2ff2..756cfd1516 100644 --- a/internal/circuitbreaker/manager.go +++ b/internal/circuitbreaker/manager.go @@ -32,7 +32,7 @@ var ( // CircuitBreaker is a state machine to prevent doing processes that are likely to fail. type CircuitBreaker interface { - Do(ctx context.Context, key string, fn func(ctx context.Context) (interface{}, error)) (val interface{}, err error) + Do(ctx context.Context, key string, fn func(ctx context.Context) (any, error)) (val any, err error) } type breakerManager struct { @@ -58,7 +58,9 @@ func NewCircuitBreaker(opts ...Option) (CircuitBreaker, error) { } // Do invokes the breaker matching the given key. -func (bm *breakerManager) Do(ctx context.Context, key string, fn func(ctx context.Context) (interface{}, error)) (val interface{}, err error) { +func (bm *breakerManager) Do( + ctx context.Context, key string, fn func(ctx context.Context) (any, error), +) (val any, err error) { var st State defer func() { mu.Lock() diff --git a/internal/circuitbreaker/manager_test.go b/internal/circuitbreaker/manager_test.go index 1f6c41a45f..c3ca672082 100644 --- a/internal/circuitbreaker/manager_test.go +++ b/internal/circuitbreaker/manager_test.go @@ -100,7 +100,6 @@ package circuitbreaker // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -109,14 +108,14 @@ package circuitbreaker // type args struct { // ctx context.Context // key string -// fn func(ctx context.Context) (interface{}, error) +// fn func(ctx context.Context) (any, error) // } // type fields struct { // m sync.Map[string, *breaker] // opts []BreakerOption // } // type want struct { -// wantVal interface{} +// wantVal any // err error // } // type test struct { @@ -124,11 +123,11 @@ package circuitbreaker // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotVal interface{}, err error) error { +// defaultCheckFunc := func(w want, gotVal any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -213,7 +212,6 @@ package circuitbreaker // if err := checkFunc(test.want, gotVal, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -299,7 +297,6 @@ package circuitbreaker // if err := checkFunc(test.want, gotMs); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/circuitbreaker/options_test.go b/internal/circuitbreaker/options_test.go index 4e6190b61a..8cc1f0ea8f 100644 --- a/internal/circuitbreaker/options_test.go +++ b/internal/circuitbreaker/options_test.go @@ -96,7 +96,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -440,7 +436,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +521,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -612,7 +606,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -698,7 +691,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/circuitbreaker/state_test.go b/internal/circuitbreaker/state_test.go index ad64394b91..cf5d59fed9 100644 --- a/internal/circuitbreaker/state_test.go +++ b/internal/circuitbreaker/state_test.go @@ -87,7 +87,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/circuitbreaker/tripper_test.go b/internal/circuitbreaker/tripper_test.go index dd9eb7361f..67179dd16d 100644 --- a/internal/circuitbreaker/tripper_test.go +++ b/internal/circuitbreaker/tripper_test.go @@ -97,7 +97,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/client/v1/client/agent/core/client.go b/internal/client/v1/client/agent/core/client.go index 4dfc45f55c..10874ac9b2 100644 --- a/internal/client/v1/client/agent/core/client.go +++ b/internal/client/v1/client/agent/core/client.go @@ -94,9 +94,7 @@ func NewAgentClient(cc *grpc.ClientConn) Client { } func (c *agentClient) CreateIndex( - ctx context.Context, - req *client.ControlCreateIndexRequest, - _ ...grpc.CallOption, + ctx context.Context, req *client.ControlCreateIndexRequest, _ ...grpc.CallOption, ) (*client.Empty, error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+agent.CreateIndexRPCName), apiName+"/"+agent.CreateIndexRPCName) defer func() { @@ -106,16 +104,14 @@ func (c *agentClient) CreateIndex( }() _, err := c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { return agent.NewAgentClient(conn).CreateIndex(ctx, req, copts...) }) return nil, err } func (c *agentClient) SaveIndex( - ctx context.Context, - _ *client.Empty, - _ ...grpc.CallOption, + ctx context.Context, _ *client.Empty, _ ...grpc.CallOption, ) (*client.Empty, error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+agent.SaveIndexRPCName), apiName+"/"+agent.SaveIndexRPCName) defer func() { @@ -125,16 +121,14 @@ func (c *agentClient) SaveIndex( }() _, err := c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { return agent.NewAgentClient(conn).SaveIndex(ctx, new(client.Empty), copts...) }) return nil, err } func (c *agentClient) CreateAndSaveIndex( - ctx context.Context, - req *client.ControlCreateIndexRequest, - _ ...grpc.CallOption, + ctx context.Context, req *client.ControlCreateIndexRequest, _ ...grpc.CallOption, ) (*client.Empty, error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+agent.CreateAndSaveIndexRPCName), apiName+"/"+agent.CreateAndSaveIndexRPCName) defer func() { @@ -144,68 +138,14 @@ func (c *agentClient) CreateAndSaveIndex( }() _, err := c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { return agent.NewAgentClient(conn).CreateAndSaveIndex(ctx, req, copts...) }) return nil, err } -func (c *agentClient) IndexInfo( - ctx context.Context, - _ *client.Empty, - _ ...grpc.CallOption, -) (res *client.InfoIndexCount, err error) { - ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+agent.IndexInfoRPCName), apiName+"/"+agent.IndexInfoRPCName) - defer func() { - if span != nil { - span.End() - } - }() - _, err = c.c.RoundRobin(ctx, func(ctx context.Context, - conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { - res, err := agent.NewAgentClient(conn).IndexInfo(ctx, new(client.Empty), copts...) - if err != nil { - return nil, err - } - return res, err - }) - if err != nil { - return nil, err - } - return res, nil -} - -func (c *agentClient) GetTimestamp( - ctx context.Context, - req *client.ObjectGetTimestampRequest, - _ ...grpc.CallOption, -) (res *client.ObjectTimestamp, err error) { - ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+agent.GetTimestampRPCName), apiName+"/"+agent.GetTimestampRPCName) - defer func() { - if span != nil { - span.End() - } - }() - _, err = c.c.RoundRobin(ctx, func(ctx context.Context, - conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { - res, err := agent.NewAgentClient(conn).GetTimestamp(ctx, req, copts...) - if err != nil { - return nil, err - } - return res, err - }) - if err != nil { - return nil, err - } - return res, nil -} - func (c *singleAgentClient) CreateIndex( - ctx context.Context, - req *client.ControlCreateIndexRequest, - opts ...grpc.CallOption, + ctx context.Context, req *client.ControlCreateIndexRequest, opts ...grpc.CallOption, ) (*client.Empty, error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+agent.CreateIndexRPCName), apiName+"/"+agent.CreateIndexRPCName) defer func() { @@ -217,9 +157,7 @@ func (c *singleAgentClient) CreateIndex( } func (c *singleAgentClient) SaveIndex( - ctx context.Context, - _ *client.Empty, - opts ...grpc.CallOption, + ctx context.Context, _ *client.Empty, opts ...grpc.CallOption, ) (*client.Empty, error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+agent.SaveIndexRPCName), apiName+"/"+agent.SaveIndexRPCName) defer func() { @@ -231,9 +169,7 @@ func (c *singleAgentClient) SaveIndex( } func (c *singleAgentClient) CreateAndSaveIndex( - ctx context.Context, - req *client.ControlCreateIndexRequest, - opts ...grpc.CallOption, + ctx context.Context, req *client.ControlCreateIndexRequest, opts ...grpc.CallOption, ) (*client.Empty, error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+agent.CreateAndSaveIndexRPCName), apiName+"/"+agent.CreateAndSaveIndexRPCName) defer func() { @@ -243,31 +179,3 @@ func (c *singleAgentClient) CreateAndSaveIndex( }() return c.ac.CreateAndSaveIndex(ctx, req, opts...) } - -func (c *singleAgentClient) IndexInfo( - ctx context.Context, - _ *client.Empty, - opts ...grpc.CallOption, -) (res *client.InfoIndexCount, err error) { - ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+agent.IndexInfoRPCName), apiName+"/"+agent.IndexInfoRPCName) - defer func() { - if span != nil { - span.End() - } - }() - return c.ac.IndexInfo(ctx, new(client.Empty), opts...) -} - -func (c *singleAgentClient) GetTimestamp( - ctx context.Context, - req *client.ObjectGetTimestampRequest, - opts ...grpc.CallOption, -) (res *client.ObjectTimestamp, err error) { - ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+agent.GetTimestampRPCName), apiName+"/"+agent.GetTimestampRPCName) - defer func() { - if span != nil { - span.End() - } - }() - return c.ac.GetTimestamp(ctx, req, opts...) -} diff --git a/internal/client/v1/client/agent/core/client_test.go b/internal/client/v1/client/agent/core/client_test.go index 6f37d9cb93..5e7febbd8d 100644 --- a/internal/client/v1/client/agent/core/client_test.go +++ b/internal/client/v1/client/agent/core/client_test.go @@ -104,7 +104,6 @@ package core // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -114,29 +113,17 @@ package core // cc *grpc.ClientConn // } // type want struct { -// want interface { -// vald.Client -// client.ObjectReader -// client.Indexer -// } +// want Client // } // type test struct { -// name string -// args args -// want want -// checkFunc func(want, interface { -// vald.Client -// client.ObjectReader -// client.Indexer -// }) error +// name string +// args args +// want want +// checkFunc func(want, Client) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got interface { -// vald.Client -// client.ObjectReader -// client.Indexer -// }) error { +// defaultCheckFunc := func(w want, got Client) error { // if !reflect.DeepEqual(got, w.want) { // return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } @@ -202,7 +189,6 @@ package core // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -319,7 +305,6 @@ package core // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -436,7 +421,6 @@ package core // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -553,241 +537,6 @@ package core // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// -// }) -// } -// } -// -// func Test_agentClient_IndexInfo(t *testing.T) { -// type args struct { -// ctx context.Context -// in1 *client.Empty -// in2 []grpc.CallOption -// } -// type fields struct { -// Client vald.Client -// addrs []string -// c grpc.Client -// } -// type want struct { -// wantRes *client.InfoIndexCount -// err error -// } -// type test struct { -// name string -// args args -// fields fields -// want want -// checkFunc func(want, *client.InfoIndexCount, error) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) -// } -// defaultCheckFunc := func(w want, gotRes *client.InfoIndexCount, 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 -// } -// tests := []test{ -// // TODO test cases -// /* -// { -// name: "test_case_1", -// args: args { -// ctx:nil, -// in1:nil, -// in2:nil, -// }, -// fields: fields { -// Client:nil, -// addrs:nil, -// 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 { -// ctx:nil, -// in1:nil, -// in2:nil, -// }, -// fields: fields { -// Client:nil, -// addrs:nil, -// 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 -// } -// c := &agentClient{ -// Client: test.fields.Client, -// addrs: test.fields.addrs, -// c: test.fields.c, -// } -// -// gotRes, err := c.IndexInfo(test.args.ctx, test.args.in1, test.args.in2...) -// if err := checkFunc(test.want, gotRes, err); err != nil { -// tt.Errorf("error = %v", err) -// } -// -// }) -// } -// } -// -// func Test_agentClient_GetTimestamp(t *testing.T) { -// type args struct { -// ctx context.Context -// req *client.ObjectGetTimestampRequest -// in2 []grpc.CallOption -// } -// type fields struct { -// Client vald.Client -// addrs []string -// c grpc.Client -// } -// type want struct { -// wantRes *client.ObjectTimestamp -// err error -// } -// type test struct { -// name string -// args args -// fields fields -// want want -// checkFunc func(want, *client.ObjectTimestamp, error) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) -// } -// defaultCheckFunc := func(w want, gotRes *client.ObjectTimestamp, 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 -// } -// tests := []test{ -// // TODO test cases -// /* -// { -// name: "test_case_1", -// args: args { -// ctx:nil, -// req:nil, -// in2:nil, -// }, -// fields: fields { -// Client:nil, -// addrs:nil, -// 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 { -// ctx:nil, -// req:nil, -// in2:nil, -// }, -// fields: fields { -// Client:nil, -// addrs:nil, -// 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 -// } -// c := &agentClient{ -// Client: test.fields.Client, -// addrs: test.fields.addrs, -// c: test.fields.c, -// } -// -// gotRes, err := c.GetTimestamp(test.args.ctx, test.args.req, test.args.in2...) -// if err := checkFunc(test.want, gotRes, err); err != nil { -// tt.Errorf("error = %v", err) -// } -// // }) // } // } @@ -900,7 +649,6 @@ package core // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1013,7 +761,6 @@ package core // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1126,233 +873,6 @@ package core // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// -// }) -// } -// } -// -// func Test_singleAgentClient_IndexInfo(t *testing.T) { -// type args struct { -// ctx context.Context -// in1 *client.Empty -// opts []grpc.CallOption -// } -// type fields struct { -// Client vald.Client -// ac agent.AgentClient -// } -// type want struct { -// wantRes *client.InfoIndexCount -// err error -// } -// type test struct { -// name string -// args args -// fields fields -// want want -// checkFunc func(want, *client.InfoIndexCount, error) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) -// } -// defaultCheckFunc := func(w want, gotRes *client.InfoIndexCount, 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 -// } -// tests := []test{ -// // TODO test cases -// /* -// { -// name: "test_case_1", -// args: args { -// ctx:nil, -// in1:nil, -// opts:nil, -// }, -// fields: fields { -// Client:nil, -// ac: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 { -// ctx:nil, -// in1:nil, -// opts:nil, -// }, -// fields: fields { -// Client:nil, -// ac: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 -// } -// c := &singleAgentClient{ -// Client: test.fields.Client, -// ac: test.fields.ac, -// } -// -// gotRes, err := c.IndexInfo(test.args.ctx, test.args.in1, test.args.opts...) -// if err := checkFunc(test.want, gotRes, err); err != nil { -// tt.Errorf("error = %v", err) -// } -// -// }) -// } -// } -// -// func Test_singleAgentClient_GetTimestamp(t *testing.T) { -// type args struct { -// ctx context.Context -// req *client.ObjectGetTimestampRequest -// opts []grpc.CallOption -// } -// type fields struct { -// Client vald.Client -// ac agent.AgentClient -// } -// type want struct { -// wantRes *client.ObjectTimestamp -// err error -// } -// type test struct { -// name string -// args args -// fields fields -// want want -// checkFunc func(want, *client.ObjectTimestamp, error) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) -// } -// defaultCheckFunc := func(w want, gotRes *client.ObjectTimestamp, 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 -// } -// tests := []test{ -// // TODO test cases -// /* -// { -// name: "test_case_1", -// args: args { -// ctx:nil, -// req:nil, -// opts:nil, -// }, -// fields: fields { -// Client:nil, -// ac: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 { -// ctx:nil, -// req:nil, -// opts:nil, -// }, -// fields: fields { -// Client:nil, -// ac: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 -// } -// c := &singleAgentClient{ -// Client: test.fields.Client, -// ac: test.fields.ac, -// } -// -// gotRes, err := c.GetTimestamp(test.args.ctx, test.args.req, test.args.opts...) -// if err := checkFunc(test.want, gotRes, err); err != nil { -// tt.Errorf("error = %v", err) -// } -// // }) // } // } diff --git a/internal/client/v1/client/agent/core/option_test.go b/internal/client/v1/client/agent/core/option_test.go index e45ee40e61..e919fdd408 100644 --- a/internal/client/v1/client/agent/core/option_test.go +++ b/internal/client/v1/client/agent/core/option_test.go @@ -100,7 +100,6 @@ package core // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package core // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package core // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/client/v1/client/client.go b/internal/client/v1/client/client.go index 3416aca136..4c3b71363b 100644 --- a/internal/client/v1/client/client.go +++ b/internal/client/v1/client/client.go @@ -51,7 +51,7 @@ type ( SearchConfig = payload.Search_Config ObjectDistance = payload.Object_Distance ObjectTimestamp = payload.Object_Timestamp - ObjectGetTimestampRequest = payload.Object_GetTimestampRequest + ObjectTimestampRequest = payload.Object_TimestampRequest Searcher = vald.SearchClient Inserter = vald.InsertClient diff --git a/internal/client/v1/client/discoverer/discover.go b/internal/client/v1/client/discoverer/discover.go index 32b0d86ebb..83c98c46db 100644 --- a/internal/client/v1/client/discoverer/discover.go +++ b/internal/client/v1/client/discoverer/discover.go @@ -271,7 +271,7 @@ func (c *client) discover(ctx context.Context, ech chan<- error) (err error) { var connected []string if bo := c.client.GetBackoff(); bo != nil { - _, err = bo.Do(ctx, func(ctx context.Context) (interface{}, bool, error) { + _, err = bo.Do(ctx, func(ctx context.Context) (any, bool, error) { connected, err = c.updateDiscoveryInfo(ctx, ech) if err != nil { if !errors.Is(err, errors.ErrGRPCClientNotFound) && @@ -298,7 +298,9 @@ func (c *client) discover(ctx context.Context, ech chan<- error) (err error) { return c.disconnectOldAddrs(ctx, oldAddrs, connected, ech) } -func (c *client) updateDiscoveryInfo(ctx context.Context, ech chan<- error) (connected []string, err error) { +func (c *client) updateDiscoveryInfo( + ctx context.Context, ech chan<- error, +) (connected []string, err error) { nodes, err := c.discoverNodes(ctx) if err != nil { log.Warnf("error detected when discovering nodes,\terrors: %v", err) @@ -329,7 +331,7 @@ func (c *client) updateDiscoveryInfo(ctx context.Context, ech chan<- error) (con func (c *client) discoverNodes(ctx context.Context) (nodes *payload.Info_Nodes, err error) { _, err = c.dscClient.RoundRobin(grpc.WithGRPCMethod(ctx, "discoverer.v1.Discoverer/Nodes"), func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { nodes, err = discoverer.NewDiscovererClient(conn). Nodes(ctx, &payload.Discoverer_Request{ Namespace: c.namespace, @@ -344,7 +346,9 @@ func (c *client) discoverNodes(ctx context.Context) (nodes *payload.Info_Nodes, return nodes, err } -func (c *client) discoverAddrs(ctx context.Context, nodes *payload.Info_Nodes, ech chan<- error) (addrs []string, err error) { +func (c *client) discoverAddrs( + ctx context.Context, nodes *payload.Info_Nodes, ech chan<- error, +) (addrs []string, err error) { maxPodLen := 0 podLength := 0 for _, node := range nodes.GetNodes() { @@ -383,7 +387,9 @@ func (c *client) discoverAddrs(ctx context.Context, nodes *payload.Info_Nodes, e return addrs, nil } -func (c *client) disconnectOldAddrs(ctx context.Context, oldAddrs, connectedAddrs []string, ech chan<- error) (err error) { +func (c *client) disconnectOldAddrs( + ctx context.Context, oldAddrs, connectedAddrs []string, ech chan<- error, +) (err error) { if !c.autoconn { return nil } diff --git a/internal/client/v1/client/discoverer/discover_test.go b/internal/client/v1/client/discoverer/discover_test.go index 491f2ba3c5..deb775c8ab 100644 --- a/internal/client/v1/client/discoverer/discover_test.go +++ b/internal/client/v1/client/discoverer/discover_test.go @@ -243,7 +243,6 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // if err := checkFunc(test.want, gotD, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -253,21 +252,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // ctx context.Context // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // want <-chan error @@ -315,6 +317,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -351,6 +356,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -381,28 +389,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // got, err := c.Start(test.args.ctx) // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -412,21 +422,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // ctx context.Context // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // wantAddrs []string @@ -470,6 +483,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -506,6 +522,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -536,49 +555,54 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // gotAddrs := c.GetAddrs(test.args.ctx) // if err := checkFunc(test.want, gotAddrs); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func Test_client_GetClient(t *testing.T) { // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // want grpc.Client @@ -618,6 +642,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -651,6 +678,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -681,28 +711,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // got := c.GetClient() // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -713,21 +745,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // addr string // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // err error @@ -772,6 +807,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -809,6 +847,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -839,28 +880,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // err := c.connect(test.args.ctx, test.args.addr) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -871,21 +914,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // addr string // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // err error @@ -930,6 +976,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -967,6 +1016,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -997,28 +1049,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // err := c.disconnect(test.args.ctx, test.args.addr) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1029,21 +1083,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // ech chan<- error // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // wantAddrs []string @@ -1092,6 +1149,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1129,6 +1189,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1159,28 +1222,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // gotAddrs, err := c.dnsDiscovery(test.args.ctx, test.args.ech) // if err := checkFunc(test.want, gotAddrs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1191,21 +1256,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // ech chan<- error // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // err error @@ -1250,6 +1318,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1287,6 +1358,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1317,28 +1391,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // err := c.discover(test.args.ctx, test.args.ech) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1349,21 +1425,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // ech chan<- error // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // wantConnected []string @@ -1412,6 +1491,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1449,6 +1531,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1479,28 +1564,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // gotConnected, err := c.updateDiscoveryInfo(test.args.ctx, test.args.ech) // if err := checkFunc(test.want, gotConnected, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1510,21 +1597,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // ctx context.Context // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // wantNodes *payload.Info_Nodes @@ -1572,6 +1662,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1608,6 +1701,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1638,28 +1734,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // gotNodes, err := c.discoverNodes(test.args.ctx) // if err := checkFunc(test.want, gotNodes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1671,21 +1769,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // ech chan<- error // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // wantAddrs []string @@ -1735,6 +1836,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1773,6 +1877,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1803,28 +1910,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // gotAddrs, err := c.discoverAddrs(test.args.ctx, test.args.nodes, test.args.ech) // if err := checkFunc(test.want, gotAddrs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1837,21 +1946,24 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // ech chan<- error // } // type fields struct { -// autoconn bool -// onDiscover func(ctx context.Context, c Client, addrs []string) error -// onConnect func(ctx context.Context, c Client, addr string) error -// onDisconnect func(ctx context.Context, c Client, addr string) error -// client grpc.Client -// dns string -// opts []grpc.Option -// port int -// addrs atomic.Pointer[[]string] -// dscClient grpc.Client -// dscDur time.Duration -// eg errgroup.Group -// name string -// namespace string -// nodeName string +// autoconn bool +// onDiscover func(ctx context.Context, c Client, addrs []string) error +// onConnect func(ctx context.Context, c Client, addr string) error +// onDisconnect func(ctx context.Context, c Client, addr string) error +// client grpc.Client +// dns string +// opts []grpc.Option +// port int +// addrs atomic.Pointer[[]string] +// dscClient grpc.Client +// dscDur time.Duration +// eg errgroup.Group +// name string +// namespace string +// nodeName string +// readClient grpc.Client +// readReplicaReplicas uint64 +// roundRobin atomic.Uint64 // } // type want struct { // err error @@ -1898,6 +2010,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1937,6 +2052,9 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // name:"", // namespace:"", // nodeName:"", +// readClient:nil, +// readReplicaReplicas:0, +// roundRobin:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1967,28 +2085,30 @@ func Test_client_GetReadClient_concurrent(t *testing.T) { // checkFunc = defaultCheckFunc // } // c := &client{ -// autoconn: test.fields.autoconn, -// onDiscover: test.fields.onDiscover, -// onConnect: test.fields.onConnect, -// onDisconnect: test.fields.onDisconnect, -// client: test.fields.client, -// dns: test.fields.dns, -// opts: test.fields.opts, -// port: test.fields.port, -// addrs: test.fields.addrs, -// dscClient: test.fields.dscClient, -// dscDur: test.fields.dscDur, -// eg: test.fields.eg, -// name: test.fields.name, -// namespace: test.fields.namespace, -// nodeName: test.fields.nodeName, +// autoconn: test.fields.autoconn, +// onDiscover: test.fields.onDiscover, +// onConnect: test.fields.onConnect, +// onDisconnect: test.fields.onDisconnect, +// client: test.fields.client, +// dns: test.fields.dns, +// opts: test.fields.opts, +// port: test.fields.port, +// addrs: test.fields.addrs, +// dscClient: test.fields.dscClient, +// dscDur: test.fields.dscDur, +// eg: test.fields.eg, +// name: test.fields.name, +// namespace: test.fields.namespace, +// nodeName: test.fields.nodeName, +// readClient: test.fields.readClient, +// readReplicaReplicas: test.fields.readReplicaReplicas, +// roundRobin: test.fields.roundRobin, // } // // err := c.disconnectOldAddrs(test.args.ctx, test.args.oldAddrs, test.args.connectedAddrs, test.args.ech) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/client/v1/client/discoverer/option_test.go b/internal/client/v1/client/discoverer/option_test.go index 149b803bcc..9fff59e43d 100644 --- a/internal/client/v1/client/discoverer/option_test.go +++ b/internal/client/v1/client/discoverer/option_test.go @@ -100,7 +100,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,91 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func TestWithReadReplicaClient(t *testing.T) { +// type args struct { +// gc grpc.Client +// } +// 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 { +// gc: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 { +// gc: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 := WithReadReplicaClient(test.args.gc) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -444,7 +525,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +610,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +695,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -702,7 +780,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -788,7 +865,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -874,7 +950,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -960,7 +1035,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1046,7 +1120,6 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1132,7 +1205,91 @@ package discoverer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func TestWithReadReplicaReplicas(t *testing.T) { +// type args struct { +// num uint64 +// } +// 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 { +// num: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 { +// num: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 := WithReadReplicaReplicas(test.args.num) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/internal/client/v1/client/filter/egress/client.go b/internal/client/v1/client/filter/egress/client.go index 6fbc8fcf8e..3e550db635 100644 --- a/internal/client/v1/client/filter/egress/client.go +++ b/internal/client/v1/client/filter/egress/client.go @@ -130,7 +130,9 @@ func (c *client) Target(ctx context.Context, targets ...string) (egress.FilterCl }, nil } -func (c *client) FilterDistance(ctx context.Context, in *payload.Object_Distance, opts ...grpc.CallOption) (res *payload.Object_Distance, err error) { +func (c *client) FilterDistance( + ctx context.Context, in *payload.Object_Distance, opts ...grpc.CallOption, +) (res *payload.Object_Distance, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.FilterDistance") defer func() { if span != nil { @@ -140,7 +142,7 @@ func (c *client) FilterDistance(ctx context.Context, in *payload.Object_Distance _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = egress.NewFilterClient(conn).FilterDistance(ctx, in, append(copts, opts...)...) return nil, err }) @@ -150,7 +152,9 @@ func (c *client) FilterDistance(ctx context.Context, in *payload.Object_Distance return res, nil } -func (s *specificAddrClient) FilterDistance(ctx context.Context, in *payload.Object_Distance, opts ...grpc.CallOption) (res *payload.Object_Distance, err error) { +func (s *specificAddrClient) FilterDistance( + ctx context.Context, in *payload.Object_Distance, opts ...grpc.CallOption, +) (res *payload.Object_Distance, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.FilterDistance/"+s.addr) defer func() { if span != nil { @@ -160,7 +164,7 @@ func (s *specificAddrClient) FilterDistance(ctx context.Context, in *payload.Obj _, err = s.c.Do(ctx, s.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = egress.NewFilterClient(conn).FilterDistance(ctx, in, append(copts, opts...)...) if err != nil { return nil, err @@ -174,7 +178,9 @@ func (s *specificAddrClient) FilterDistance(ctx context.Context, in *payload.Obj return res, nil } -func (m *multipleAddrsClient) FilterDistance(ctx context.Context, in *payload.Object_Distance, opts ...grpc.CallOption) (res *payload.Object_Distance, err error) { +func (m *multipleAddrsClient) FilterDistance( + ctx context.Context, in *payload.Object_Distance, opts ...grpc.CallOption, +) (res *payload.Object_Distance, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.FilterDistance/["+strings.Join(m.addrs, ",")+"]") defer func() { if span != nil { @@ -198,7 +204,9 @@ func (m *multipleAddrsClient) FilterDistance(ctx context.Context, in *payload.Ob return res, nil } -func (c *client) FilterVector(ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (c *client) FilterVector( + ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.FilterVector") defer func() { if span != nil { @@ -208,7 +216,7 @@ func (c *client) FilterVector(ctx context.Context, in *payload.Object_Vector, op _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = egress.NewFilterClient(conn).FilterVector(ctx, in, append(copts, opts...)...) return nil, err }) @@ -218,7 +226,9 @@ func (c *client) FilterVector(ctx context.Context, in *payload.Object_Vector, op return res, nil } -func (s *specificAddrClient) FilterVector(ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (s *specificAddrClient) FilterVector( + ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.FilterVector/"+s.addr) defer func() { if span != nil { @@ -228,7 +238,7 @@ func (s *specificAddrClient) FilterVector(ctx context.Context, in *payload.Objec _, err = s.c.Do(ctx, s.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = egress.NewFilterClient(conn).FilterVector(ctx, in, append(copts, opts...)...) if err != nil { return nil, err @@ -242,7 +252,9 @@ func (s *specificAddrClient) FilterVector(ctx context.Context, in *payload.Objec return res, nil } -func (m *multipleAddrsClient) FilterVector(ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (m *multipleAddrsClient) FilterVector( + ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.FilterVector/["+strings.Join(m.addrs, ",")+"]") defer func() { if span != nil { diff --git a/internal/client/v1/client/filter/egress/client_test.go b/internal/client/v1/client/filter/egress/client_test.go index 4a1db8c6a5..44c87c0a9f 100644 --- a/internal/client/v1/client/filter/egress/client_test.go +++ b/internal/client/v1/client/filter/egress/client_test.go @@ -104,7 +104,6 @@ package egress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -215,7 +214,6 @@ package egress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -322,7 +320,6 @@ package egress // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -419,7 +416,6 @@ package egress // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -533,7 +529,6 @@ package egress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -650,7 +645,6 @@ package egress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -763,7 +757,6 @@ package egress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -876,7 +869,6 @@ package egress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -993,7 +985,6 @@ package egress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1106,7 +1097,6 @@ package egress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1219,7 +1209,6 @@ package egress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/client/v1/client/filter/egress/option_test.go b/internal/client/v1/client/filter/egress/option_test.go index ad817386c8..4bbb393b61 100644 --- a/internal/client/v1/client/filter/egress/option_test.go +++ b/internal/client/v1/client/filter/egress/option_test.go @@ -100,7 +100,6 @@ package egress // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package egress // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/client/v1/client/filter/ingress/client.go b/internal/client/v1/client/filter/ingress/client.go index 68cac7523e..56c88e5887 100644 --- a/internal/client/v1/client/filter/ingress/client.go +++ b/internal/client/v1/client/filter/ingress/client.go @@ -130,7 +130,9 @@ func (c *client) Target(ctx context.Context, targets ...string) (ingress.FilterC }, nil } -func (c *client) GenVector(ctx context.Context, in *payload.Object_Blob, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (c *client) GenVector( + ctx context.Context, in *payload.Object_Blob, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.GenVector") defer func() { if span != nil { @@ -140,7 +142,7 @@ func (c *client) GenVector(ctx context.Context, in *payload.Object_Blob, opts .. _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = ingress.NewFilterClient(conn).GenVector(ctx, in, append(copts, opts...)...) return nil, err }) @@ -150,7 +152,9 @@ func (c *client) GenVector(ctx context.Context, in *payload.Object_Blob, opts .. return res, nil } -func (c *client) FilterVector(ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (c *client) FilterVector( + ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.FilterVector") defer func() { if span != nil { @@ -160,7 +164,7 @@ func (c *client) FilterVector(ctx context.Context, in *payload.Object_Vector, op _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = ingress.NewFilterClient(conn).FilterVector(ctx, in, append(copts, opts...)...) return nil, err }) @@ -170,7 +174,9 @@ func (c *client) FilterVector(ctx context.Context, in *payload.Object_Vector, op return res, nil } -func (s *specificAddrClient) GenVector(ctx context.Context, in *payload.Object_Blob, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (s *specificAddrClient) GenVector( + ctx context.Context, in *payload.Object_Blob, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.GenVector/"+s.addr) defer func() { if span != nil { @@ -180,7 +186,7 @@ func (s *specificAddrClient) GenVector(ctx context.Context, in *payload.Object_B _, err = s.c.Do(ctx, s.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = ingress.NewFilterClient(conn).GenVector(ctx, in, append(copts, opts...)...) return nil, err }) @@ -190,7 +196,9 @@ func (s *specificAddrClient) GenVector(ctx context.Context, in *payload.Object_B return res, nil } -func (s *specificAddrClient) FilterVector(ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (s *specificAddrClient) FilterVector( + ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.FilterVector/"+s.addr) defer func() { if span != nil { @@ -200,7 +208,7 @@ func (s *specificAddrClient) FilterVector(ctx context.Context, in *payload.Objec _, err = s.c.Do(ctx, s.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = ingress.NewFilterClient(conn).FilterVector(ctx, in, append(copts, opts...)...) return nil, err }) @@ -210,7 +218,9 @@ func (s *specificAddrClient) FilterVector(ctx context.Context, in *payload.Objec return res, nil } -func (m *multipleAddrsClient) GenVector(ctx context.Context, in *payload.Object_Blob, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (m *multipleAddrsClient) GenVector( + ctx context.Context, in *payload.Object_Blob, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.GetVector/["+strings.Join(m.addrs, ",")+"]") defer func() { if span != nil { @@ -220,7 +230,7 @@ func (m *multipleAddrsClient) GenVector(ctx context.Context, in *payload.Object_ _, err = m.c.Do(ctx, m.addrs[0], func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = ingress.NewFilterClient(conn).GenVector(ctx, in, append(copts, opts...)...) return nil, err }) @@ -230,7 +240,9 @@ func (m *multipleAddrsClient) GenVector(ctx context.Context, in *payload.Object_ return res, nil } -func (m *multipleAddrsClient) FilterVector(ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (m *multipleAddrsClient) FilterVector( + ctx context.Context, in *payload.Object_Vector, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.FilterVector/["+strings.Join(m.addrs, ",")+"]") defer func() { if span != nil { diff --git a/internal/client/v1/client/filter/ingress/client_test.go b/internal/client/v1/client/filter/ingress/client_test.go index c163967916..1c84266c1f 100644 --- a/internal/client/v1/client/filter/ingress/client_test.go +++ b/internal/client/v1/client/filter/ingress/client_test.go @@ -104,7 +104,6 @@ package ingress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -215,7 +214,6 @@ package ingress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -322,7 +320,6 @@ package ingress // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -419,7 +416,6 @@ package ingress // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -533,7 +529,6 @@ package ingress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -650,7 +645,6 @@ package ingress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -767,7 +761,6 @@ package ingress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -880,7 +873,6 @@ package ingress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -993,7 +985,6 @@ package ingress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1106,7 +1097,6 @@ package ingress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1219,7 +1209,6 @@ package ingress // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/client/v1/client/filter/ingress/option_test.go b/internal/client/v1/client/filter/ingress/option_test.go index 66022604e3..1c35a938c0 100644 --- a/internal/client/v1/client/filter/ingress/option_test.go +++ b/internal/client/v1/client/filter/ingress/option_test.go @@ -100,7 +100,6 @@ package ingress // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package ingress // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/client/v1/client/mirror/mirror.go b/internal/client/v1/client/mirror/mirror.go index 616de1fabc..de28b66eb2 100644 --- a/internal/client/v1/client/mirror/mirror.go +++ b/internal/client/v1/client/mirror/mirror.go @@ -67,7 +67,9 @@ func (c *client) GRPCClient() grpc.Client { return c.c } -func (c *client) Register(ctx context.Context, in *payload.Mirror_Targets, opts ...grpc.CallOption) (res *payload.Mirror_Targets, err error) { +func (c *client) Register( + ctx context.Context, in *payload.Mirror_Targets, opts ...grpc.CallOption, +) (res *payload.Mirror_Targets, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+mirror.RegisterRPCName), apiName+"/"+mirror.RegisterRPCName) defer func() { if span != nil { @@ -75,7 +77,7 @@ func (c *client) Register(ctx context.Context, in *payload.Mirror_Targets, opts } }() - _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) { + _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (any, error) { res, err = mirror.NewMirrorClient(conn).Register(ctx, in, append(copts, opts...)...) if err != nil { return nil, err diff --git a/internal/client/v1/client/mirror/mirror_test.go b/internal/client/v1/client/mirror/mirror_test.go new file mode 100644 index 0000000000..0ff5b364aa --- /dev/null +++ b/internal/client/v1/client/mirror/mirror_test.go @@ -0,0 +1,517 @@ +// 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 mirror + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Client +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Client, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Client, 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 Test_client_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// addrs []string +// c grpc.Client +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 { +// ctx:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 +// } +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, +// } +// +// got, err := c.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_client_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// addrs []string +// c grpc.Client +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 { +// ctx:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 +// } +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, +// } +// +// err := c.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_client_GRPCClient(t *testing.T) { +// type fields struct { +// addrs []string +// c grpc.Client +// } +// type want struct { +// want grpc.Client +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, grpc.Client) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got grpc.Client) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// addrs:nil, +// c: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 { +// addrs:nil, +// c: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 +// } +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, +// } +// +// got := c.GRPCClient() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_client_Register(t *testing.T) { +// type args struct { +// ctx context.Context +// in *payload.Mirror_Targets +// opts []grpc.CallOption +// } +// type fields struct { +// addrs []string +// c grpc.Client +// } +// type want struct { +// wantRes *payload.Mirror_Targets +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Mirror_Targets, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Mirror_Targets, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 +// } +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, +// } +// +// gotRes, err := c.Register(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/client/v1/client/mirror/option.go b/internal/client/v1/client/mirror/option.go index 4d671a8771..981dd69f81 100644 --- a/internal/client/v1/client/mirror/option.go +++ b/internal/client/v1/client/mirror/option.go @@ -13,9 +13,7 @@ // limitations under the License. package mirror -import ( - "github.com/vdaas/vald/internal/net/grpc" -) +import "github.com/vdaas/vald/internal/net/grpc" type Option func(c *client) error diff --git a/internal/client/v1/client/mirror/option_test.go b/internal/client/v1/client/mirror/option_test.go new file mode 100644 index 0000000000..faaf26df0d --- /dev/null +++ b/internal/client/v1/client/mirror/option_test.go @@ -0,0 +1,186 @@ +// 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 mirror + +// NOT IMPLEMENTED BELOW +// +// func TestWithAddrs(t *testing.T) { +// type args struct { +// addrs []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 { +// addrs: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 { +// addrs: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 := WithAddrs(test.args.addrs...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithClient(t *testing.T) { +// type args struct { +// gc grpc.Client +// } +// 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 { +// gc: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 { +// gc: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 := WithClient(test.args.gc) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/client/v1/client/vald/option_test.go b/internal/client/v1/client/vald/option_test.go index 56bc50d2c9..e377146aaa 100644 --- a/internal/client/v1/client/vald/option_test.go +++ b/internal/client/v1/client/vald/option_test.go @@ -100,7 +100,6 @@ package vald // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package vald // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/client/v1/client/vald/vald.go b/internal/client/v1/client/vald/vald.go index 0cc5b2b87a..00957b7b7b 100644 --- a/internal/client/v1/client/vald/vald.go +++ b/internal/client/v1/client/vald/vald.go @@ -81,7 +81,9 @@ func (c *client) GRPCClient() grpc.Client { return c.c } -func (c *client) Exists(ctx context.Context, in *payload.Object_ID, opts ...grpc.CallOption) (oid *payload.Object_ID, err error) { +func (c *client) Exists( + ctx context.Context, in *payload.Object_ID, opts ...grpc.CallOption, +) (oid *payload.Object_ID, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.ExistsRPCName), apiName+"/"+vald.ExistsRPCName) defer func() { if span != nil { @@ -91,7 +93,7 @@ func (c *client) Exists(ctx context.Context, in *payload.Object_ID, opts ...grpc _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { oid, err = vald.NewValdClient(conn).Exists(ctx, in, append(copts, opts...)...) return nil, err }) @@ -101,7 +103,9 @@ func (c *client) Exists(ctx context.Context, in *payload.Object_ID, opts ...grpc return oid, nil } -func (c *client) Search(ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption) (res *payload.Search_Response, err error) { +func (c *client) Search( + ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.SearchRPCName), apiName+"/"+vald.SearchRPCName) defer func() { if span != nil { @@ -111,7 +115,7 @@ func (c *client) Search(ctx context.Context, in *payload.Search_Request, opts .. _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).Search(ctx, in, append(copts, opts...)...) return nil, err }) @@ -121,7 +125,9 @@ func (c *client) Search(ctx context.Context, in *payload.Search_Request, opts .. return res, nil } -func (c *client) SearchByID(ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption) (res *payload.Search_Response, err error) { +func (c *client) SearchByID( + ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.SearchByIDRPCName), apiName+"/"+vald.SearchByIDRPCName) defer func() { if span != nil { @@ -131,7 +137,7 @@ func (c *client) SearchByID(ctx context.Context, in *payload.Search_IDRequest, o _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).SearchByID(ctx, in, append(copts, opts...)...) return nil, err }) @@ -141,7 +147,9 @@ func (c *client) SearchByID(ctx context.Context, in *payload.Search_IDRequest, o return res, nil } -func (c *client) StreamSearch(ctx context.Context, opts ...grpc.CallOption) (res vald.Search_StreamSearchClient, err error) { +func (c *client) StreamSearch( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Search_StreamSearchClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamSearchRPCName), apiName+"/"+vald.StreamSearchRPCName) defer func() { if span != nil { @@ -151,7 +159,7 @@ func (c *client) StreamSearch(ctx context.Context, opts ...grpc.CallOption) (res _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).StreamSearch(ctx, append(copts, opts...)...) return nil, err }) @@ -161,7 +169,9 @@ func (c *client) StreamSearch(ctx context.Context, opts ...grpc.CallOption) (res return res, nil } -func (c *client) StreamSearchByID(ctx context.Context, opts ...grpc.CallOption) (res vald.Search_StreamSearchByIDClient, err error) { +func (c *client) StreamSearchByID( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Search_StreamSearchByIDClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamSearchByIDRPCName), apiName+"/"+vald.StreamSearchByIDRPCName) defer func() { if span != nil { @@ -171,7 +181,7 @@ func (c *client) StreamSearchByID(ctx context.Context, opts ...grpc.CallOption) _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).StreamSearchByID(ctx, append(copts, opts...)...) return nil, err }) @@ -181,7 +191,9 @@ func (c *client) StreamSearchByID(ctx context.Context, opts ...grpc.CallOption) return res, nil } -func (c *client) MultiSearch(ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption) (res *payload.Search_Responses, err error) { +func (c *client) MultiSearch( + ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.MultiSearchRPCName), apiName+"/"+vald.MultiSearchRPCName) defer func() { if span != nil { @@ -191,7 +203,7 @@ func (c *client) MultiSearch(ctx context.Context, in *payload.Search_MultiReques _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).MultiSearch(ctx, in, append(copts, opts...)...) return nil, err }) @@ -201,7 +213,9 @@ func (c *client) MultiSearch(ctx context.Context, in *payload.Search_MultiReques return res, nil } -func (c *client) MultiSearchByID(ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption) (res *payload.Search_Responses, err error) { +func (c *client) MultiSearchByID( + ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.MultiSearchByIDRPCName), apiName+"/"+vald.MultiSearchByIDRPCName) defer func() { if span != nil { @@ -211,7 +225,7 @@ func (c *client) MultiSearchByID(ctx context.Context, in *payload.Search_MultiID _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).MultiSearchByID(ctx, in, append(copts, opts...)...) return nil, err }) @@ -221,7 +235,9 @@ func (c *client) MultiSearchByID(ctx context.Context, in *payload.Search_MultiID return res, nil } -func (c *client) LinearSearch(ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption) (res *payload.Search_Response, err error) { +func (c *client) LinearSearch( + ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.LinearSearchRPCName), apiName+"/"+vald.LinearSearchRPCName) defer func() { if span != nil { @@ -231,7 +247,7 @@ func (c *client) LinearSearch(ctx context.Context, in *payload.Search_Request, o _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).LinearSearch(ctx, in, append(copts, opts...)...) return nil, err }) @@ -241,7 +257,9 @@ func (c *client) LinearSearch(ctx context.Context, in *payload.Search_Request, o return res, nil } -func (c *client) LinearSearchByID(ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption) (res *payload.Search_Response, err error) { +func (c *client) LinearSearchByID( + ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.LinearSearchByIDRPCName), apiName+"/"+vald.LinearSearchByIDRPCName) defer func() { if span != nil { @@ -251,7 +269,7 @@ func (c *client) LinearSearchByID(ctx context.Context, in *payload.Search_IDRequ _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).LinearSearchByID(ctx, in, append(copts, opts...)...) return nil, err }) @@ -261,7 +279,9 @@ func (c *client) LinearSearchByID(ctx context.Context, in *payload.Search_IDRequ return res, nil } -func (c *client) StreamLinearSearch(ctx context.Context, opts ...grpc.CallOption) (res vald.Search_StreamLinearSearchClient, err error) { +func (c *client) StreamLinearSearch( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Search_StreamLinearSearchClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamSearchRPCName), apiName+"/"+vald.StreamSearchRPCName) defer func() { if span != nil { @@ -271,7 +291,7 @@ func (c *client) StreamLinearSearch(ctx context.Context, opts ...grpc.CallOption _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).StreamLinearSearch(ctx, append(copts, opts...)...) return nil, err }) @@ -281,7 +301,9 @@ func (c *client) StreamLinearSearch(ctx context.Context, opts ...grpc.CallOption return res, nil } -func (c *client) StreamLinearSearchByID(ctx context.Context, opts ...grpc.CallOption) (res vald.Search_StreamLinearSearchByIDClient, err error) { +func (c *client) StreamLinearSearchByID( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Search_StreamLinearSearchByIDClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamSearchByIDRPCName), apiName+"/"+vald.StreamSearchByIDRPCName) defer func() { if span != nil { @@ -291,7 +313,7 @@ func (c *client) StreamLinearSearchByID(ctx context.Context, opts ...grpc.CallOp _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).StreamLinearSearchByID(ctx, append(copts, opts...)...) return nil, err }) @@ -301,7 +323,9 @@ func (c *client) StreamLinearSearchByID(ctx context.Context, opts ...grpc.CallOp return res, nil } -func (c *client) MultiLinearSearch(ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption) (res *payload.Search_Responses, err error) { +func (c *client) MultiLinearSearch( + ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.MultiLinearSearchRPCName), apiName+"/"+vald.MultiLinearSearchRPCName) defer func() { if span != nil { @@ -311,7 +335,7 @@ func (c *client) MultiLinearSearch(ctx context.Context, in *payload.Search_Multi _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).MultiLinearSearch(ctx, in, append(copts, opts...)...) return nil, err }) @@ -321,7 +345,9 @@ func (c *client) MultiLinearSearch(ctx context.Context, in *payload.Search_Multi return res, nil } -func (c *client) MultiLinearSearchByID(ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption) (res *payload.Search_Responses, err error) { +func (c *client) MultiLinearSearchByID( + ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.MultiLinearSearchByIDRPCName), apiName+"/"+vald.MultiLinearSearchByIDRPCName) defer func() { if span != nil { @@ -331,7 +357,7 @@ func (c *client) MultiLinearSearchByID(ctx context.Context, in *payload.Search_M _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).MultiLinearSearchByID(ctx, in, append(copts, opts...)...) return nil, err }) @@ -341,7 +367,9 @@ func (c *client) MultiLinearSearchByID(ctx context.Context, in *payload.Search_M return res, nil } -func (c *client) Insert(ctx context.Context, in *payload.Insert_Request, opts ...grpc.CallOption) (res *payload.Object_Location, err error) { +func (c *client) Insert( + ctx context.Context, in *payload.Insert_Request, opts ...grpc.CallOption, +) (res *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.InsertRPCName), apiName+"/"+vald.InsertRPCName) defer func() { if span != nil { @@ -351,7 +379,7 @@ func (c *client) Insert(ctx context.Context, in *payload.Insert_Request, opts .. _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).Insert(ctx, in, append(copts, opts...)...) return nil, err }) @@ -361,7 +389,9 @@ func (c *client) Insert(ctx context.Context, in *payload.Insert_Request, opts .. return res, nil } -func (c *client) StreamInsert(ctx context.Context, opts ...grpc.CallOption) (res vald.Insert_StreamInsertClient, err error) { +func (c *client) StreamInsert( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Insert_StreamInsertClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamInsertRPCName), apiName+"/"+vald.StreamInsertRPCName) defer func() { if span != nil { @@ -371,7 +401,7 @@ func (c *client) StreamInsert(ctx context.Context, opts ...grpc.CallOption) (res _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).StreamInsert(ctx, append(copts, opts...)...) return nil, err }) @@ -381,7 +411,9 @@ func (c *client) StreamInsert(ctx context.Context, opts ...grpc.CallOption) (res return res, nil } -func (c *client) MultiInsert(ctx context.Context, in *payload.Insert_MultiRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *client) MultiInsert( + ctx context.Context, in *payload.Insert_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.MultiInsertRPCName), apiName+"/"+vald.MultiInsertRPCName) defer func() { if span != nil { @@ -391,7 +423,7 @@ func (c *client) MultiInsert(ctx context.Context, in *payload.Insert_MultiReques _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).MultiInsert(ctx, in, append(copts, opts...)...) return nil, err }) @@ -401,7 +433,9 @@ func (c *client) MultiInsert(ctx context.Context, in *payload.Insert_MultiReques return res, nil } -func (c *client) Update(ctx context.Context, in *payload.Update_Request, opts ...grpc.CallOption) (res *payload.Object_Location, err error) { +func (c *client) Update( + ctx context.Context, in *payload.Update_Request, opts ...grpc.CallOption, +) (res *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.UpdateRPCName), apiName+"/"+vald.UpdateRPCName) defer func() { if span != nil { @@ -411,7 +445,7 @@ func (c *client) Update(ctx context.Context, in *payload.Update_Request, opts .. _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).Update(ctx, in, append(copts, opts...)...) return nil, err }) @@ -421,7 +455,9 @@ func (c *client) Update(ctx context.Context, in *payload.Update_Request, opts .. return res, nil } -func (c *client) StreamUpdate(ctx context.Context, opts ...grpc.CallOption) (res vald.Update_StreamUpdateClient, err error) { +func (c *client) StreamUpdate( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Update_StreamUpdateClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamUpdateRPCName), apiName+"/"+vald.StreamUpdateRPCName) defer func() { if span != nil { @@ -431,7 +467,7 @@ func (c *client) StreamUpdate(ctx context.Context, opts ...grpc.CallOption) (res _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).StreamUpdate(ctx, append(copts, opts...)...) return nil, err }) @@ -441,7 +477,9 @@ func (c *client) StreamUpdate(ctx context.Context, opts ...grpc.CallOption) (res return res, nil } -func (c *client) MultiUpdate(ctx context.Context, in *payload.Update_MultiRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *client) MultiUpdate( + ctx context.Context, in *payload.Update_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.MultiUpdateRPCName), apiName+"/"+vald.MultiUpdateRPCName) defer func() { if span != nil { @@ -451,7 +489,7 @@ func (c *client) MultiUpdate(ctx context.Context, in *payload.Update_MultiReques _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).MultiUpdate(ctx, in, append(copts, opts...)...) return nil, err }) @@ -461,7 +499,9 @@ func (c *client) MultiUpdate(ctx context.Context, in *payload.Update_MultiReques return res, nil } -func (c *client) Upsert(ctx context.Context, in *payload.Upsert_Request, opts ...grpc.CallOption) (res *payload.Object_Location, err error) { +func (c *client) Upsert( + ctx context.Context, in *payload.Upsert_Request, opts ...grpc.CallOption, +) (res *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.UpsertRPCName), apiName+"/"+vald.UpsertRPCName) defer func() { if span != nil { @@ -471,7 +511,7 @@ func (c *client) Upsert(ctx context.Context, in *payload.Upsert_Request, opts .. _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).Upsert(ctx, in, append(copts, opts...)...) return nil, err }) @@ -481,7 +521,9 @@ func (c *client) Upsert(ctx context.Context, in *payload.Upsert_Request, opts .. return res, nil } -func (c *client) StreamUpsert(ctx context.Context, opts ...grpc.CallOption) (res vald.Upsert_StreamUpsertClient, err error) { +func (c *client) StreamUpsert( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Upsert_StreamUpsertClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamUpsertRPCName), apiName+"/"+vald.StreamUpsertRPCName) defer func() { if span != nil { @@ -491,7 +533,7 @@ func (c *client) StreamUpsert(ctx context.Context, opts ...grpc.CallOption) (res _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).StreamUpsert(ctx, append(copts, opts...)...) return nil, err }) @@ -501,7 +543,9 @@ func (c *client) StreamUpsert(ctx context.Context, opts ...grpc.CallOption) (res return res, nil } -func (c *client) MultiUpsert(ctx context.Context, in *payload.Upsert_MultiRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *client) MultiUpsert( + ctx context.Context, in *payload.Upsert_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.MultiUpsertRPCName), apiName+"/"+vald.MultiUpsertRPCName) defer func() { if span != nil { @@ -511,7 +555,7 @@ func (c *client) MultiUpsert(ctx context.Context, in *payload.Upsert_MultiReques _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).MultiUpsert(ctx, in, append(copts, opts...)...) return nil, err }) @@ -521,7 +565,9 @@ func (c *client) MultiUpsert(ctx context.Context, in *payload.Upsert_MultiReques return res, nil } -func (c *client) Remove(ctx context.Context, in *payload.Remove_Request, opts ...grpc.CallOption) (res *payload.Object_Location, err error) { +func (c *client) Remove( + ctx context.Context, in *payload.Remove_Request, opts ...grpc.CallOption, +) (res *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.RemoveRPCName), apiName+"/"+vald.RemoveRPCName) defer func() { if span != nil { @@ -531,7 +577,7 @@ func (c *client) Remove(ctx context.Context, in *payload.Remove_Request, opts .. _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).Remove(ctx, in, append(copts, opts...)...) return nil, err }) @@ -541,7 +587,9 @@ func (c *client) Remove(ctx context.Context, in *payload.Remove_Request, opts .. return res, nil } -func (c *client) StreamRemove(ctx context.Context, opts ...grpc.CallOption) (res vald.Remove_StreamRemoveClient, err error) { +func (c *client) StreamRemove( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Remove_StreamRemoveClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamRemoveRPCName), apiName+"/"+vald.StreamRemoveRPCName) defer func() { if span != nil { @@ -551,7 +599,7 @@ func (c *client) StreamRemove(ctx context.Context, opts ...grpc.CallOption) (res _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).StreamRemove(ctx, append(copts, opts...)...) return nil, err }) @@ -561,7 +609,9 @@ func (c *client) StreamRemove(ctx context.Context, opts ...grpc.CallOption) (res return res, nil } -func (c *client) MultiRemove(ctx context.Context, in *payload.Remove_MultiRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *client) MultiRemove( + ctx context.Context, in *payload.Remove_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.MultiRemoveRPCName), apiName+"/"+vald.MultiRemoveRPCName) defer func() { if span != nil { @@ -571,7 +621,7 @@ func (c *client) MultiRemove(ctx context.Context, in *payload.Remove_MultiReques _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).MultiRemove(ctx, in, append(copts, opts...)...) return nil, err }) @@ -581,7 +631,9 @@ func (c *client) MultiRemove(ctx context.Context, in *payload.Remove_MultiReques return res, nil } -func (c *client) Flush(ctx context.Context, in *payload.Flush_Request, opts ...grpc.CallOption) (res *payload.Info_Index_Count, err error) { +func (c *client) Flush( + ctx context.Context, in *payload.Flush_Request, opts ...grpc.CallOption, +) (res *payload.Info_Index_Count, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.FlushRPCName), apiName+"/"+vald.FlushRPCName) defer func() { if span != nil { @@ -591,7 +643,7 @@ func (c *client) Flush(ctx context.Context, in *payload.Flush_Request, opts ...g _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).Flush(ctx, in, append(copts, opts...)...) return nil, err }) @@ -601,7 +653,9 @@ func (c *client) Flush(ctx context.Context, in *payload.Flush_Request, opts ...g return res, nil } -func (c *client) RemoveByTimestamp(ctx context.Context, in *payload.Remove_TimestampRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *client) RemoveByTimestamp( + ctx context.Context, in *payload.Remove_TimestampRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.RemoveByTimestampRPCName), apiName+"/"+vald.RemoveByTimestampRPCName) defer func() { if span != nil { @@ -611,7 +665,7 @@ func (c *client) RemoveByTimestamp(ctx context.Context, in *payload.Remove_Times _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).RemoveByTimestamp(ctx, in, append(copts, opts...)...) return nil, err }) @@ -621,7 +675,9 @@ func (c *client) RemoveByTimestamp(ctx context.Context, in *payload.Remove_Times return res, nil } -func (c *client) GetObject(ctx context.Context, in *payload.Object_VectorRequest, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (c *client) GetObject( + ctx context.Context, in *payload.Object_VectorRequest, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.GetObjectRPCName), apiName+"/"+vald.GetObjectRPCName) defer func() { if span != nil { @@ -631,7 +687,7 @@ func (c *client) GetObject(ctx context.Context, in *payload.Object_VectorRequest _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).GetObject(ctx, in, append(copts, opts...)...) return nil, err }) @@ -641,7 +697,9 @@ func (c *client) GetObject(ctx context.Context, in *payload.Object_VectorRequest return res, nil } -func (c *client) StreamGetObject(ctx context.Context, opts ...grpc.CallOption) (res vald.Object_StreamGetObjectClient, err error) { +func (c *client) StreamGetObject( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Object_StreamGetObjectClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamGetObjectRPCName), apiName+"/"+vald.StreamGetObjectRPCName) defer func() { if span != nil { @@ -651,7 +709,7 @@ func (c *client) StreamGetObject(ctx context.Context, opts ...grpc.CallOption) ( _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { res, err = vald.NewValdClient(conn).StreamGetObject(ctx, append(copts, opts...)...) return nil, err }) @@ -661,7 +719,9 @@ func (c *client) StreamGetObject(ctx context.Context, opts ...grpc.CallOption) ( return res, nil } -func (c *client) StreamListObject(ctx context.Context, in *payload.Object_List_Request, opts ...grpc.CallOption) (res vald.Object_StreamListObjectClient, err error) { +func (c *client) StreamListObject( + ctx context.Context, in *payload.Object_List_Request, opts ...grpc.CallOption, +) (res vald.Object_StreamListObjectClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.StreamListObjectRPCName), apiName+"/"+vald.StreamListObjectRPCName) defer func() { if span != nil { @@ -671,7 +731,7 @@ func (c *client) StreamListObject(ctx context.Context, in *payload.Object_List_R _, err = c.c.RoundRobin(ctx, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption, - ) (interface{}, error) { + ) (any, error) { return vald.NewValdClient(conn).StreamListObject(ctx, in, append(copts, opts...)...) }) if err != nil { @@ -680,6 +740,116 @@ func (c *client) StreamListObject(ctx context.Context, in *payload.Object_List_R return res, nil } +func (c *client) IndexInfo( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (res *payload.Info_Index_Count, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.IndexInfoRPCName), apiName+"/"+vald.IndexInfoRPCName) + defer func() { + if span != nil { + span.End() + } + }() + _, err = c.c.RoundRobin(ctx, func(ctx context.Context, + conn *grpc.ClientConn, + copts ...grpc.CallOption, + ) (any, error) { + res, err = vald.NewValdClient(conn).IndexInfo(ctx, in, append(copts, opts...)...) + return nil, err + }) + if err != nil { + return nil, err + } + return res, nil +} + +func (c *client) IndexDetail( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (res *payload.Info_Index_Detail, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.IndexDetailRPCName), apiName+"/"+vald.IndexDetailRPCName) + defer func() { + if span != nil { + span.End() + } + }() + _, err = c.c.RoundRobin(ctx, func(ctx context.Context, + conn *grpc.ClientConn, + copts ...grpc.CallOption, + ) (any, error) { + res, err = vald.NewValdClient(conn).IndexDetail(ctx, in, append(copts, opts...)...) + return nil, err + }) + if err != nil { + return nil, err + } + return res, nil +} + +func (c *client) IndexStatistics( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (res *payload.Info_Index_Statistics, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.IndexStatisticsRPCName), apiName+"/"+vald.IndexStatisticsRPCName) + defer func() { + if span != nil { + span.End() + } + }() + _, err = c.c.RoundRobin(ctx, func(ctx context.Context, + conn *grpc.ClientConn, + copts ...grpc.CallOption, + ) (any, error) { + res, err = vald.NewValdClient(conn).IndexStatistics(ctx, in, append(copts, opts...)...) + return nil, err + }) + if err != nil { + return nil, err + } + return res, nil +} + +func (c *client) IndexStatisticsDetail( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (res *payload.Info_Index_StatisticsDetail, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.IndexStatisticsDetailRPCName), apiName+"/"+vald.IndexStatisticsDetailRPCName) + defer func() { + if span != nil { + span.End() + } + }() + _, err = c.c.RoundRobin(ctx, func(ctx context.Context, + conn *grpc.ClientConn, + copts ...grpc.CallOption, + ) (any, error) { + res, err = vald.NewValdClient(conn).IndexStatisticsDetail(ctx, in, append(copts, opts...)...) + return nil, err + }) + if err != nil { + return nil, err + } + return res, nil +} + +func (c *client) GetTimestamp( + ctx context.Context, in *payload.Object_TimestampRequest, opts ...grpc.CallOption, +) (res *payload.Object_Timestamp, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.GetTimestampRPCName), apiName+"/"+vald.GetTimestampRPCName) + defer func() { + if span != nil { + span.End() + } + }() + _, err = c.c.RoundRobin(ctx, func(ctx context.Context, + conn *grpc.ClientConn, + copts ...grpc.CallOption, + ) (any, error) { + res, err = vald.NewValdClient(conn).GetTimestamp(ctx, in, append(copts, opts...)...) + return nil, err + }) + if err != nil { + return nil, err + } + return res, nil +} + func (*singleClient) Start(context.Context) (<-chan error, error) { return nil, nil } @@ -692,7 +862,9 @@ func (*singleClient) GRPCClient() grpc.Client { return nil } -func (c *singleClient) Exists(ctx context.Context, in *payload.Object_ID, opts ...grpc.CallOption) (oid *payload.Object_ID, err error) { +func (c *singleClient) Exists( + ctx context.Context, in *payload.Object_ID, opts ...grpc.CallOption, +) (oid *payload.Object_ID, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.ExistsRPCName), apiName+"/"+vald.ExistsRPCName) defer func() { if span != nil { @@ -702,7 +874,9 @@ func (c *singleClient) Exists(ctx context.Context, in *payload.Object_ID, opts . return c.vc.Exists(ctx, in, opts...) } -func (c *singleClient) Search(ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption) (res *payload.Search_Response, err error) { +func (c *singleClient) Search( + ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.SearchRPCName), apiName+"/"+vald.SearchRPCName) defer func() { if span != nil { @@ -712,7 +886,9 @@ func (c *singleClient) Search(ctx context.Context, in *payload.Search_Request, o return c.vc.Search(ctx, in, opts...) } -func (c *singleClient) SearchByID(ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption) (res *payload.Search_Response, err error) { +func (c *singleClient) SearchByID( + ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.SearchByIDRPCName), apiName+"/"+vald.SearchByIDRPCName) defer func() { if span != nil { @@ -722,7 +898,9 @@ func (c *singleClient) SearchByID(ctx context.Context, in *payload.Search_IDRequ return c.vc.SearchByID(ctx, in, opts...) } -func (c *singleClient) StreamSearch(ctx context.Context, opts ...grpc.CallOption) (res vald.Search_StreamSearchClient, err error) { +func (c *singleClient) StreamSearch( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Search_StreamSearchClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamSearchRPCName), apiName+"/"+vald.StreamSearchRPCName) defer func() { if span != nil { @@ -732,7 +910,9 @@ func (c *singleClient) StreamSearch(ctx context.Context, opts ...grpc.CallOption return c.vc.StreamSearch(ctx, opts...) } -func (c *singleClient) StreamSearchByID(ctx context.Context, opts ...grpc.CallOption) (res vald.Search_StreamSearchByIDClient, err error) { +func (c *singleClient) StreamSearchByID( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Search_StreamSearchByIDClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamSearchByIDRPCName), apiName+"/"+vald.StreamSearchByIDRPCName) defer func() { if span != nil { @@ -742,7 +922,9 @@ func (c *singleClient) StreamSearchByID(ctx context.Context, opts ...grpc.CallOp return c.vc.StreamSearchByID(ctx, opts...) } -func (c *singleClient) MultiSearch(ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption) (res *payload.Search_Responses, err error) { +func (c *singleClient) MultiSearch( + ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.MultiSearchRPCName), apiName+"/"+vald.MultiSearchRPCName) defer func() { if span != nil { @@ -752,7 +934,9 @@ func (c *singleClient) MultiSearch(ctx context.Context, in *payload.Search_Multi return c.vc.MultiSearch(ctx, in, opts...) } -func (c *singleClient) MultiSearchByID(ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption) (res *payload.Search_Responses, err error) { +func (c *singleClient) MultiSearchByID( + ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.MultiSearchByIDRPCName), apiName+"/"+vald.MultiSearchByIDRPCName) defer func() { if span != nil { @@ -762,7 +946,9 @@ func (c *singleClient) MultiSearchByID(ctx context.Context, in *payload.Search_M return c.vc.MultiSearchByID(ctx, in, opts...) } -func (c *singleClient) LinearSearch(ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption) (res *payload.Search_Response, err error) { +func (c *singleClient) LinearSearch( + ctx context.Context, in *payload.Search_Request, opts ...grpc.CallOption, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.LinearSearchRPCName), apiName+"/"+vald.LinearSearchRPCName) defer func() { if span != nil { @@ -772,7 +958,9 @@ func (c *singleClient) LinearSearch(ctx context.Context, in *payload.Search_Requ return c.vc.LinearSearch(ctx, in, opts...) } -func (c *singleClient) LinearSearchByID(ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption) (res *payload.Search_Response, err error) { +func (c *singleClient) LinearSearchByID( + ctx context.Context, in *payload.Search_IDRequest, opts ...grpc.CallOption, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.LinearSearchByIDRPCName), apiName+"/"+vald.LinearSearchByIDRPCName) defer func() { if span != nil { @@ -782,7 +970,9 @@ func (c *singleClient) LinearSearchByID(ctx context.Context, in *payload.Search_ return c.vc.LinearSearchByID(ctx, in, opts...) } -func (c *singleClient) StreamLinearSearch(ctx context.Context, opts ...grpc.CallOption) (res vald.Search_StreamLinearSearchClient, err error) { +func (c *singleClient) StreamLinearSearch( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Search_StreamLinearSearchClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamLinearSearchRPCName), apiName+"/"+vald.StreamLinearSearchRPCName) defer func() { if span != nil { @@ -792,7 +982,9 @@ func (c *singleClient) StreamLinearSearch(ctx context.Context, opts ...grpc.Call return c.vc.StreamLinearSearch(ctx, opts...) } -func (c *singleClient) StreamLinearSearchByID(ctx context.Context, opts ...grpc.CallOption) (res vald.Search_StreamLinearSearchByIDClient, err error) { +func (c *singleClient) StreamLinearSearchByID( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Search_StreamLinearSearchByIDClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamLinearSearchByIDRPCName), apiName+"/"+vald.StreamLinearSearchByIDRPCName) defer func() { if span != nil { @@ -802,7 +994,9 @@ func (c *singleClient) StreamLinearSearchByID(ctx context.Context, opts ...grpc. return c.vc.StreamLinearSearchByID(ctx, opts...) } -func (c *singleClient) MultiLinearSearch(ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption) (res *payload.Search_Responses, err error) { +func (c *singleClient) MultiLinearSearch( + ctx context.Context, in *payload.Search_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.MultiLinearSearchRPCName), apiName+"/"+vald.MultiLinearSearchRPCName) defer func() { if span != nil { @@ -812,7 +1006,9 @@ func (c *singleClient) MultiLinearSearch(ctx context.Context, in *payload.Search return c.vc.MultiLinearSearch(ctx, in, opts...) } -func (c *singleClient) MultiLinearSearchByID(ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption) (res *payload.Search_Responses, err error) { +func (c *singleClient) MultiLinearSearchByID( + ctx context.Context, in *payload.Search_MultiIDRequest, opts ...grpc.CallOption, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.MultiLinearSearchByIDRPCName), apiName+"/"+vald.MultiLinearSearchByIDRPCName) defer func() { if span != nil { @@ -822,7 +1018,9 @@ func (c *singleClient) MultiLinearSearchByID(ctx context.Context, in *payload.Se return c.vc.MultiLinearSearchByID(ctx, in, opts...) } -func (c *singleClient) Insert(ctx context.Context, in *payload.Insert_Request, opts ...grpc.CallOption) (res *payload.Object_Location, err error) { +func (c *singleClient) Insert( + ctx context.Context, in *payload.Insert_Request, opts ...grpc.CallOption, +) (res *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.InsertRPCName), apiName+"/"+vald.InsertRPCName) defer func() { if span != nil { @@ -832,7 +1030,9 @@ func (c *singleClient) Insert(ctx context.Context, in *payload.Insert_Request, o return c.vc.Insert(ctx, in, opts...) } -func (c *singleClient) StreamInsert(ctx context.Context, opts ...grpc.CallOption) (res vald.Insert_StreamInsertClient, err error) { +func (c *singleClient) StreamInsert( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Insert_StreamInsertClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamInsertRPCName), apiName+"/"+vald.StreamInsertRPCName) defer func() { if span != nil { @@ -842,7 +1042,9 @@ func (c *singleClient) StreamInsert(ctx context.Context, opts ...grpc.CallOption return c.vc.StreamInsert(ctx, opts...) } -func (c *singleClient) MultiInsert(ctx context.Context, in *payload.Insert_MultiRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *singleClient) MultiInsert( + ctx context.Context, in *payload.Insert_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.MultiInsertRPCName), apiName+"/"+vald.MultiInsertRPCName) defer func() { if span != nil { @@ -852,7 +1054,9 @@ func (c *singleClient) MultiInsert(ctx context.Context, in *payload.Insert_Multi return c.vc.MultiInsert(ctx, in, opts...) } -func (c *singleClient) Update(ctx context.Context, in *payload.Update_Request, opts ...grpc.CallOption) (res *payload.Object_Location, err error) { +func (c *singleClient) Update( + ctx context.Context, in *payload.Update_Request, opts ...grpc.CallOption, +) (res *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.UpdateRPCName), apiName+"/"+vald.UpdateRPCName) defer func() { if span != nil { @@ -862,7 +1066,9 @@ func (c *singleClient) Update(ctx context.Context, in *payload.Update_Request, o return c.vc.Update(ctx, in, opts...) } -func (c *singleClient) StreamUpdate(ctx context.Context, opts ...grpc.CallOption) (res vald.Update_StreamUpdateClient, err error) { +func (c *singleClient) StreamUpdate( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Update_StreamUpdateClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamUpdateRPCName), apiName+"/"+vald.StreamUpdateRPCName) defer func() { if span != nil { @@ -872,7 +1078,9 @@ func (c *singleClient) StreamUpdate(ctx context.Context, opts ...grpc.CallOption return c.vc.StreamUpdate(ctx, opts...) } -func (c *singleClient) MultiUpdate(ctx context.Context, in *payload.Update_MultiRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *singleClient) MultiUpdate( + ctx context.Context, in *payload.Update_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.MultiUpdateRPCName), apiName+"/"+vald.MultiUpdateRPCName) defer func() { if span != nil { @@ -882,7 +1090,9 @@ func (c *singleClient) MultiUpdate(ctx context.Context, in *payload.Update_Multi return c.vc.MultiUpdate(ctx, in, opts...) } -func (c *singleClient) Upsert(ctx context.Context, in *payload.Upsert_Request, opts ...grpc.CallOption) (res *payload.Object_Location, err error) { +func (c *singleClient) Upsert( + ctx context.Context, in *payload.Upsert_Request, opts ...grpc.CallOption, +) (res *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.UpsertRPCName), apiName+"/"+vald.UpsertRPCName) defer func() { if span != nil { @@ -892,7 +1102,9 @@ func (c *singleClient) Upsert(ctx context.Context, in *payload.Upsert_Request, o return c.vc.Upsert(ctx, in, opts...) } -func (c *singleClient) StreamUpsert(ctx context.Context, opts ...grpc.CallOption) (res vald.Upsert_StreamUpsertClient, err error) { +func (c *singleClient) StreamUpsert( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Upsert_StreamUpsertClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamUpsertRPCName), apiName+"/"+vald.StreamUpsertRPCName) defer func() { if span != nil { @@ -902,7 +1114,9 @@ func (c *singleClient) StreamUpsert(ctx context.Context, opts ...grpc.CallOption return c.vc.StreamUpsert(ctx, opts...) } -func (c *singleClient) MultiUpsert(ctx context.Context, in *payload.Upsert_MultiRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *singleClient) MultiUpsert( + ctx context.Context, in *payload.Upsert_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.MultiUpsertRPCName), apiName+"/"+vald.MultiUpsertRPCName) defer func() { if span != nil { @@ -912,7 +1126,9 @@ func (c *singleClient) MultiUpsert(ctx context.Context, in *payload.Upsert_Multi return c.vc.MultiUpsert(ctx, in, opts...) } -func (c *singleClient) Remove(ctx context.Context, in *payload.Remove_Request, opts ...grpc.CallOption) (res *payload.Object_Location, err error) { +func (c *singleClient) Remove( + ctx context.Context, in *payload.Remove_Request, opts ...grpc.CallOption, +) (res *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.RemoveRPCName), apiName+"/"+vald.RemoveRPCName) defer func() { if span != nil { @@ -922,7 +1138,9 @@ func (c *singleClient) Remove(ctx context.Context, in *payload.Remove_Request, o return c.vc.Remove(ctx, in, opts...) } -func (c *singleClient) StreamRemove(ctx context.Context, opts ...grpc.CallOption) (res vald.Remove_StreamRemoveClient, err error) { +func (c *singleClient) StreamRemove( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Remove_StreamRemoveClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamRemoveRPCName), apiName+"/"+vald.StreamRemoveRPCName) defer func() { if span != nil { @@ -932,7 +1150,9 @@ func (c *singleClient) StreamRemove(ctx context.Context, opts ...grpc.CallOption return c.vc.StreamRemove(ctx, opts...) } -func (c *singleClient) MultiRemove(ctx context.Context, in *payload.Remove_MultiRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *singleClient) MultiRemove( + ctx context.Context, in *payload.Remove_MultiRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.MultiRemoveRPCName), apiName+"/"+vald.MultiRemoveRPCName) defer func() { if span != nil { @@ -942,7 +1162,9 @@ func (c *singleClient) MultiRemove(ctx context.Context, in *payload.Remove_Multi return c.vc.MultiRemove(ctx, in, opts...) } -func (c *singleClient) Flush(ctx context.Context, in *payload.Flush_Request, opts ...grpc.CallOption) (res *payload.Info_Index_Count, err error) { +func (c *singleClient) Flush( + ctx context.Context, in *payload.Flush_Request, opts ...grpc.CallOption, +) (res *payload.Info_Index_Count, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/singleClient.Flush") defer func() { if span != nil { @@ -952,7 +1174,9 @@ func (c *singleClient) Flush(ctx context.Context, in *payload.Flush_Request, opt return c.vc.Flush(ctx, in, opts...) } -func (c *singleClient) RemoveByTimestamp(ctx context.Context, in *payload.Remove_TimestampRequest, opts ...grpc.CallOption) (res *payload.Object_Locations, err error) { +func (c *singleClient) RemoveByTimestamp( + ctx context.Context, in *payload.Remove_TimestampRequest, opts ...grpc.CallOption, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.RemoveByTimestampRPCName), apiName+"/"+vald.RemoveByTimestampRPCName) defer func() { if span != nil { @@ -962,7 +1186,9 @@ func (c *singleClient) RemoveByTimestamp(ctx context.Context, in *payload.Remove return c.vc.RemoveByTimestamp(ctx, in, opts...) } -func (c *singleClient) GetObject(ctx context.Context, in *payload.Object_VectorRequest, opts ...grpc.CallOption) (res *payload.Object_Vector, err error) { +func (c *singleClient) GetObject( + ctx context.Context, in *payload.Object_VectorRequest, opts ...grpc.CallOption, +) (res *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.GetObjectRPCName), apiName+"/"+vald.GetObjectRPCName) defer func() { if span != nil { @@ -972,7 +1198,9 @@ func (c *singleClient) GetObject(ctx context.Context, in *payload.Object_VectorR return c.vc.GetObject(ctx, in, opts...) } -func (c *singleClient) StreamGetObject(ctx context.Context, opts ...grpc.CallOption) (res vald.Object_StreamGetObjectClient, err error) { +func (c *singleClient) StreamGetObject( + ctx context.Context, opts ...grpc.CallOption, +) (res vald.Object_StreamGetObjectClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamGetObjectRPCName), apiName+"/"+vald.StreamGetObjectRPCName) defer func() { if span != nil { @@ -982,7 +1210,9 @@ func (c *singleClient) StreamGetObject(ctx context.Context, opts ...grpc.CallOpt return c.vc.StreamGetObject(ctx, opts...) } -func (c *singleClient) StreamListObject(ctx context.Context, in *payload.Object_List_Request, opts ...grpc.CallOption) (res vald.Object_StreamListObjectClient, err error) { +func (c *singleClient) StreamListObject( + ctx context.Context, in *payload.Object_List_Request, opts ...grpc.CallOption, +) (res vald.Object_StreamListObjectClient, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.StreamListObjectRPCName), apiName+"/"+vald.StreamListObjectRPCName) defer func() { if span != nil { @@ -991,3 +1221,63 @@ func (c *singleClient) StreamListObject(ctx context.Context, in *payload.Object_ }() return c.vc.StreamListObject(ctx, in, opts...) } + +func (c *singleClient) IndexInfo( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (res *payload.Info_Index_Count, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.IndexInfoRPCName), apiName+"/"+vald.IndexInfoRPCName) + defer func() { + if span != nil { + span.End() + } + }() + return c.vc.IndexInfo(ctx, in, opts...) +} + +func (c *singleClient) IndexDetail( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (res *payload.Info_Index_Detail, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.IndexDetailRPCName), apiName+"/"+vald.IndexDetailRPCName) + defer func() { + if span != nil { + span.End() + } + }() + return c.vc.IndexDetail(ctx, in, opts...) +} + +func (c *singleClient) IndexStatistics( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (res *payload.Info_Index_Statistics, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/singleClient/"+vald.IndexStatisticsRPCName), apiName+"/"+vald.IndexStatisticsRPCName) + defer func() { + if span != nil { + span.End() + } + }() + return c.vc.IndexStatistics(ctx, in, opts...) +} + +func (c *singleClient) IndexStatisticsDetail( + ctx context.Context, in *payload.Empty, opts ...grpc.CallOption, +) (res *payload.Info_Index_StatisticsDetail, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.IndexStatisticsDetailRPCName), apiName+"/"+vald.IndexStatisticsDetailRPCName) + defer func() { + if span != nil { + span.End() + } + }() + return c.vc.IndexStatisticsDetail(ctx, in, opts...) +} + +func (c *singleClient) GetTimestamp( + ctx context.Context, in *payload.Object_TimestampRequest, opts ...grpc.CallOption, +) (res *payload.Object_Timestamp, err error) { + ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.GetTimestampRPCName), apiName+"/"+vald.GetTimestampRPCName) + defer func() { + if span != nil { + span.End() + } + }() + return c.vc.GetTimestamp(ctx, in, opts...) +} diff --git a/internal/client/v1/client/vald/vald_test.go b/internal/client/v1/client/vald/vald_test.go index 05632dc25c..10a006d2bf 100644 --- a/internal/client/v1/client/vald/vald_test.go +++ b/internal/client/v1/client/vald/vald_test.go @@ -104,7 +104,6 @@ package vald // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -190,7 +189,6 @@ package vald // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -297,7 +295,6 @@ package vald // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -400,7 +397,6 @@ package vald // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -493,7 +489,6 @@ package vald // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -606,7 +601,6 @@ package vald // if err := checkFunc(test.want, gotOid, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -719,7 +713,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -832,7 +825,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -942,7 +934,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1052,7 +1043,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1165,7 +1155,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1278,7 +1267,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1391,7 +1379,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1504,7 +1491,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1614,7 +1600,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1724,7 +1709,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1837,7 +1821,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1950,7 +1933,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2063,7 +2045,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2173,7 +2154,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2286,7 +2266,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2399,7 +2378,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2509,7 +2487,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2622,7 +2599,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2735,7 +2711,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2845,7 +2820,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2958,7 +2932,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3071,7 +3044,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3181,7 +3153,6 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3294,15 +3265,14 @@ package vald // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_client_RemoveByTimestamp(t *testing.T) { +// func Test_client_Flush(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Remove_TimestampRequest +// in *payload.Flush_Request // opts []grpc.CallOption // } // type fields struct { @@ -3310,7 +3280,7 @@ package vald // c grpc.Client // } // type want struct { -// wantRes *payload.Object_Locations +// wantRes *payload.Info_Index_Count // err error // } // type test struct { @@ -3318,11 +3288,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, *payload.Info_Index_Count, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Count, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -3403,19 +3373,18 @@ package vald // c: test.fields.c, // } // -// gotRes, err := c.RemoveByTimestamp(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.Flush(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_client_GetObject(t *testing.T) { +// func Test_client_RemoveByTimestamp(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Object_VectorRequest +// in *payload.Remove_TimestampRequest // opts []grpc.CallOption // } // type fields struct { @@ -3423,7 +3392,7 @@ package vald // c grpc.Client // } // type want struct { -// wantRes *payload.Object_Vector +// wantRes *payload.Object_Locations // err error // } // type test struct { @@ -3431,11 +3400,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Vector, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Vector, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -3516,18 +3485,18 @@ package vald // c: test.fields.c, // } // -// gotRes, err := c.GetObject(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.RemoveByTimestamp(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_client_StreamGetObject(t *testing.T) { +// func Test_client_GetObject(t *testing.T) { // type args struct { // ctx context.Context +// in *payload.Object_VectorRequest // opts []grpc.CallOption // } // type fields struct { @@ -3535,7 +3504,7 @@ package vald // c grpc.Client // } // type want struct { -// wantRes vald.Object_StreamGetObjectClient +// wantRes *payload.Object_Vector // err error // } // type test struct { @@ -3543,11 +3512,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Object_StreamGetObjectClient, error) error +// checkFunc func(want, *payload.Object_Vector, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Object_StreamGetObjectClient, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Vector, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -3563,6 +3532,7 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -3587,6 +3557,7 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -3626,19 +3597,17 @@ package vald // c: test.fields.c, // } // -// gotRes, err := c.StreamGetObject(test.args.ctx, test.args.opts...) +// gotRes, err := c.GetObject(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_client_StreamListObject(t *testing.T) { +// func Test_client_StreamGetObject(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Object_List_Request // opts []grpc.CallOption // } // type fields struct { @@ -3646,7 +3615,7 @@ package vald // c grpc.Client // } // type want struct { -// wantRes vald.Object_StreamListObjectClient +// wantRes vald.Object_StreamGetObjectClient // err error // } // type test struct { @@ -3654,11 +3623,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Object_StreamListObjectClient, error) error +// checkFunc func(want, vald.Object_StreamGetObjectClient, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Object_StreamListObjectClient, err error) error { +// defaultCheckFunc := func(w want, gotRes vald.Object_StreamGetObjectClient, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -3674,7 +3643,6 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, -// in:nil, // opts:nil, // }, // fields: fields { @@ -3699,7 +3667,6 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, -// in:nil, // opts:nil, // }, // fields: fields { @@ -3739,41 +3706,43 @@ package vald // c: test.fields.c, // } // -// gotRes, err := c.StreamListObject(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.StreamGetObject(test.args.ctx, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_Start(t *testing.T) { +// func Test_client_StreamListObject(t *testing.T) { // type args struct { -// in0 context.Context +// ctx context.Context +// in *payload.Object_List_Request +// opts []grpc.CallOption // } // type fields struct { -// vc vald.Client +// addrs []string +// c grpc.Client // } // type want struct { -// want <-chan error -// err error +// wantRes vald.Object_StreamListObjectClient +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, <-chan error, error) error +// checkFunc func(want, vald.Object_StreamListObjectClient, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got <-chan error, err error) error { +// defaultCheckFunc := func(w want, gotRes vald.Object_StreamListObjectClient, 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) +// if !reflect.DeepEqual(gotRes, w.wantRes) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) // } // return nil // } @@ -3783,10 +3752,13 @@ package vald // { // name: "test_case_1", // args: args { -// in0:nil, +// ctx:nil, +// in:nil, +// opts:nil, // }, // fields: fields { -// vc:nil, +// addrs:nil, +// c:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3805,10 +3777,13 @@ package vald // return test { // name: "test_case_2", // args: args { -// in0:nil, +// ctx:nil, +// in:nil, +// opts:nil, // }, // fields: fields { -// vc:nil, +// addrs:nil, +// c:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3838,42 +3813,49 @@ package vald // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// s := &singleClient{ -// vc: test.fields.vc, +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, // } // -// got, err := s.Start(test.args.in0) -// if err := checkFunc(test.want, got, err); err != nil { +// gotRes, err := c.StreamListObject(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_Stop(t *testing.T) { +// func Test_client_IndexInfo(t *testing.T) { // type args struct { -// in0 context.Context +// ctx context.Context +// in *payload.Empty +// opts []grpc.CallOption // } // type fields struct { -// vc vald.Client +// addrs []string +// c grpc.Client // } // type want struct { -// err error +// wantRes *payload.Info_Index_Count +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Info_Index_Count, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Count, 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 // } // tests := []test{ @@ -3882,10 +3864,13 @@ package vald // { // name: "test_case_1", // args: args { -// in0:nil, +// ctx:nil, +// in:nil, +// opts:nil, // }, // fields: fields { -// vc:nil, +// addrs:nil, +// c:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3904,10 +3889,13 @@ package vald // return test { // name: "test_case_2", // args: args { -// in0:nil, +// ctx:nil, +// in:nil, +// opts:nil, // }, // fields: fields { -// vc:nil, +// addrs:nil, +// c:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3937,37 +3925,48 @@ package vald // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// s := &singleClient{ -// vc: test.fields.vc, +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, // } // -// err := s.Stop(test.args.in0) -// if err := checkFunc(test.want, err); err != nil { +// gotRes, err := c.IndexInfo(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_GRPCClient(t *testing.T) { +// func Test_client_IndexDetail(t *testing.T) { +// type args struct { +// ctx context.Context +// in *payload.Empty +// opts []grpc.CallOption +// } // type fields struct { -// vc vald.Client +// addrs []string +// c grpc.Client // } // type want struct { -// want grpc.Client +// wantRes *payload.Info_Index_Detail +// err error // } // type test struct { // name string +// args args // fields fields // want want -// checkFunc func(want, grpc.Client) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) +// checkFunc func(want, *payload.Info_Index_Detail, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got grpc.Client) 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.Info_Index_Detail, 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 // } @@ -3976,15 +3975,21 @@ package vald // /* // { // name: "test_case_1", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, // fields: fields { -// vc:nil, +// addrs:nil, +// c:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // }, @@ -3995,15 +4000,21 @@ package vald // func() test { // return test { // name: "test_case_2", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, // fields: fields { -// vc:nil, +// addrs:nil, +// c:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // } @@ -4017,39 +4028,40 @@ package vald // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt) +// test.beforeFunc(tt, test.args) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt) +// defer test.afterFunc(tt, test.args) // } // checkFunc := test.checkFunc // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// s := &singleClient{ -// vc: test.fields.vc, +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, // } // -// got := s.GRPCClient() -// if err := checkFunc(test.want, got); err != nil { +// gotRes, err := c.IndexDetail(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_Exists(t *testing.T) { +// func Test_client_IndexStatistics(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Object_ID +// in *payload.Empty // opts []grpc.CallOption // } // type fields struct { -// vc vald.Client +// addrs []string +// c grpc.Client // } // type want struct { -// wantOid *payload.Object_ID +// wantRes *payload.Info_Index_Statistics // err error // } // type test struct { @@ -4057,16 +4069,16 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Object_ID, error) error +// checkFunc func(want, *payload.Info_Index_Statistics, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotOid *payload.Object_ID, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Statistics, 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(gotOid, w.wantOid) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOid, w.wantOid) +// if !reflect.DeepEqual(gotRes, w.wantRes) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) // } // return nil // } @@ -4081,7 +4093,8 @@ package vald // opts:nil, // }, // fields: fields { -// vc:nil, +// addrs:nil, +// c:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4105,7 +4118,8 @@ package vald // opts:nil, // }, // fields: fields { -// vc:nil, +// addrs:nil, +// c:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4135,30 +4149,31 @@ package vald // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// c := &singleClient{ -// vc: test.fields.vc, +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, // } // -// gotOid, err := c.Exists(test.args.ctx, test.args.in, test.args.opts...) -// if err := checkFunc(test.want, gotOid, err); err != nil { +// gotRes, err := c.IndexStatistics(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_Search(t *testing.T) { +// func Test_client_IndexStatisticsDetail(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Search_Request +// in *payload.Empty // opts []grpc.CallOption // } // type fields struct { -// vc vald.Client +// addrs []string +// c grpc.Client // } // type want struct { -// wantRes *payload.Search_Response +// wantRes *payload.Info_Index_StatisticsDetail // err error // } // type test struct { @@ -4166,11 +4181,1056 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, *payload.Info_Index_StatisticsDetail, 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, gotRes *payload.Info_Index_StatisticsDetail, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 +// } +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, +// } +// +// gotRes, err := c.IndexStatisticsDetail(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_client_GetTimestamp(t *testing.T) { +// type args struct { +// ctx context.Context +// in *payload.Object_TimestampRequest +// opts []grpc.CallOption +// } +// type fields struct { +// addrs []string +// c grpc.Client +// } +// type want struct { +// wantRes *payload.Object_Timestamp +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Timestamp, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Timestamp, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// addrs:nil, +// 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 +// } +// c := &client{ +// addrs: test.fields.addrs, +// c: test.fields.c, +// } +// +// gotRes, err := c.GetTimestamp(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_Start(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// vc vald.Client +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// in0:nil, +// }, +// fields: fields { +// vc: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 { +// in0:nil, +// }, +// fields: fields { +// vc: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 +// } +// s := &singleClient{ +// vc: test.fields.vc, +// } +// +// got, err := s.Start(test.args.in0) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_Stop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// vc vald.Client +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// vc: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 { +// in0:nil, +// }, +// fields: fields { +// vc: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 +// } +// s := &singleClient{ +// vc: test.fields.vc, +// } +// +// err := s.Stop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_GRPCClient(t *testing.T) { +// type fields struct { +// vc vald.Client +// } +// type want struct { +// want grpc.Client +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, grpc.Client) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got grpc.Client) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// vc: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 { +// vc: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 +// } +// s := &singleClient{ +// vc: test.fields.vc, +// } +// +// got := s.GRPCClient() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_Exists(t *testing.T) { +// type args struct { +// ctx context.Context +// in *payload.Object_ID +// opts []grpc.CallOption +// } +// type fields struct { +// vc vald.Client +// } +// type want struct { +// wantOid *payload.Object_ID +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_ID, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotOid *payload.Object_ID, 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(gotOid, w.wantOid) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOid, w.wantOid) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 +// } +// c := &singleClient{ +// vc: test.fields.vc, +// } +// +// gotOid, err := c.Exists(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotOid, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_Search(t *testing.T) { +// type args struct { +// ctx context.Context +// in *payload.Search_Request +// opts []grpc.CallOption +// } +// type fields struct { +// vc vald.Client +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 +// } +// c := &singleClient{ +// vc: test.fields.vc, +// } +// +// gotRes, err := c.Search(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_SearchByID(t *testing.T) { +// type args struct { +// ctx context.Context +// in *payload.Search_IDRequest +// opts []grpc.CallOption +// } +// type fields struct { +// vc vald.Client +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 +// } +// c := &singleClient{ +// vc: test.fields.vc, +// } +// +// gotRes, err := c.SearchByID(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_StreamSearch(t *testing.T) { +// type args struct { +// ctx context.Context +// opts []grpc.CallOption +// } +// type fields struct { +// vc vald.Client +// } +// type want struct { +// wantRes vald.Search_StreamSearchClient +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, vald.Search_StreamSearchClient, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes vald.Search_StreamSearchClient, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 { +// ctx:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 +// } +// c := &singleClient{ +// vc: test.fields.vc, +// } +// +// gotRes, err := c.StreamSearch(test.args.ctx, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_StreamSearchByID(t *testing.T) { +// type args struct { +// ctx context.Context +// opts []grpc.CallOption +// } +// type fields struct { +// vc vald.Client +// } +// type want struct { +// wantRes vald.Search_StreamSearchByIDClient +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, vald.Search_StreamSearchByIDClient, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes vald.Search_StreamSearchByIDClient, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 { +// ctx:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 +// } +// c := &singleClient{ +// vc: test.fields.vc, +// } +// +// gotRes, err := c.StreamSearchByID(test.args.ctx, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_MultiSearch(t *testing.T) { +// type args struct { +// ctx context.Context +// in *payload.Search_MultiRequest +// opts []grpc.CallOption +// } +// type fields struct { +// vc vald.Client +// } +// type want struct { +// wantRes *payload.Search_Responses +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Search_Responses, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -4248,16 +5308,231 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.Search(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.MultiSearch(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleClient_MultiSearchByID(t *testing.T) { +// type args struct { +// ctx context.Context +// in *payload.Search_MultiIDRequest +// opts []grpc.CallOption +// } +// type fields struct { +// vc vald.Client +// } +// type want struct { +// wantRes *payload.Search_Responses +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Search_Responses, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 +// } +// c := &singleClient{ +// vc: test.fields.vc, +// } +// +// gotRes, err := c.MultiSearchByID(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_singleClient_LinearSearch(t *testing.T) { +// type args struct { +// ctx context.Context +// in *payload.Search_Request +// opts []grpc.CallOption +// } +// type fields struct { +// vc vald.Client +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 { +// ctx:nil, +// in:nil, +// opts:nil, +// }, +// fields: fields { +// vc: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 +// } +// c := &singleClient{ +// vc: test.fields.vc, +// } // +// gotRes, err := c.LinearSearch(test.args.ctx, test.args.in, test.args.opts...) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } // -// func Test_singleClient_SearchByID(t *testing.T) { +// func Test_singleClient_LinearSearchByID(t *testing.T) { // type args struct { // ctx context.Context // in *payload.Search_IDRequest @@ -4357,16 +5632,15 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.SearchByID(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.LinearSearchByID(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamSearch(t *testing.T) { +// func Test_singleClient_StreamLinearSearch(t *testing.T) { // type args struct { // ctx context.Context // opts []grpc.CallOption @@ -4375,7 +5649,7 @@ package vald // vc vald.Client // } // type want struct { -// wantRes vald.Search_StreamSearchClient +// wantRes vald.Search_StreamLinearSearchClient // err error // } // type test struct { @@ -4383,11 +5657,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Search_StreamSearchClient, error) error +// checkFunc func(want, vald.Search_StreamLinearSearchClient, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Search_StreamSearchClient, err error) error { +// defaultCheckFunc := func(w want, gotRes vald.Search_StreamLinearSearchClient, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -4463,16 +5737,15 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamSearch(test.args.ctx, test.args.opts...) +// gotRes, err := c.StreamLinearSearch(test.args.ctx, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamSearchByID(t *testing.T) { +// func Test_singleClient_StreamLinearSearchByID(t *testing.T) { // type args struct { // ctx context.Context // opts []grpc.CallOption @@ -4481,7 +5754,7 @@ package vald // vc vald.Client // } // type want struct { -// wantRes vald.Search_StreamSearchByIDClient +// wantRes vald.Search_StreamLinearSearchByIDClient // err error // } // type test struct { @@ -4489,11 +5762,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Search_StreamSearchByIDClient, error) error +// checkFunc func(want, vald.Search_StreamLinearSearchByIDClient, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Search_StreamSearchByIDClient, err error) error { +// defaultCheckFunc := func(w want, gotRes vald.Search_StreamLinearSearchByIDClient, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -4569,16 +5842,15 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamSearchByID(test.args.ctx, test.args.opts...) +// gotRes, err := c.StreamLinearSearchByID(test.args.ctx, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_MultiSearch(t *testing.T) { +// func Test_singleClient_MultiLinearSearch(t *testing.T) { // type args struct { // ctx context.Context // in *payload.Search_MultiRequest @@ -4678,16 +5950,15 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.MultiSearch(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.MultiLinearSearch(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_MultiSearchByID(t *testing.T) { +// func Test_singleClient_MultiLinearSearchByID(t *testing.T) { // type args struct { // ctx context.Context // in *payload.Search_MultiIDRequest @@ -4787,26 +6058,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.MultiSearchByID(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.MultiLinearSearchByID(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_LinearSearch(t *testing.T) { +// func Test_singleClient_Insert(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Search_Request +// in *payload.Insert_Request // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Search_Response +// wantRes *payload.Object_Location // err error // } // type test struct { @@ -4814,11 +6084,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, *payload.Object_Location, 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, gotRes *payload.Object_Location, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -4896,26 +6166,24 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.LinearSearch(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.Insert(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_LinearSearchByID(t *testing.T) { +// func Test_singleClient_StreamInsert(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Search_IDRequest // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Search_Response +// wantRes vald.Insert_StreamInsertClient // err error // } // type test struct { @@ -4923,11 +6191,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, vald.Insert_StreamInsertClient, 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, gotRes vald.Insert_StreamInsertClient, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -4943,7 +6211,6 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, -// in:nil, // opts:nil, // }, // fields: fields { @@ -4967,7 +6234,6 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, -// in:nil, // opts:nil, // }, // fields: fields { @@ -5005,25 +6271,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.LinearSearchByID(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.StreamInsert(test.args.ctx, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamLinearSearch(t *testing.T) { +// func Test_singleClient_MultiInsert(t *testing.T) { // type args struct { // ctx context.Context +// in *payload.Insert_MultiRequest // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes vald.Search_StreamLinearSearchClient +// wantRes *payload.Object_Locations // err error // } // type test struct { @@ -5031,11 +6297,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Search_StreamLinearSearchClient, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Search_StreamLinearSearchClient, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -5051,6 +6317,7 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -5074,6 +6341,7 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -5111,25 +6379,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamLinearSearch(test.args.ctx, test.args.opts...) +// gotRes, err := c.MultiInsert(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamLinearSearchByID(t *testing.T) { +// func Test_singleClient_Update(t *testing.T) { // type args struct { // ctx context.Context +// in *payload.Update_Request // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes vald.Search_StreamLinearSearchByIDClient +// wantRes *payload.Object_Location // err error // } // type test struct { @@ -5137,11 +6405,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Search_StreamLinearSearchByIDClient, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Search_StreamLinearSearchByIDClient, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Location, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -5157,6 +6425,7 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -5180,6 +6449,7 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -5217,26 +6487,24 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamLinearSearchByID(test.args.ctx, test.args.opts...) +// gotRes, err := c.Update(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_MultiLinearSearch(t *testing.T) { +// func Test_singleClient_StreamUpdate(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Search_MultiRequest // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Search_Responses +// wantRes vald.Update_StreamUpdateClient // err error // } // type test struct { @@ -5244,11 +6512,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Responses, error) error +// checkFunc func(want, vald.Update_StreamUpdateClient, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, err error) error { +// defaultCheckFunc := func(w want, gotRes vald.Update_StreamUpdateClient, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -5264,7 +6532,6 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, -// in:nil, // opts:nil, // }, // fields: fields { @@ -5288,7 +6555,6 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, -// in:nil, // opts:nil, // }, // fields: fields { @@ -5326,26 +6592,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.MultiLinearSearch(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.StreamUpdate(test.args.ctx, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_MultiLinearSearchByID(t *testing.T) { +// func Test_singleClient_MultiUpdate(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Search_MultiIDRequest +// in *payload.Update_MultiRequest // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Search_Responses +// wantRes *payload.Object_Locations // err error // } // type test struct { @@ -5353,11 +6618,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Responses, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -5435,19 +6700,18 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.MultiLinearSearchByID(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.MultiUpdate(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_Insert(t *testing.T) { +// func Test_singleClient_Upsert(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Insert_Request +// in *payload.Upsert_Request // opts []grpc.CallOption // } // type fields struct { @@ -5544,16 +6808,15 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.Insert(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.Upsert(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamInsert(t *testing.T) { +// func Test_singleClient_StreamUpsert(t *testing.T) { // type args struct { // ctx context.Context // opts []grpc.CallOption @@ -5562,7 +6825,7 @@ package vald // vc vald.Client // } // type want struct { -// wantRes vald.Insert_StreamInsertClient +// wantRes vald.Upsert_StreamUpsertClient // err error // } // type test struct { @@ -5570,11 +6833,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Insert_StreamInsertClient, error) error +// checkFunc func(want, vald.Upsert_StreamUpsertClient, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Insert_StreamInsertClient, err error) error { +// defaultCheckFunc := func(w want, gotRes vald.Upsert_StreamUpsertClient, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -5650,19 +6913,18 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamInsert(test.args.ctx, test.args.opts...) +// gotRes, err := c.StreamUpsert(test.args.ctx, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_MultiInsert(t *testing.T) { +// func Test_singleClient_MultiUpsert(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Insert_MultiRequest +// in *payload.Upsert_MultiRequest // opts []grpc.CallOption // } // type fields struct { @@ -5759,19 +7021,18 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.MultiInsert(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.MultiUpsert(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_Update(t *testing.T) { +// func Test_singleClient_Remove(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Update_Request +// in *payload.Remove_Request // opts []grpc.CallOption // } // type fields struct { @@ -5868,16 +7129,15 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.Update(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.Remove(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamUpdate(t *testing.T) { +// func Test_singleClient_StreamRemove(t *testing.T) { // type args struct { // ctx context.Context // opts []grpc.CallOption @@ -5886,7 +7146,7 @@ package vald // vc vald.Client // } // type want struct { -// wantRes vald.Update_StreamUpdateClient +// wantRes vald.Remove_StreamRemoveClient // err error // } // type test struct { @@ -5894,11 +7154,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Update_StreamUpdateClient, error) error +// checkFunc func(want, vald.Remove_StreamRemoveClient, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Update_StreamUpdateClient, err error) error { +// defaultCheckFunc := func(w want, gotRes vald.Remove_StreamRemoveClient, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -5974,19 +7234,18 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamUpdate(test.args.ctx, test.args.opts...) +// gotRes, err := c.StreamRemove(test.args.ctx, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_MultiUpdate(t *testing.T) { +// func Test_singleClient_MultiRemove(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Update_MultiRequest +// in *payload.Remove_MultiRequest // opts []grpc.CallOption // } // type fields struct { @@ -6083,26 +7342,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.MultiUpdate(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.MultiRemove(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_Upsert(t *testing.T) { +// func Test_singleClient_Flush(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Upsert_Request +// in *payload.Flush_Request // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Object_Location +// wantRes *payload.Info_Index_Count // err error // } // type test struct { @@ -6110,11 +7368,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Location, error) error +// checkFunc func(want, *payload.Info_Index_Count, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Location, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Count, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -6192,25 +7450,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.Upsert(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.Flush(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamUpsert(t *testing.T) { +// func Test_singleClient_RemoveByTimestamp(t *testing.T) { // type args struct { // ctx context.Context +// in *payload.Remove_TimestampRequest // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes vald.Upsert_StreamUpsertClient +// wantRes *payload.Object_Locations // err error // } // type test struct { @@ -6218,11 +7476,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Upsert_StreamUpsertClient, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Upsert_StreamUpsertClient, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -6238,6 +7496,7 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -6261,6 +7520,7 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -6298,26 +7558,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamUpsert(test.args.ctx, test.args.opts...) +// gotRes, err := c.RemoveByTimestamp(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_MultiUpsert(t *testing.T) { +// func Test_singleClient_GetObject(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Upsert_MultiRequest +// in *payload.Object_VectorRequest // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Object_Locations +// wantRes *payload.Object_Vector // err error // } // type test struct { @@ -6325,11 +7584,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, *payload.Object_Vector, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Vector, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -6407,26 +7666,24 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.MultiUpsert(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.GetObject(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_Remove(t *testing.T) { +// func Test_singleClient_StreamGetObject(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Remove_Request // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Object_Location +// wantRes vald.Object_StreamGetObjectClient // err error // } // type test struct { @@ -6434,11 +7691,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Location, error) error +// checkFunc func(want, vald.Object_StreamGetObjectClient, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Location, err error) error { +// defaultCheckFunc := func(w want, gotRes vald.Object_StreamGetObjectClient, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -6454,7 +7711,6 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, -// in:nil, // opts:nil, // }, // fields: fields { @@ -6478,7 +7734,6 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, -// in:nil, // opts:nil, // }, // fields: fields { @@ -6516,25 +7771,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.Remove(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.StreamGetObject(test.args.ctx, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamRemove(t *testing.T) { +// func Test_singleClient_StreamListObject(t *testing.T) { // type args struct { // ctx context.Context +// in *payload.Object_List_Request // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes vald.Remove_StreamRemoveClient +// wantRes vald.Object_StreamListObjectClient // err error // } // type test struct { @@ -6542,11 +7797,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Remove_StreamRemoveClient, error) error +// checkFunc func(want, vald.Object_StreamListObjectClient, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Remove_StreamRemoveClient, err error) error { +// defaultCheckFunc := func(w want, gotRes vald.Object_StreamListObjectClient, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -6562,6 +7817,7 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -6585,6 +7841,7 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -6622,26 +7879,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamRemove(test.args.ctx, test.args.opts...) +// gotRes, err := c.StreamListObject(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_MultiRemove(t *testing.T) { +// func Test_singleClient_IndexInfo(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Remove_MultiRequest +// in *payload.Empty // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Object_Locations +// wantRes *payload.Info_Index_Count // err error // } // type test struct { @@ -6649,11 +7905,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, *payload.Info_Index_Count, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Count, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -6731,26 +7987,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.MultiRemove(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.IndexInfo(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_RemoveByTimestamp(t *testing.T) { +// func Test_singleClient_IndexDetail(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Remove_TimestampRequest +// in *payload.Empty // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Object_Locations +// wantRes *payload.Info_Index_Detail // err error // } // type test struct { @@ -6758,11 +8013,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, *payload.Info_Index_Detail, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Detail, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -6840,26 +8095,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.RemoveByTimestamp(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.IndexDetail(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_GetObject(t *testing.T) { +// func Test_singleClient_IndexStatistics(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Object_VectorRequest +// in *payload.Empty // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes *payload.Object_Vector +// wantRes *payload.Info_Index_Statistics // err error // } // type test struct { @@ -6867,11 +8121,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Vector, error) error +// checkFunc func(want, *payload.Info_Index_Statistics, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Vector, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Statistics, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -6949,25 +8203,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.GetObject(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.IndexStatistics(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamGetObject(t *testing.T) { +// func Test_singleClient_IndexStatisticsDetail(t *testing.T) { // type args struct { // ctx context.Context +// in *payload.Empty // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes vald.Object_StreamGetObjectClient +// wantRes *payload.Info_Index_StatisticsDetail // err error // } // type test struct { @@ -6975,11 +8229,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Object_StreamGetObjectClient, error) error +// checkFunc func(want, *payload.Info_Index_StatisticsDetail, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Object_StreamGetObjectClient, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_StatisticsDetail, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -6995,6 +8249,7 @@ package vald // name: "test_case_1", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -7018,6 +8273,7 @@ package vald // name: "test_case_2", // args: args { // ctx:nil, +// in:nil, // opts:nil, // }, // fields: fields { @@ -7055,26 +8311,25 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamGetObject(test.args.ctx, test.args.opts...) +// gotRes, err := c.IndexStatisticsDetail(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_singleClient_StreamListObject(t *testing.T) { +// func Test_singleClient_GetTimestamp(t *testing.T) { // type args struct { // ctx context.Context -// in *payload.Object_List_Request +// in *payload.Object_TimestampRequest // opts []grpc.CallOption // } // type fields struct { // vc vald.Client // } // type want struct { -// wantRes vald.Object_StreamListObjectClient +// wantRes *payload.Object_Timestamp // err error // } // type test struct { @@ -7082,11 +8337,11 @@ package vald // args args // fields fields // want want -// checkFunc func(want, vald.Object_StreamListObjectClient, error) error +// checkFunc func(want, *payload.Object_Timestamp, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes vald.Object_StreamListObjectClient, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Timestamp, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -7164,11 +8419,10 @@ package vald // vc: test.fields.vc, // } // -// gotRes, err := c.StreamListObject(test.args.ctx, test.args.in, test.args.opts...) +// gotRes, err := c.GetTimestamp(test.args.ctx, test.args.in, test.args.opts...) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/compress/gob/gob.go b/internal/compress/gob/gob.go index 0c8338acb8..cfaff13839 100644 --- a/internal/compress/gob/gob.go +++ b/internal/compress/gob/gob.go @@ -21,12 +21,12 @@ import ( // Encoder represents an interface for Encoder of gob. type Encoder interface { - Encode(e interface{}) error + Encode(e any) error } // Decoder represents an interface for Decoder of gob. type Decoder interface { - Decode(e interface{}) error + Decode(e any) error } // Transcoder is an interface to create Encoder and Decoder implementation. diff --git a/internal/compress/gob/gob_mock.go b/internal/compress/gob/gob_mock.go index af769c0e96..c37f4ff8ac 100644 --- a/internal/compress/gob/gob_mock.go +++ b/internal/compress/gob/gob_mock.go @@ -17,21 +17,21 @@ import "github.com/vdaas/vald/internal/io" // MockEncoder represents mock struct of Encoder. type MockEncoder struct { - EncodeFunc func(e interface{}) error + EncodeFunc func(e any) error } // Encode calls EncodeFunc. -func (m *MockEncoder) Encode(e interface{}) error { +func (m *MockEncoder) Encode(e any) error { return m.EncodeFunc(e) } // MockDecoder represents mock struct of Decoder. type MockDecoder struct { - DecodeFunc func(e interface{}) error + DecodeFunc func(e any) error } // Decode calls DecodeFunc. -func (m *MockDecoder) Decode(e interface{}) error { +func (m *MockDecoder) Decode(e any) error { return m.DecodeFunc(e) } diff --git a/internal/compress/gob_test.go b/internal/compress/gob_test.go index fecc3dd151..68545c880f 100644 --- a/internal/compress/gob_test.go +++ b/internal/compress/gob_test.go @@ -145,7 +145,7 @@ func Test_gobCompressor_CompressVector(t *testing.T) { transcoder: &gob.MockTranscoder{ NewEncoderFunc: func(w io.Writer) gob.Encoder { return &gob.MockEncoder{ - EncodeFunc: func(e interface{}) error { + EncodeFunc: func(e any) error { _, _ = w.Write([]byte("vald")) return nil }, @@ -170,7 +170,7 @@ func Test_gobCompressor_CompressVector(t *testing.T) { transcoder: &gob.MockTranscoder{ NewEncoderFunc: func(w io.Writer) gob.Encoder { return &gob.MockEncoder{ - EncodeFunc: func(e interface{}) error { + EncodeFunc: func(e any) error { return errors.New("err") }, } @@ -319,7 +319,7 @@ func Test_gobCompressor_DecompressVector(t *testing.T) { transcoder: &gob.MockTranscoder{ NewDecoderFunc: func(io.Reader) gob.Decoder { return &gob.MockDecoder{ - DecodeFunc: func(e interface{}) error { + DecodeFunc: func(e any) error { reflect.ValueOf(e).Elem().Set(reflect.ValueOf(&[]float32{ 1, 2, 3, }).Elem()) @@ -346,7 +346,7 @@ func Test_gobCompressor_DecompressVector(t *testing.T) { transcoder: &gob.MockTranscoder{ NewDecoderFunc: func(io.Reader) gob.Decoder { return &gob.MockDecoder{ - DecodeFunc: func(interface{}) error { + DecodeFunc: func(any) error { return errors.New("err") }, } @@ -588,7 +588,7 @@ func Test_gobReader_Read(t *testing.T) { }, fields: fields{ decoder: &gob.MockDecoder{ - DecodeFunc: func(e interface{}) error { + DecodeFunc: func(e any) error { reflect.ValueOf(e).Elem().Set(reflect.ValueOf([]byte("vald"))) return nil }, @@ -607,7 +607,7 @@ func Test_gobReader_Read(t *testing.T) { }, fields: fields{ decoder: &gob.MockDecoder{ - DecodeFunc: func(e interface{}) error { + DecodeFunc: func(e any) error { return errors.New("err") }, }, @@ -747,7 +747,7 @@ func Test_gobWriter_Write(t *testing.T) { }, fields: fields{ encoder: &gob.MockEncoder{ - EncodeFunc: func(e interface{}) error { + EncodeFunc: func(e any) error { reflect.ValueOf(e).Elem().Set(reflect.ValueOf([]byte("vald"))) return nil }, @@ -766,7 +766,7 @@ func Test_gobWriter_Write(t *testing.T) { }, fields: fields{ encoder: &gob.MockEncoder{ - EncodeFunc: func(e interface{}) error { + EncodeFunc: func(e any) error { return errors.New("err") }, }, diff --git a/internal/compress/lz4_option.go b/internal/compress/lz4_option.go index f17c171814..7e170f4184 100644 --- a/internal/compress/lz4_option.go +++ b/internal/compress/lz4_option.go @@ -17,9 +17,7 @@ // Package compress provides compress functions package compress -import ( - "github.com/vdaas/vald/internal/errors" -) +import "github.com/vdaas/vald/internal/errors" // LZ4Option represents the functional option for lz4Compressor. type LZ4Option func(c *lz4Compressor) error diff --git a/internal/compress/mock_test.go b/internal/compress/mock_test.go index 6c346077f3..cf6a2188ca 100644 --- a/internal/compress/mock_test.go +++ b/internal/compress/mock_test.go @@ -125,7 +125,6 @@ package compress // if err := checkFunc(test.want, gotBytes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -240,7 +239,6 @@ package compress // if err := checkFunc(test.want, gotVector, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -355,7 +353,6 @@ package compress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -470,7 +467,6 @@ package compress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -577,7 +573,6 @@ package compress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -670,7 +665,6 @@ package compress // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -777,7 +771,6 @@ package compress // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -870,7 +863,6 @@ package compress // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/compress/zstd_option.go b/internal/compress/zstd_option.go index df60f7ac2c..a104dc8aa1 100644 --- a/internal/compress/zstd_option.go +++ b/internal/compress/zstd_option.go @@ -17,9 +17,7 @@ // Package compress provides compress functions package compress -import ( - "github.com/vdaas/vald/internal/compress/zstd" -) +import "github.com/vdaas/vald/internal/compress/zstd" // ZstdOption represents the functional option for zstdCompressor. type ZstdOption func(c *zstdCompressor) error diff --git a/internal/config/benchmark_test.go b/internal/config/benchmark_test.go new file mode 100644 index 0000000000..5f6e8f0edb --- /dev/null +++ b/internal/config/benchmark_test.go @@ -0,0 +1,1404 @@ +// 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 config + +// NOT IMPLEMENTED BELOW +// +// func TestBenchmarkTarget_Bind(t *testing.T) { +// type fields struct { +// Host string +// Port int +// } +// type want struct { +// want *BenchmarkTarget +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *BenchmarkTarget) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkTarget) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Host:"", +// Port:0, +// }, +// 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 { +// Host:"", +// Port:0, +// }, +// 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 +// } +// tr := &BenchmarkTarget{ +// Host: test.fields.Host, +// Port: test.fields.Port, +// } +// +// got := tr.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkDataset_Bind(t *testing.T) { +// type fields struct { +// Name string +// Group string +// Indexes int +// Range *BenchmarkDatasetRange +// URL string +// } +// type want struct { +// want *BenchmarkDataset +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *BenchmarkDataset) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkDataset) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Name:"", +// Group:"", +// Indexes:0, +// Range:BenchmarkDatasetRange{}, +// URL:"", +// }, +// 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 { +// Name:"", +// Group:"", +// Indexes:0, +// Range:BenchmarkDatasetRange{}, +// URL:"", +// }, +// 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 := &BenchmarkDataset{ +// Name: test.fields.Name, +// Group: test.fields.Group, +// Indexes: test.fields.Indexes, +// Range: test.fields.Range, +// URL: test.fields.URL, +// } +// +// got := d.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkJobRule_Bind(t *testing.T) { +// type fields struct { +// Name string +// Type string +// } +// type want struct { +// want *BenchmarkJobRule +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *BenchmarkJobRule) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkJobRule) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Name:"", +// Type:"", +// }, +// 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 { +// Name:"", +// Type:"", +// }, +// 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 +// } +// r := &BenchmarkJobRule{ +// Name: test.fields.Name, +// Type: test.fields.Type, +// } +// +// got := r.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestInsertConfig_Bind(t *testing.T) { +// type fields struct { +// SkipStrictExistCheck bool +// Timestamp string +// } +// type want struct { +// want *InsertConfig +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *InsertConfig) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *InsertConfig) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// SkipStrictExistCheck:false, +// Timestamp:"", +// }, +// 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 { +// SkipStrictExistCheck:false, +// Timestamp:"", +// }, +// 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 +// } +// cfg := &InsertConfig{ +// SkipStrictExistCheck: test.fields.SkipStrictExistCheck, +// Timestamp: test.fields.Timestamp, +// } +// +// got := cfg.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestUpdateConfig_Bind(t *testing.T) { +// type fields struct { +// SkipStrictExistCheck bool +// Timestamp string +// DisableBalancedUpdate bool +// } +// type want struct { +// want *UpdateConfig +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *UpdateConfig) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *UpdateConfig) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// SkipStrictExistCheck:false, +// Timestamp:"", +// DisableBalancedUpdate:false, +// }, +// 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 { +// SkipStrictExistCheck:false, +// Timestamp:"", +// DisableBalancedUpdate:false, +// }, +// 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 +// } +// cfg := &UpdateConfig{ +// SkipStrictExistCheck: test.fields.SkipStrictExistCheck, +// Timestamp: test.fields.Timestamp, +// DisableBalancedUpdate: test.fields.DisableBalancedUpdate, +// } +// +// got := cfg.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestUpsertConfig_Bind(t *testing.T) { +// type fields struct { +// SkipStrictExistCheck bool +// Timestamp string +// DisableBalancedUpdate bool +// } +// type want struct { +// want *UpsertConfig +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *UpsertConfig) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *UpsertConfig) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// SkipStrictExistCheck:false, +// Timestamp:"", +// DisableBalancedUpdate:false, +// }, +// 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 { +// SkipStrictExistCheck:false, +// Timestamp:"", +// DisableBalancedUpdate:false, +// }, +// 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 +// } +// cfg := &UpsertConfig{ +// SkipStrictExistCheck: test.fields.SkipStrictExistCheck, +// Timestamp: test.fields.Timestamp, +// DisableBalancedUpdate: test.fields.DisableBalancedUpdate, +// } +// +// got := cfg.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestSearchConfig_Bind(t *testing.T) { +// type fields struct { +// Epsilon float32 +// Radius float32 +// Num int32 +// MinNum int32 +// Timeout string +// EnableLinearSearch bool +// AggregationAlgorithm string +// } +// type want struct { +// want *SearchConfig +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *SearchConfig) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *SearchConfig) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Epsilon:0, +// Radius:0, +// Num:0, +// MinNum:0, +// Timeout:"", +// EnableLinearSearch:false, +// AggregationAlgorithm:"", +// }, +// 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 { +// Epsilon:0, +// Radius:0, +// Num:0, +// MinNum:0, +// Timeout:"", +// EnableLinearSearch:false, +// AggregationAlgorithm:"", +// }, +// 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 +// } +// cfg := &SearchConfig{ +// Epsilon: test.fields.Epsilon, +// Radius: test.fields.Radius, +// Num: test.fields.Num, +// MinNum: test.fields.MinNum, +// Timeout: test.fields.Timeout, +// EnableLinearSearch: test.fields.EnableLinearSearch, +// AggregationAlgorithm: test.fields.AggregationAlgorithm, +// } +// +// got := cfg.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestRemoveConfig_Bind(t *testing.T) { +// type fields struct { +// SkipStrictExistCheck bool +// Timestamp string +// } +// type want struct { +// want *RemoveConfig +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *RemoveConfig) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *RemoveConfig) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// SkipStrictExistCheck:false, +// Timestamp:"", +// }, +// 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 { +// SkipStrictExistCheck:false, +// Timestamp:"", +// }, +// 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 +// } +// cfg := &RemoveConfig{ +// SkipStrictExistCheck: test.fields.SkipStrictExistCheck, +// Timestamp: test.fields.Timestamp, +// } +// +// got := cfg.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestObjectConfig_Bind(t *testing.T) { +// type fields struct { +// FilterConfig FilterConfig +// } +// type want struct { +// want *ObjectConfig +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *ObjectConfig) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *ObjectConfig) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// FilterConfig:FilterConfig{}, +// }, +// 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 { +// FilterConfig:FilterConfig{}, +// }, +// 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 +// } +// cfg := &ObjectConfig{ +// FilterConfig: test.fields.FilterConfig, +// } +// +// got := cfg.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestFilterTarget_Bind(t *testing.T) { +// type fields struct { +// Host string +// Port int32 +// } +// type want struct { +// want *FilterTarget +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *FilterTarget) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *FilterTarget) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Host:"", +// Port:0, +// }, +// 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 { +// Host:"", +// Port:0, +// }, +// 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 +// } +// cfg := &FilterTarget{ +// Host: test.fields.Host, +// Port: test.fields.Port, +// } +// +// got := cfg.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestFilterConfig_Bind(t *testing.T) { +// type fields struct { +// Targets []*FilterTarget +// } +// type want struct { +// want *FilterConfig +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *FilterConfig) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *FilterConfig) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Targets: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 { +// Targets: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 +// } +// cfg := &FilterConfig{ +// Targets: test.fields.Targets, +// } +// +// got := cfg.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkJob_Bind(t *testing.T) { +// type fields struct { +// Target *BenchmarkTarget +// Dataset *BenchmarkDataset +// Replica int +// Repetition int +// JobType string +// InsertConfig *InsertConfig +// UpdateConfig *UpdateConfig +// UpsertConfig *UpsertConfig +// SearchConfig *SearchConfig +// RemoveConfig *RemoveConfig +// ObjectConfig *ObjectConfig +// ClientConfig *GRPCClient +// Rules []*BenchmarkJobRule +// BeforeJobName string +// BeforeJobNamespace string +// RPS int +// ConcurrencyLimit int +// } +// type want struct { +// want *BenchmarkJob +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *BenchmarkJob) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkJob) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Target:BenchmarkTarget{}, +// Dataset:BenchmarkDataset{}, +// Replica:0, +// Repetition:0, +// JobType:"", +// InsertConfig:InsertConfig{}, +// UpdateConfig:UpdateConfig{}, +// UpsertConfig:UpsertConfig{}, +// SearchConfig:SearchConfig{}, +// RemoveConfig:RemoveConfig{}, +// ObjectConfig:ObjectConfig{}, +// ClientConfig:GRPCClient{}, +// Rules:nil, +// BeforeJobName:"", +// BeforeJobNamespace:"", +// RPS:0, +// ConcurrencyLimit:0, +// }, +// 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 { +// Target:BenchmarkTarget{}, +// Dataset:BenchmarkDataset{}, +// Replica:0, +// Repetition:0, +// JobType:"", +// InsertConfig:InsertConfig{}, +// UpdateConfig:UpdateConfig{}, +// UpsertConfig:UpsertConfig{}, +// SearchConfig:SearchConfig{}, +// RemoveConfig:RemoveConfig{}, +// ObjectConfig:ObjectConfig{}, +// ClientConfig:GRPCClient{}, +// Rules:nil, +// BeforeJobName:"", +// BeforeJobNamespace:"", +// RPS:0, +// ConcurrencyLimit:0, +// }, +// 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 +// } +// b := &BenchmarkJob{ +// Target: test.fields.Target, +// Dataset: test.fields.Dataset, +// Replica: test.fields.Replica, +// Repetition: test.fields.Repetition, +// JobType: test.fields.JobType, +// InsertConfig: test.fields.InsertConfig, +// UpdateConfig: test.fields.UpdateConfig, +// UpsertConfig: test.fields.UpsertConfig, +// SearchConfig: test.fields.SearchConfig, +// RemoveConfig: test.fields.RemoveConfig, +// ObjectConfig: test.fields.ObjectConfig, +// ClientConfig: test.fields.ClientConfig, +// Rules: test.fields.Rules, +// BeforeJobName: test.fields.BeforeJobName, +// BeforeJobNamespace: test.fields.BeforeJobNamespace, +// RPS: test.fields.RPS, +// ConcurrencyLimit: test.fields.ConcurrencyLimit, +// } +// +// got := b.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkScenario_Bind(t *testing.T) { +// type fields struct { +// Target *BenchmarkTarget +// Dataset *BenchmarkDataset +// Jobs []*BenchmarkJob +// } +// type want struct { +// want *BenchmarkScenario +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *BenchmarkScenario) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkScenario) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Target:BenchmarkTarget{}, +// Dataset:BenchmarkDataset{}, +// Jobs: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 { +// Target:BenchmarkTarget{}, +// Dataset:BenchmarkDataset{}, +// Jobs: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 +// } +// b := &BenchmarkScenario{ +// Target: test.fields.Target, +// Dataset: test.fields.Dataset, +// Jobs: test.fields.Jobs, +// } +// +// got := b.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkJobImageInfo_Bind(t *testing.T) { +// type fields struct { +// Repository string +// Tag string +// PullPolicy string +// } +// type want struct { +// want *BenchmarkJobImageInfo +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *BenchmarkJobImageInfo) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkJobImageInfo) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Repository:"", +// Tag:"", +// PullPolicy:"", +// }, +// 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 { +// Repository:"", +// Tag:"", +// PullPolicy:"", +// }, +// 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 +// } +// b := &BenchmarkJobImageInfo{ +// Repository: test.fields.Repository, +// Tag: test.fields.Tag, +// PullPolicy: test.fields.PullPolicy, +// } +// +// got := b.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/config/circuitbreaker_test.go b/internal/config/circuitbreaker_test.go index 07feec3df6..75208e8683 100644 --- a/internal/config/circuitbreaker_test.go +++ b/internal/config/circuitbreaker_test.go @@ -115,7 +115,6 @@ package config // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/config/compress_test.go b/internal/config/compress_test.go index c2b7eb7116..155c5f7c70 100644 --- a/internal/config/compress_test.go +++ b/internal/config/compress_test.go @@ -638,7 +638,6 @@ func TestCompressorRegisterer_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/config/config.go b/internal/config/config.go index fba7c949a6..5fe764e5f2 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -63,7 +63,7 @@ func (c *GlobalConfig) Bind() *GlobalConfig { } // Read returns config struct or error when decoding the configuration file to actually *Config struct. -func Read(path string, cfg interface{}) (err error) { +func Read(path string, cfg any) (err error) { f, err := file.Open(path, os.O_RDONLY, fs.ModePerm) if err != nil { return err @@ -130,7 +130,7 @@ func checkPrefixAndSuffix(str, pref, suf string) bool { } // ToRawYaml writes the YAML encoding of v to the stream and returns the string written to stream. -func ToRawYaml(data interface{}) string { +func ToRawYaml(data any) string { b, err := yaml.Marshal(data) if err != nil { log.Error(err) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 364ba64a69..8f3520a950 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -273,21 +273,21 @@ func TestGlobalConfig_Bind(t *testing.T) { func TestRead(t *testing.T) { type args struct { path string - cfg interface{} + cfg any } type want struct { - want interface{} + want any err error } type test struct { name string args args want want - checkFunc func(want, interface{}, error) error + checkFunc func(want, any, error) error beforeFunc func(*testing.T, args) afterFunc func(*testing.T, args) } - defaultCheckFunc := func(w want, got interface{}, err error) error { + defaultCheckFunc := func(w want, got any, err error) error { if !errors.Is(err, w.err) { return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) } @@ -405,7 +405,7 @@ func TestRead(t *testing.T) { "logger": "glg" } }` - cfg := make(map[string]interface{}) + cfg := make(map[string]any) return test{ name: "return nil when read json file successes and input data type is nested map", @@ -436,10 +436,10 @@ func TestRead(t *testing.T) { } }, want: want{ - want: &map[string]interface{}{ + want: &map[string]any{ "version": "v1.0.0", "time_zone": "UTC", - "logging": map[string]interface{}{ + "logging": map[string]any{ "logger": "glg", }, }, @@ -459,7 +459,7 @@ func TestRead(t *testing.T) { "port": "3001" } ]` - cfg := make([]map[string]interface{}, 0) + cfg := make([]map[string]any, 0) return test{ name: "return nil when read json file successes and input data type is map slice", @@ -490,7 +490,7 @@ func TestRead(t *testing.T) { } }, want: want{ - want: &[]map[string]interface{}{ + want: &[]map[string]any{ { "addr": "0.0.0.0", "port": "8080", @@ -639,7 +639,7 @@ func TestRead(t *testing.T) { func() test { path := "read_config_test.yaml" data := "version: v1.0.0\ntime_zone: UTC\nlogging:\n logger: glg" - cfg := make(map[string]interface{}) + cfg := make(map[string]any) return test{ name: "return nil when read yaml file successes and input data type is nested map", @@ -670,10 +670,10 @@ func TestRead(t *testing.T) { } }, want: want{ - want: &map[string]interface{}{ + want: &map[string]any{ "version": "v1.0.0", "time_zone": "UTC", - "logging": map[string]interface{}{ + "logging": map[string]any{ "logger": "glg", }, }, @@ -684,7 +684,7 @@ func TestRead(t *testing.T) { func() test { path := "read_config_test.yaml" data := "- \n addr: 0.0.0.0\n port: \"8080\"\n- \n addr: 0.0.0.0\n port: \"3001\"" - cfg := make([]map[string]interface{}, 0) + cfg := make([]map[string]any, 0) return test{ name: "return nil when read yaml file successes and input data type is map slice", @@ -715,7 +715,7 @@ func TestRead(t *testing.T) { } }, want: want{ - want: &[]map[string]interface{}{ + want: &[]map[string]any{ { "addr": "0.0.0.0", "port": "8080", @@ -1310,7 +1310,7 @@ func Test_checkPrefixAndSuffix(t *testing.T) { func TestToRawYaml(t *testing.T) { type args struct { - data interface{} + data any } type want struct { want string @@ -1362,8 +1362,8 @@ func TestToRawYaml(t *testing.T) { { name: "return row string when data is a nested map type", args: args{ - data: map[string]interface{}{ - "logging": map[string]interface{}{ + data: map[string]any{ + "logging": map[string]any{ "logger": "glg", }, }, @@ -1890,3 +1890,5 @@ func Test_deepMerge(t *testing.T) { }) } } + +// NOT IMPLEMENTED BELOW diff --git a/internal/config/corrector_test.go b/internal/config/corrector_test.go index 95c6a83913..c0edc00dc1 100644 --- a/internal/config/corrector_test.go +++ b/internal/config/corrector_test.go @@ -131,7 +131,6 @@ package config // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/config/discoverer_test.go b/internal/config/discoverer_test.go index 1c688dd2d2..8d612692bb 100644 --- a/internal/config/discoverer_test.go +++ b/internal/config/discoverer_test.go @@ -395,7 +395,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -500,7 +499,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -605,7 +603,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -710,7 +707,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -815,7 +811,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -920,7 +915,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1025,7 +1019,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1130,7 +1123,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1235,7 +1227,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1340,7 +1331,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1433,7 +1423,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1526,7 +1515,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1619,7 +1607,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1712,7 +1699,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1817,7 +1803,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1910,7 +1895,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2003,7 +1987,6 @@ func TestDiscovererClient_Bind(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/config/faiss_test.go b/internal/config/faiss_test.go new file mode 100644 index 0000000000..fc69110c00 --- /dev/null +++ b/internal/config/faiss_test.go @@ -0,0 +1,176 @@ +// 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 config + +// NOT IMPLEMENTED BELOW +// +// func TestFaiss_Bind(t *testing.T) { +// type fields struct { +// IndexPath string +// Dimension int +// Nlist int +// M int +// NbitsPerIdx int +// MetricType string +// EnableInMemoryMode bool +// AutoIndexCheckDuration string +// AutoSaveIndexDuration string +// AutoIndexDurationLimit string +// AutoIndexLength int +// InitialDelayMaxDuration string +// MinLoadIndexTimeout string +// MaxLoadIndexTimeout string +// LoadIndexTimeoutFactor string +// EnableProactiveGC bool +// EnableCopyOnWrite bool +// VQueue *VQueue +// KVSDB *KVSDB +// } +// type want struct { +// want *Faiss +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *Faiss) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *Faiss) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// IndexPath:"", +// Dimension:0, +// Nlist:0, +// M:0, +// NbitsPerIdx:0, +// MetricType:"", +// EnableInMemoryMode:false, +// AutoIndexCheckDuration:"", +// AutoSaveIndexDuration:"", +// AutoIndexDurationLimit:"", +// AutoIndexLength:0, +// InitialDelayMaxDuration:"", +// MinLoadIndexTimeout:"", +// MaxLoadIndexTimeout:"", +// LoadIndexTimeoutFactor:"", +// EnableProactiveGC:false, +// EnableCopyOnWrite:false, +// VQueue:VQueue{}, +// KVSDB:KVSDB{}, +// }, +// 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 { +// IndexPath:"", +// Dimension:0, +// Nlist:0, +// M:0, +// NbitsPerIdx:0, +// MetricType:"", +// EnableInMemoryMode:false, +// AutoIndexCheckDuration:"", +// AutoSaveIndexDuration:"", +// AutoIndexDurationLimit:"", +// AutoIndexLength:0, +// InitialDelayMaxDuration:"", +// MinLoadIndexTimeout:"", +// MaxLoadIndexTimeout:"", +// LoadIndexTimeoutFactor:"", +// EnableProactiveGC:false, +// EnableCopyOnWrite:false, +// VQueue:VQueue{}, +// KVSDB:KVSDB{}, +// }, +// 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 +// } +// f := &Faiss{ +// IndexPath: test.fields.IndexPath, +// Dimension: test.fields.Dimension, +// Nlist: test.fields.Nlist, +// M: test.fields.M, +// NbitsPerIdx: test.fields.NbitsPerIdx, +// MetricType: test.fields.MetricType, +// EnableInMemoryMode: test.fields.EnableInMemoryMode, +// AutoIndexCheckDuration: test.fields.AutoIndexCheckDuration, +// AutoSaveIndexDuration: test.fields.AutoSaveIndexDuration, +// AutoIndexDurationLimit: test.fields.AutoIndexDurationLimit, +// AutoIndexLength: test.fields.AutoIndexLength, +// InitialDelayMaxDuration: test.fields.InitialDelayMaxDuration, +// MinLoadIndexTimeout: test.fields.MinLoadIndexTimeout, +// MaxLoadIndexTimeout: test.fields.MaxLoadIndexTimeout, +// LoadIndexTimeoutFactor: test.fields.LoadIndexTimeoutFactor, +// EnableProactiveGC: test.fields.EnableProactiveGC, +// EnableCopyOnWrite: test.fields.EnableCopyOnWrite, +// VQueue: test.fields.VQueue, +// KVSDB: test.fields.KVSDB, +// } +// +// got := f.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/config/index_creation_test.go b/internal/config/index_creation_test.go index 707b3326a9..dc3a31aa94 100644 --- a/internal/config/index_creation_test.go +++ b/internal/config/index_creation_test.go @@ -131,7 +131,6 @@ package config // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/config/index_operator_test.go b/internal/config/index_operator_test.go new file mode 100644 index 0000000000..db13967f70 --- /dev/null +++ b/internal/config/index_operator_test.go @@ -0,0 +1,136 @@ +// 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 config + +// NOT IMPLEMENTED BELOW +// +// func TestIndexOperator_Bind(t *testing.T) { +// type fields struct { +// Namespace string +// AgentName string +// AgentNamespace string +// RotatorName string +// TargetReadReplicaIDAnnotationsKey string +// RotationJobConcurrency uint +// ReadReplicaEnabled bool +// ReadReplicaLabelKey string +// JobTemplates IndexJobTemplates +// } +// type want struct { +// want *IndexOperator +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *IndexOperator) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *IndexOperator) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Namespace:"", +// AgentName:"", +// AgentNamespace:"", +// RotatorName:"", +// TargetReadReplicaIDAnnotationsKey:"", +// RotationJobConcurrency:0, +// ReadReplicaEnabled:false, +// ReadReplicaLabelKey:"", +// JobTemplates:IndexJobTemplates{}, +// }, +// 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 { +// Namespace:"", +// AgentName:"", +// AgentNamespace:"", +// RotatorName:"", +// TargetReadReplicaIDAnnotationsKey:"", +// RotationJobConcurrency:0, +// ReadReplicaEnabled:false, +// ReadReplicaLabelKey:"", +// JobTemplates:IndexJobTemplates{}, +// }, +// 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 +// } +// ic := &IndexOperator{ +// Namespace: test.fields.Namespace, +// AgentName: test.fields.AgentName, +// AgentNamespace: test.fields.AgentNamespace, +// RotatorName: test.fields.RotatorName, +// TargetReadReplicaIDAnnotationsKey: test.fields.TargetReadReplicaIDAnnotationsKey, +// RotationJobConcurrency: test.fields.RotationJobConcurrency, +// ReadReplicaEnabled: test.fields.ReadReplicaEnabled, +// ReadReplicaLabelKey: test.fields.ReadReplicaLabelKey, +// JobTemplates: test.fields.JobTemplates, +// } +// +// got := ic.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/config/index_save_test.go b/internal/config/index_save_test.go index 8c4463782a..75e24a7f0f 100644 --- a/internal/config/index_save_test.go +++ b/internal/config/index_save_test.go @@ -127,7 +127,6 @@ package config // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/config/lb_test.go b/internal/config/lb_test.go index ee392744db..526ce7a3b3 100644 --- a/internal/config/lb_test.go +++ b/internal/config/lb_test.go @@ -200,3 +200,99 @@ func TestLB_Bind(t *testing.T) { } // NOT IMPLEMENTED BELOW +// +// func TestReadReplicaClient_Bind(t *testing.T) { +// type fields struct { +// Duration string +// Client *GRPCClient +// AgentClientOptions *GRPCClient +// } +// type want struct { +// want *ReadReplicaClient +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *ReadReplicaClient) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *ReadReplicaClient) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Duration:"", +// Client:GRPCClient{}, +// AgentClientOptions:GRPCClient{}, +// }, +// 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 { +// Duration:"", +// Client:GRPCClient{}, +// AgentClientOptions:GRPCClient{}, +// }, +// 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 := &ReadReplicaClient{ +// Duration: test.fields.Duration, +// Client: test.fields.Client, +// AgentClientOptions: test.fields.AgentClientOptions, +// } +// +// got := d.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/config/meta.go b/internal/config/meta.go index 2000cb4b25..5013302b2b 100644 --- a/internal/config/meta.go +++ b/internal/config/meta.go @@ -17,9 +17,7 @@ // Package config providers configuration type and load configuration logic package config -import ( - "github.com/vdaas/vald/internal/net" -) +import "github.com/vdaas/vald/internal/net" // Meta represents the configurations for vald meta. type Meta struct { diff --git a/internal/config/mirror_test.go b/internal/config/mirror_test.go new file mode 100644 index 0000000000..438f193e58 --- /dev/null +++ b/internal/config/mirror_test.go @@ -0,0 +1,140 @@ +// 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 config + +// NOT IMPLEMENTED BELOW +// +// func TestMirror_Bind(t *testing.T) { +// type fields struct { +// Net *Net +// Client *GRPCClient +// SelfMirrorAddr string +// GatewayAddr string +// PodName string +// RegisterDuration string +// Namespace string +// DiscoveryDuration string +// Colocation string +// Group string +// } +// type want struct { +// want *Mirror +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *Mirror) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *Mirror) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Net:Net{}, +// Client:GRPCClient{}, +// SelfMirrorAddr:"", +// GatewayAddr:"", +// PodName:"", +// RegisterDuration:"", +// Namespace:"", +// DiscoveryDuration:"", +// Colocation:"", +// Group:"", +// }, +// 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 { +// Net:Net{}, +// Client:GRPCClient{}, +// SelfMirrorAddr:"", +// GatewayAddr:"", +// PodName:"", +// RegisterDuration:"", +// Namespace:"", +// DiscoveryDuration:"", +// Colocation:"", +// Group:"", +// }, +// 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 +// } +// m := &Mirror{ +// Net: test.fields.Net, +// Client: test.fields.Client, +// SelfMirrorAddr: test.fields.SelfMirrorAddr, +// GatewayAddr: test.fields.GatewayAddr, +// PodName: test.fields.PodName, +// RegisterDuration: test.fields.RegisterDuration, +// Namespace: test.fields.Namespace, +// DiscoveryDuration: test.fields.DiscoveryDuration, +// Colocation: test.fields.Colocation, +// Group: test.fields.Group, +// } +// +// got := m.Bind() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/config/ngt.go b/internal/config/ngt.go index 236a1c1fa8..0b75c91658 100644 --- a/internal/config/ngt.go +++ b/internal/config/ngt.go @@ -109,6 +109,9 @@ type NGT struct { // ExportIndexInfoDuration represents the duration of exporting index info to k8s ExportIndexInfoDuration string `json:"export_index_info_duration,omitempty" yaml:"export_index_info_duration"` + + // EnableStatistics represents whether the ngt index statistics load or not + EnableStatistics bool `json:"enable_statistics" yaml:"enable_statistics"` } // KVSDB represent the ngt vector bidirectional kv store configuration. diff --git a/internal/config/readreplica_rotate_test.go b/internal/config/readreplica_rotate_test.go index 8aa44e1c3f..147c779c94 100644 --- a/internal/config/readreplica_rotate_test.go +++ b/internal/config/readreplica_rotate_test.go @@ -19,7 +19,7 @@ package config // type fields struct { // AgentNamespace string // ReadReplicaLabelKey string -// ReadReplicaID string +// TargetReadReplicaID string // VolumeName string // } // type want struct { @@ -47,7 +47,7 @@ package config // fields: fields { // AgentNamespace:"", // ReadReplicaLabelKey:"", -// ReadReplicaID:"", +// TargetReadReplicaID:"", // VolumeName:"", // }, // want: want{}, @@ -69,7 +69,7 @@ package config // fields: fields { // AgentNamespace:"", // ReadReplicaLabelKey:"", -// ReadReplicaID:"", +// TargetReadReplicaID:"", // VolumeName:"", // }, // want: want{}, @@ -103,7 +103,7 @@ package config // r := &ReadReplicaRotate{ // AgentNamespace: test.fields.AgentNamespace, // ReadReplicaLabelKey: test.fields.ReadReplicaLabelKey, -// ReadReplicaID: test.fields.ReadReplicaID, +// TargetReadReplicaID: test.fields.TargetReadReplicaID, // VolumeName: test.fields.VolumeName, // } // @@ -111,7 +111,6 @@ package config // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/conv/conv_bench_test.go b/internal/conv/conv_bench_test.go index 49f8e7501d..a4365f6c2f 100644 --- a/internal/conv/conv_bench_test.go +++ b/internal/conv/conv_bench_test.go @@ -13,9 +13,7 @@ // limitations under the License. package conv -import ( - "testing" -) +import "testing" func Benchmark_Btoa(b *testing.B) { data := []byte(testData) diff --git a/internal/conv/conv_test.go b/internal/conv/conv_test.go index d6125a716d..e91812346b 100644 --- a/internal/conv/conv_test.go +++ b/internal/conv/conv_test.go @@ -466,7 +466,6 @@ func Test_encode(t *testing.T) { // if err := checkFunc(test.want, gotS); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/core/algorithm/faiss/option.go b/internal/core/algorithm/faiss/option.go index 650d28caaf..e7d7b757ed 100644 --- a/internal/core/algorithm/faiss/option.go +++ b/internal/core/algorithm/faiss/option.go @@ -17,6 +17,10 @@ // Package faiss provides implementation of Go API for https://github.com/facebookresearch/faiss package faiss +/* +#cgo LDFLAGS: -lfaiss +#include +*/ import "C" import ( diff --git a/internal/core/algorithm/ngt/ngt.go b/internal/core/algorithm/ngt/ngt.go index 1f0b4d3fac..56aeb548d0 100644 --- a/internal/core/algorithm/ngt/ngt.go +++ b/internal/core/algorithm/ngt/ngt.go @@ -85,6 +85,8 @@ type ( // GetVector returns vector stored in NGT index. GetVector(id uint) ([]float32, error) + GetGraphStatistics(m statisticsType) (stats *GraphStatistics, err error) + // Close Without save index. CloseWithoutSaveIndex() @@ -103,6 +105,7 @@ type ( poolSize uint32 cnt atomic.Uint64 prop C.NGTProperty + ces uint64 // NGT edge size for creation epool sync.Pool // NGT error buffer pool eps atomic.Uint64 // NGT error buffer pool size epl uint64 // NGT error buffer pool size limit @@ -116,6 +119,42 @@ type ( err C.NGTError destroyed atomic.Bool } + + GraphStatistics struct { + Valid bool + MedianIndegree int32 + MedianOutdegree int32 + MaxNumberOfIndegree uint64 + MaxNumberOfOutdegree uint64 + MinNumberOfIndegree uint64 + MinNumberOfOutdegree uint64 + ModeIndegree uint64 + ModeOutdegree uint64 + NodesSkippedFor10Edges uint64 + NodesSkippedForIndegreeDistance uint64 + NumberOfEdges uint64 + NumberOfIndexedObjects uint64 + NumberOfNodes uint64 + NumberOfNodesWithoutEdges uint64 + NumberOfNodesWithoutIndegree uint64 + NumberOfObjects uint64 + NumberOfRemovedObjects uint64 + SizeOfObjectRepository uint64 + SizeOfRefinementObjectRepository uint64 + VarianceOfIndegree float64 + VarianceOfOutdegree float64 + MeanEdgeLength float64 + MeanEdgeLengthFor10Edges float64 + MeanIndegreeDistanceFor10Edges float64 + MeanNumberOfEdgesPerNode float64 + C1Indegree float64 + C5Indegree float64 + C95Outdegree float64 + C99Outdegree float64 + IndegreeCount []int64 + OutdegreeHistogram []uint64 + IndegreeHistogram []uint64 + } ) func newNGTError() (n *ngtError) { @@ -142,6 +181,8 @@ type objectType int // DistanceType is alias of distance type in NGT. type distanceType int +type statisticsType int + const ( // ------------------------------------------------------------- // Object Type Definition @@ -195,6 +236,9 @@ const ( // -------------------------------------------------------------. ErrorCode = C._Bool(false) // -------------------------------------------------------------. + + NormalStatistics statisticsType = iota - 1 + AdditionalStatistics ) func (o objectType) String() string { @@ -304,7 +348,7 @@ func gen(isLoad bool, opts ...Option) (NGT, error) { func (n *ngt) setup() error { n.epool = sync.Pool{ - New: func() interface{} { + New: func() any { return newNGTError() }, } @@ -404,7 +448,9 @@ func (n *ngt) loadObjectSpace() error { } // Search returns search result as []algorithm.SearchResult. -func (n *ngt) Search(ctx context.Context, vec []float32, size int, epsilon, radius float32) (result []algorithm.SearchResult, err error) { +func (n *ngt) Search( + ctx context.Context, vec []float32, size int, epsilon, radius float32, +) (result []algorithm.SearchResult, err error) { if len(vec) != int(n.dimension) { return nil, errors.ErrIncompatibleDimensionSize(len(vec), int(n.dimension)) } @@ -476,7 +522,9 @@ func (n *ngt) Search(ctx context.Context, vec []float32, size int, epsilon, radi } // Linear Search returns linear search result as []algorithm.SearchResult. -func (n *ngt) LinearSearch(ctx context.Context, vec []float32, size int) (result []algorithm.SearchResult, err error) { +func (n *ngt) LinearSearch( + ctx context.Context, vec []float32, size int, +) (result []algorithm.SearchResult, err error) { if len(vec) != int(n.dimension) { return nil, errors.ErrIncompatibleDimensionSize(len(vec), int(n.dimension)) } @@ -852,3 +900,82 @@ func (n *ngt) Close() { n.ospace = nil } } + +func fromCGraphStatistics(cstats *C.NGTGraphStatistics) *GraphStatistics { + goStats := &GraphStatistics{ + NumberOfObjects: uint64(cstats.numberOfObjects), + NumberOfIndexedObjects: uint64(cstats.numberOfIndexedObjects), + SizeOfObjectRepository: uint64(cstats.sizeOfObjectRepository), + SizeOfRefinementObjectRepository: uint64(cstats.sizeOfRefinementObjectRepository), + NumberOfRemovedObjects: uint64(cstats.numberOfRemovedObjects), + NumberOfNodes: uint64(cstats.numberOfNodes), + NumberOfEdges: uint64(cstats.numberOfEdges), + MeanEdgeLength: float64(cstats.meanEdgeLength), + MeanNumberOfEdgesPerNode: float64(cstats.meanNumberOfEdgesPerNode), + NumberOfNodesWithoutEdges: uint64(cstats.numberOfNodesWithoutEdges), + MaxNumberOfOutdegree: uint64(cstats.maxNumberOfOutdegree), + MinNumberOfOutdegree: uint64(cstats.minNumberOfOutdegree), + NumberOfNodesWithoutIndegree: uint64(cstats.numberOfNodesWithoutIndegree), + MaxNumberOfIndegree: uint64(cstats.maxNumberOfIndegree), + MinNumberOfIndegree: uint64(cstats.minNumberOfIndegree), + MeanEdgeLengthFor10Edges: float64(cstats.meanEdgeLengthFor10Edges), + NodesSkippedFor10Edges: uint64(cstats.nodesSkippedFor10Edges), + MeanIndegreeDistanceFor10Edges: float64(cstats.meanIndegreeDistanceFor10Edges), + NodesSkippedForIndegreeDistance: uint64(cstats.nodesSkippedForIndegreeDistance), + VarianceOfOutdegree: float64(cstats.varianceOfOutdegree), + VarianceOfIndegree: float64(cstats.varianceOfIndegree), + MedianOutdegree: int32(cstats.medianOutdegree), + ModeOutdegree: uint64(cstats.modeOutdegree), + C95Outdegree: float64(cstats.c95Outdegree), + C99Outdegree: float64(cstats.c99Outdegree), + MedianIndegree: int32(cstats.medianIndegree), + ModeIndegree: uint64(cstats.modeIndegree), + C5Indegree: float64(cstats.c5Indegree), + C1Indegree: float64(cstats.c1Indegree), + Valid: bool(cstats.valid), + } + + // Convert indegreeCount + indegreeCountSize := int(cstats.indegreeCountSize) + goStats.IndegreeCount = make([]int64, indegreeCountSize) + cIndegreeCount := (*[1 << 30]C.size_t)(unsafe.Pointer(cstats.indegreeCount))[:indegreeCountSize:indegreeCountSize] + for i := 0; i < indegreeCountSize; i++ { + goStats.IndegreeCount[i] = int64(cIndegreeCount[i]) + } + + // Convert outdegreeHistogram + outdegreeHistogramSize := int(cstats.outdegreeHistogramSize) + goStats.OutdegreeHistogram = make([]uint64, outdegreeHistogramSize) + cOutdegreeHistogram := (*[1 << 30]C.size_t)(unsafe.Pointer(cstats.outdegreeHistogram))[:outdegreeHistogramSize:outdegreeHistogramSize] + for i := 0; i < outdegreeHistogramSize; i++ { + goStats.OutdegreeHistogram[i] = uint64(cOutdegreeHistogram[i]) + } + + // Convert indegreeHistogram + indegreeHistogramSize := int(cstats.indegreeHistogramSize) + goStats.IndegreeHistogram = make([]uint64, indegreeHistogramSize) + cIndegreeHistogram := (*[1 << 30]C.size_t)(unsafe.Pointer(cstats.indegreeHistogram))[:indegreeHistogramSize:indegreeHistogramSize] + for i := 0; i < indegreeHistogramSize; i++ { + goStats.IndegreeHistogram[i] = uint64(cIndegreeHistogram[i]) + } + + return goStats +} + +func (n *ngt) GetGraphStatistics(m statisticsType) (stats *GraphStatistics, err error) { + var mode rune + switch m { + case NormalStatistics: + mode = '-' + case AdditionalStatistics: + mode = 'a' + } + ne := n.GetErrorBuffer() + cstats := C.ngt_get_graph_statistics(n.index, C.char(mode), C.size_t(n.ces), ne.err) + if !cstats.valid { + return nil, n.newGoError(ne) + } + n.PutErrorBuffer(ne) + defer C.ngt_free_graph_statistics(&cstats) + return fromCGraphStatistics(&cstats), nil +} diff --git a/internal/core/algorithm/ngt/ngt_test.go b/internal/core/algorithm/ngt/ngt_test.go index 83ef76b23a..0186f2abed 100644 --- a/internal/core/algorithm/ngt/ngt_test.go +++ b/internal/core/algorithm/ngt/ngt_test.go @@ -138,6 +138,7 @@ func TestNew(t *testing.T) { epsilon: DefaultEpsilon, poolSize: DefaultPoolSize, bulkInsertChunkSize: 100, + ces: 10, objectType: Float, mu: &sync.RWMutex{}, cmu: &sync.RWMutex{}, @@ -161,6 +162,7 @@ func TestNew(t *testing.T) { want: want{ want: &ngt{ idxPath: idxPath, + ces: 10, radius: DefaultRadius, epsilon: DefaultEpsilon, poolSize: DefaultPoolSize, @@ -187,6 +189,7 @@ func TestNew(t *testing.T) { want: want{ want: &ngt{ idxPath: idxPath, + ces: 10, radius: DefaultRadius, epsilon: DefaultEpsilon, poolSize: 100, @@ -317,6 +320,7 @@ func TestLoad(t *testing.T) { want: want{ want: &ngt{ idxPath: idxPath, + ces: 10, radius: DefaultRadius, epsilon: DefaultEpsilon, poolSize: DefaultPoolSize, @@ -384,6 +388,7 @@ func TestLoad(t *testing.T) { want: want{ want: &ngt{ idxPath: idxPath, + ces: 10, radius: DefaultRadius, epsilon: DefaultEpsilon, poolSize: DefaultPoolSize, @@ -451,6 +456,7 @@ func TestLoad(t *testing.T) { want: want{ want: &ngt{ idxPath: idxPath, + ces: 10, radius: DefaultRadius, epsilon: DefaultEpsilon, poolSize: DefaultPoolSize, @@ -518,6 +524,7 @@ func TestLoad(t *testing.T) { want: want{ want: &ngt{ idxPath: idxPath, + ces: 10, radius: DefaultRadius, epsilon: DefaultEpsilon, poolSize: DefaultPoolSize, @@ -715,6 +722,7 @@ func Test_gen(t *testing.T) { want: want{ want: &ngt{ idxPath: "/tmp/ngt-", + ces: 10, radius: DefaultRadius, epsilon: DefaultEpsilon, poolSize: DefaultPoolSize, @@ -762,6 +770,7 @@ func Test_gen(t *testing.T) { }, want: want{ want: &ngt{ + ces: 10, idxPath: idxPath, radius: DefaultRadius, epsilon: DefaultEpsilon, diff --git a/internal/core/algorithm/ngt/option.go b/internal/core/algorithm/ngt/option.go index c9ce2484b3..5e622ec54a 100644 --- a/internal/core/algorithm/ngt/option.go +++ b/internal/core/algorithm/ngt/option.go @@ -269,6 +269,9 @@ func WithObjectType(t objectType) Option { // WithCreationEdgeSize represents the option to set the creation edge size for NGT. func WithCreationEdgeSize(size int) Option { return func(n *ngt) error { + if size > 0 { + n.ces = uint64(size) + } ne := n.GetErrorBuffer() if C.ngt_set_property_edge_size_for_creation(n.prop, C.int16_t(size), ne.err) == ErrorCode { err := errors.ErrFailedToSetCreationEdgeSize(n.newGoError(ne)) diff --git a/internal/core/algorithm/ngt/option_test.go b/internal/core/algorithm/ngt/option_test.go index b6808550c2..444bec4ac3 100644 --- a/internal/core/algorithm/ngt/option_test.go +++ b/internal/core/algorithm/ngt/option_test.go @@ -1142,7 +1142,9 @@ func TestWithCreationEdgeSize(t *testing.T) { size: 0, }, want: want{ - obj: new(T), + obj: &ngt{ + ces: 0, + }, }, }, { @@ -1151,7 +1153,9 @@ func TestWithCreationEdgeSize(t *testing.T) { size: 1, }, want: want{ - obj: new(T), + obj: &ngt{ + ces: 1, + }, }, }, { @@ -1160,7 +1164,9 @@ func TestWithCreationEdgeSize(t *testing.T) { size: -1, }, want: want{ - obj: new(T), + obj: &ngt{ + ces: 0, + }, }, }, { @@ -1169,7 +1175,9 @@ func TestWithCreationEdgeSize(t *testing.T) { size: math.MinInt64, }, want: want{ - obj: new(T), + obj: &ngt{ + ces: 0, + }, }, }, { @@ -1178,7 +1186,9 @@ func TestWithCreationEdgeSize(t *testing.T) { size: math.MaxInt64, }, want: want{ - obj: new(T), + obj: &ngt{ + ces: math.MaxInt64, + }, }, }, } diff --git a/internal/db/kvs/bbolt/bbolt_test.go b/internal/db/kvs/bbolt/bbolt_test.go index 77c712a6c7..ad29b96c1a 100644 --- a/internal/db/kvs/bbolt/bbolt_test.go +++ b/internal/db/kvs/bbolt/bbolt_test.go @@ -317,7 +317,6 @@ func Test_bbolt_AsyncSet(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -432,7 +431,6 @@ func Test_bbolt_AsyncSet(t *testing.T) { // if err := checkFunc(test.want, gotVal, gotOk, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -539,7 +537,6 @@ func Test_bbolt_AsyncSet(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/kvs/bbolt/option_test.go b/internal/db/kvs/bbolt/option_test.go index 29d28e1419..102f4fbeb4 100644 --- a/internal/db/kvs/bbolt/option_test.go +++ b/internal/db/kvs/bbolt/option_test.go @@ -96,7 +96,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -440,7 +436,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +521,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -612,7 +606,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -698,7 +691,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -784,7 +776,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -870,7 +861,6 @@ package bbolt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/kvs/pogreb/pogreb.go b/internal/db/kvs/pogreb/pogreb.go index d2dc8854bd..26e7cc1da0 100644 --- a/internal/db/kvs/pogreb/pogreb.go +++ b/internal/db/kvs/pogreb/pogreb.go @@ -19,7 +19,6 @@ import ( "reflect" "github.com/akrylysov/pogreb" - "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" diff --git a/internal/db/kvs/pogreb/pogreb_test.go b/internal/db/kvs/pogreb/pogreb_test.go index ac4dda8a82..14b14c5650 100644 --- a/internal/db/kvs/pogreb/pogreb_test.go +++ b/internal/db/kvs/pogreb/pogreb_test.go @@ -582,7 +582,6 @@ func Test_db_Len(t *testing.T) { // NOT IMPLEMENTED BELOW // -// // func Test_db_Set(t *testing.T) { // type args struct { // key string @@ -688,7 +687,6 @@ func Test_db_Len(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -795,7 +793,6 @@ func Test_db_Len(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/kvs/redis/hook.go b/internal/db/kvs/redis/hook.go index 233bfa3504..1543da2e99 100644 --- a/internal/db/kvs/redis/hook.go +++ b/internal/db/kvs/redis/hook.go @@ -16,9 +16,7 @@ package redis -import ( - redis "github.com/go-redis/redis/v8" -) +import redis "github.com/go-redis/redis/v8" type ( Hook = redis.Hook diff --git a/internal/db/kvs/redis/list.go b/internal/db/kvs/redis/list.go index c78823b211..7c713a3e12 100644 --- a/internal/db/kvs/redis/list.go +++ b/internal/db/kvs/redis/list.go @@ -16,4 +16,4 @@ package redis -type Lister interface{} +type Lister any diff --git a/internal/db/kvs/redis/option_test.go b/internal/db/kvs/redis/option_test.go index 55f8ae42cb..1ae93dd212 100644 --- a/internal/db/kvs/redis/option_test.go +++ b/internal/db/kvs/redis/option_test.go @@ -2443,7 +2443,6 @@ func TestWithHooks(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2529,7 +2528,6 @@ func TestWithHooks(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2615,7 +2613,6 @@ func TestWithHooks(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2701,7 +2698,6 @@ func TestWithHooks(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2787,7 +2783,6 @@ func TestWithHooks(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/kvs/redis/set.go b/internal/db/kvs/redis/set.go index 19b164418b..4ed9a3fb92 100644 --- a/internal/db/kvs/redis/set.go +++ b/internal/db/kvs/redis/set.go @@ -16,6 +16,4 @@ package redis -type Setter interface { // Set(string, string) *redis.StringCmd - // MSet(map[string]string) *redis.StringCmd -} +type Setter any diff --git a/internal/db/nosql/cassandra/observer.go b/internal/db/nosql/cassandra/observer.go index 46780e6a7c..0682f2f1d5 100644 --- a/internal/db/nosql/cassandra/observer.go +++ b/internal/db/nosql/cassandra/observer.go @@ -16,9 +16,7 @@ package cassandra -import ( - "github.com/gocql/gocql" -) +import "github.com/gocql/gocql" type ( QueryObserver = gocql.QueryObserver diff --git a/internal/db/rdb/mysql/dbr/dbr.go b/internal/db/rdb/mysql/dbr/dbr.go index bc65093794..e123403154 100644 --- a/internal/db/rdb/mysql/dbr/dbr.go +++ b/internal/db/rdb/mysql/dbr/dbr.go @@ -16,14 +16,12 @@ package dbr -import ( - dbr "github.com/gocraft/dbr/v2" -) +import dbr "github.com/gocraft/dbr/v2" // DBR repreesnts the interface to create connection to MySQL. type DBR interface { Open(driver, dsn string, log EventReceiver) (Connection, error) - Eq(col string, val interface{}) Builder + Eq(col string, val any) Builder } type ( @@ -57,6 +55,6 @@ func (*db) Open(driver, dsn string, log EventReceiver) (Connection, error) { } // Eq returns the built SQL statement made from col name and the value. -func (*db) Eq(col string, val interface{}) Builder { +func (*db) Eq(col string, val any) Builder { return dbr.Eq(col, val) } diff --git a/internal/db/rdb/mysql/dbr/dbr_mock.go b/internal/db/rdb/mysql/dbr/dbr_mock.go index 636b9fb64d..2cad19ccc3 100644 --- a/internal/db/rdb/mysql/dbr/dbr_mock.go +++ b/internal/db/rdb/mysql/dbr/dbr_mock.go @@ -24,14 +24,14 @@ import ( type MockDBR struct { OpenFunc func(driver, dsn string, log EventReceiver) (Connection, error) - EqFunc func(col string, val interface{}) Builder + EqFunc func(col string, val any) Builder } func (d *MockDBR) Open(driver, dsn string, log EventReceiver) (Connection, error) { return d.OpenFunc(driver, dsn, log) } -func (d *MockDBR) Eq(col string, val interface{}) Builder { +func (d *MockDBR) Eq(col string, val any) Builder { return d.EqFunc(col, val) } @@ -62,7 +62,7 @@ type MockTx struct { CommitFunc func() error RollbackFunc func() error RollbackUnlessCommittedFunc func() - InsertBySqlFunc func(query string, value ...interface{}) InsertStmt + InsertBySqlFunc func(query string, value ...any) InsertStmt InsertIntoFunc func(table string) InsertStmt SelectFunc func(column ...string) SelectStmt DeleteFromFunc func(table string) DeleteStmt @@ -80,7 +80,7 @@ func (t *MockTx) RollbackUnlessCommitted() { t.RollbackUnlessCommittedFunc() } -func (t *MockTx) InsertBySql(query string, value ...interface{}) InsertStmt { +func (t *MockTx) InsertBySql(query string, value ...any) InsertStmt { return t.InsertBySqlFunc(query, value...) } @@ -120,17 +120,17 @@ func (c *MockConn) SetMaxOpenConns(n int) { } type MockSelect struct { - FromFunc func(table interface{}) SelectStmt - WhereFunc func(query interface{}, value ...interface{}) SelectStmt + FromFunc func(table any) SelectStmt + WhereFunc func(query any, value ...any) SelectStmt LimitFunc func(n uint64) SelectStmt - LoadContextFunc func(ctx context.Context, value interface{}) (int, error) + LoadContextFunc func(ctx context.Context, value any) (int, error) } -func (s *MockSelect) From(table interface{}) SelectStmt { +func (s *MockSelect) From(table any) SelectStmt { return s.FromFunc(table) } -func (s *MockSelect) Where(query interface{}, value ...interface{}) SelectStmt { +func (s *MockSelect) Where(query any, value ...any) SelectStmt { return s.WhereFunc(query, value...) } @@ -138,14 +138,14 @@ func (s *MockSelect) Limit(n uint64) SelectStmt { return s.LimitFunc(n) } -func (s *MockSelect) LoadContext(ctx context.Context, value interface{}) (int, error) { +func (s *MockSelect) LoadContext(ctx context.Context, value any) (int, error) { return s.LoadContextFunc(ctx, value) } type MockInsert struct { ColumnsFunc func(column ...string) InsertStmt ExecContextFunc func(ctx context.Context) (sql.Result, error) - RecordFunc func(structValue interface{}) InsertStmt + RecordFunc func(structValue any) InsertStmt } func (s *MockInsert) Columns(column ...string) InsertStmt { @@ -156,19 +156,19 @@ func (s *MockInsert) ExecContext(ctx context.Context) (sql.Result, error) { return s.ExecContextFunc(ctx) } -func (s *MockInsert) Record(structValue interface{}) InsertStmt { +func (s *MockInsert) Record(structValue any) InsertStmt { return s.RecordFunc(structValue) } type MockDelete struct { ExecContextFunc func(ctx context.Context) (sql.Result, error) - WhereFunc func(query interface{}, value ...interface{}) DeleteStmt + WhereFunc func(query any, value ...any) DeleteStmt } func (s *MockDelete) ExecContext(ctx context.Context) (sql.Result, error) { return s.ExecContextFunc(ctx) } -func (s *MockDelete) Where(query interface{}, value ...interface{}) DeleteStmt { +func (s *MockDelete) Where(query any, value ...any) DeleteStmt { return s.WhereFunc(query, value...) } diff --git a/internal/db/rdb/mysql/dbr/delete.go b/internal/db/rdb/mysql/dbr/delete.go index f04e470029..fc7307be83 100644 --- a/internal/db/rdb/mysql/dbr/delete.go +++ b/internal/db/rdb/mysql/dbr/delete.go @@ -26,7 +26,7 @@ import ( // DeleteStmt represents the interface to execute delete data. type DeleteStmt interface { ExecContext(ctx context.Context) (sql.Result, error) - Where(query interface{}, value ...interface{}) DeleteStmt + Where(query any, value ...any) DeleteStmt } type deleteStmt struct { @@ -39,7 +39,7 @@ func (stmt *deleteStmt) ExecContext(ctx context.Context) (sql.Result, error) { } // Where adds a where condition. -func (stmt *deleteStmt) Where(query interface{}, value ...interface{}) DeleteStmt { +func (stmt *deleteStmt) Where(query any, value ...any) DeleteStmt { stmt.DeleteStmt = stmt.DeleteStmt.Where(query, value...) return stmt } diff --git a/internal/db/rdb/mysql/dbr/insert.go b/internal/db/rdb/mysql/dbr/insert.go index 5f60464b6c..8d96e916c8 100644 --- a/internal/db/rdb/mysql/dbr/insert.go +++ b/internal/db/rdb/mysql/dbr/insert.go @@ -27,7 +27,7 @@ import ( type InsertStmt interface { Columns(column ...string) InsertStmt ExecContext(ctx context.Context) (sql.Result, error) - Record(structValue interface{}) InsertStmt + Record(structValue any) InsertStmt } type insertStmt struct { @@ -46,7 +46,7 @@ func (stmt *insertStmt) ExecContext(ctx context.Context) (sql.Result, error) { } // Record adds a tuple for columns from a struct. -func (stmt *insertStmt) Record(structValue interface{}) InsertStmt { +func (stmt *insertStmt) Record(structValue any) InsertStmt { stmt.InsertStmt = stmt.InsertStmt.Record(structValue) return stmt } diff --git a/internal/db/rdb/mysql/dbr/select.go b/internal/db/rdb/mysql/dbr/select.go index 01e9370352..56b0cd1d16 100644 --- a/internal/db/rdb/mysql/dbr/select.go +++ b/internal/db/rdb/mysql/dbr/select.go @@ -24,10 +24,10 @@ import ( // SelectStmt represents the interface to get data from database. type SelectStmt interface { - From(table interface{}) SelectStmt - Where(query interface{}, value ...interface{}) SelectStmt + From(table any) SelectStmt + Where(query any, value ...any) SelectStmt Limit(n uint64) SelectStmt - LoadContext(ctx context.Context, value interface{}) (int, error) + LoadContext(ctx context.Context, value any) (int, error) } type selectStmt struct { @@ -35,13 +35,13 @@ type selectStmt struct { } // From specifies table to select from. -func (stmt *selectStmt) From(table interface{}) SelectStmt { +func (stmt *selectStmt) From(table any) SelectStmt { stmt.SelectStmt = stmt.SelectStmt.From(table) return stmt } // Where adds a where condition. -func (stmt *selectStmt) Where(query interface{}, value ...interface{}) SelectStmt { +func (stmt *selectStmt) Where(query any, value ...any) SelectStmt { stmt.SelectStmt = stmt.SelectStmt.Where(query, value...) return stmt } @@ -53,6 +53,6 @@ func (stmt *selectStmt) Limit(n uint64) SelectStmt { } // LoadContext gets the result of select. -func (stmt *selectStmt) LoadContext(ctx context.Context, value interface{}) (int, error) { +func (stmt *selectStmt) LoadContext(ctx context.Context, value any) (int, error) { return stmt.SelectStmt.LoadContext(ctx, value) } diff --git a/internal/db/rdb/mysql/dbr/tx.go b/internal/db/rdb/mysql/dbr/tx.go index 5c88971ac0..ce5dc2d02d 100644 --- a/internal/db/rdb/mysql/dbr/tx.go +++ b/internal/db/rdb/mysql/dbr/tx.go @@ -16,16 +16,14 @@ package dbr -import ( - dbr "github.com/gocraft/dbr/v2" -) +import dbr "github.com/gocraft/dbr/v2" // Tx represents the interface to handle transaction. type Tx interface { Commit() error Rollback() error RollbackUnlessCommitted() - InsertBySql(query string, value ...interface{}) InsertStmt + InsertBySql(query string, value ...any) InsertStmt InsertInto(table string) InsertStmt Select(column ...string) SelectStmt DeleteFrom(table string) DeleteStmt @@ -51,7 +49,7 @@ func (t *tx) RollbackUnlessCommitted() { } // InsertBySql creates an InsertStmt from raw query. -func (t *tx) InsertBySql(query string, value ...interface{}) InsertStmt { +func (t *tx) InsertBySql(query string, value ...any) InsertStmt { return &insertStmt{ t.Tx.InsertBySql(query, value...), } diff --git a/internal/db/rdb/mysql/mysql_test.go b/internal/db/rdb/mysql/mysql_test.go index 94d7463355..c741df72cd 100644 --- a/internal/db/rdb/mysql/mysql_test.go +++ b/internal/db/rdb/mysql/mysql_test.go @@ -799,16 +799,16 @@ func Test_mySQLClient_GetVector(t *testing.T) { session: &dbr.MockSession{ SelectFunc: func(column ...string) dbr.SelectStmt { m := new(dbr.MockSelect) - m.FromFunc = func(table interface{}) dbr.SelectStmt { + m.FromFunc = func(table any) dbr.SelectStmt { return m } - m.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + m.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return m } m.LimitFunc = func(n uint64) dbr.SelectStmt { return m } - m.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + m.LoadContextFunc = func(ctx context.Context, value any) (int, error) { return 0, err } return m @@ -819,7 +819,7 @@ func Test_mySQLClient_GetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -841,16 +841,16 @@ func Test_mySQLClient_GetVector(t *testing.T) { session: &dbr.MockSession{ SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var d *data if reflect.TypeOf(value) == reflect.TypeOf(&d) { return 1, nil @@ -865,7 +865,7 @@ func Test_mySQLClient_GetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -892,16 +892,16 @@ func Test_mySQLClient_GetVector(t *testing.T) { session: &dbr.MockSession{ SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var mv *data var pp []podIP if reflect.TypeOf(value) == reflect.TypeOf(&mv) { @@ -921,7 +921,7 @@ func Test_mySQLClient_GetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -954,16 +954,16 @@ func Test_mySQLClient_GetVector(t *testing.T) { session: &dbr.MockSession{ SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var mv *data var pp []podIP if reflect.TypeOf(value) == reflect.TypeOf(&mv) { @@ -985,7 +985,7 @@ func Test_mySQLClient_GetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -1112,16 +1112,16 @@ func Test_mySQLClient_GetIPs(t *testing.T) { session: &dbr.MockSession{ SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { return 0, err @@ -1136,7 +1136,7 @@ func Test_mySQLClient_GetIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -1158,16 +1158,16 @@ func Test_mySQLClient_GetIPs(t *testing.T) { session: &dbr.MockSession{ SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { return 0, nil @@ -1182,7 +1182,7 @@ func Test_mySQLClient_GetIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -1215,16 +1215,16 @@ func Test_mySQLClient_GetIPs(t *testing.T) { session: &dbr.MockSession{ SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 var pp []podIP if reflect.TypeOf(value) == reflect.TypeOf(&id) { @@ -1244,7 +1244,7 @@ func Test_mySQLClient_GetIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -1280,16 +1280,16 @@ func Test_mySQLClient_GetIPs(t *testing.T) { session: &dbr.MockSession{ SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 var pp []podIP if reflect.TypeOf(value) == reflect.TypeOf(&id) { @@ -1311,7 +1311,7 @@ func Test_mySQLClient_GetIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -1560,7 +1560,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, err @@ -1598,7 +1598,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -1607,16 +1607,16 @@ func Test_mySQLClient_SetVector(t *testing.T) { } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { return 0, err } return s @@ -1629,7 +1629,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -1656,7 +1656,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -1665,16 +1665,16 @@ func Test_mySQLClient_SetVector(t *testing.T) { } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m.podIPs)) @@ -1693,7 +1693,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -1727,7 +1727,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -1736,16 +1736,16 @@ func Test_mySQLClient_SetVector(t *testing.T) { } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m.podIPs)) @@ -1761,7 +1761,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, err } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -1775,7 +1775,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -1809,7 +1809,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -1824,23 +1824,23 @@ func Test_mySQLClient_SetVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, err } - s.RecordFunc = func(structValue interface{}) dbr.InsertStmt { + s.RecordFunc = func(structValue any) dbr.InsertStmt { return s } return s } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m.podIPs)) @@ -1856,7 +1856,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -1870,7 +1870,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -1907,7 +1907,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -1922,23 +1922,23 @@ func Test_mySQLClient_SetVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.RecordFunc = func(structValue interface{}) dbr.InsertStmt { + s.RecordFunc = func(structValue any) dbr.InsertStmt { return s } return s } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m.podIPs)) @@ -1954,7 +1954,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -1968,7 +1968,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -2004,7 +2004,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -2019,23 +2019,23 @@ func Test_mySQLClient_SetVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.RecordFunc = func(structValue interface{}) dbr.InsertStmt { + s.RecordFunc = func(structValue any) dbr.InsertStmt { return s } return s } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m.podIPs)) @@ -2051,7 +2051,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -2065,7 +2065,7 @@ func Test_mySQLClient_SetVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -2245,7 +2245,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, err @@ -2285,7 +2285,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, err @@ -2294,16 +2294,16 @@ func Test_mySQLClient_SetVectors(t *testing.T) { } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { return 0, err } return s @@ -2316,7 +2316,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -2345,7 +2345,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -2354,16 +2354,16 @@ func Test_mySQLClient_SetVectors(t *testing.T) { } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m[0].GetIPs())) @@ -2382,7 +2382,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -2419,7 +2419,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -2428,16 +2428,16 @@ func Test_mySQLClient_SetVectors(t *testing.T) { } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m[0].GetIPs())) @@ -2453,7 +2453,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, err } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -2467,7 +2467,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -2503,7 +2503,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -2518,23 +2518,23 @@ func Test_mySQLClient_SetVectors(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, err } - s.RecordFunc = func(structValue interface{}) dbr.InsertStmt { + s.RecordFunc = func(structValue any) dbr.InsertStmt { return s } return s } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m[0].GetIPs())) @@ -2550,7 +2550,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -2564,7 +2564,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -2603,7 +2603,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -2618,23 +2618,23 @@ func Test_mySQLClient_SetVectors(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.RecordFunc = func(structValue interface{}) dbr.InsertStmt { + s.RecordFunc = func(structValue any) dbr.InsertStmt { return s } return s } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m[0].GetIPs())) @@ -2650,7 +2650,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -2664,7 +2664,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -2702,7 +2702,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return nil } tx.RollbackUnlessCommittedFunc = func() {} - tx.InsertBySqlFunc = func(query string, value ...interface{}) dbr.InsertStmt { + tx.InsertBySqlFunc = func(query string, value ...any) dbr.InsertStmt { return &dbr.MockInsert{ ExecContextFunc: func(ctx context.Context) (sql.Result, error) { return nil, nil @@ -2717,23 +2717,23 @@ func Test_mySQLClient_SetVectors(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.RecordFunc = func(structValue interface{}) dbr.InsertStmt { + s.RecordFunc = func(structValue any) dbr.InsertStmt { return s } return s } tx.SelectFunc = func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = int64(len(m[0].GetIPs())) @@ -2749,7 +2749,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -2763,7 +2763,7 @@ func Test_mySQLClient_SetVectors(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -2847,16 +2847,16 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id := int64(1) @@ -2873,7 +2873,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -2886,7 +2886,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -2911,16 +2911,16 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id := int64(1) @@ -2937,7 +2937,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -2950,7 +2950,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3061,16 +3061,16 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { return 0, err } @@ -3084,7 +3084,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3113,16 +3113,16 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { return 0, nil } @@ -3136,7 +3136,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3164,16 +3164,16 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id := int64(1) @@ -3193,7 +3193,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { } return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -3206,7 +3206,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3234,16 +3234,16 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id := int64(1) @@ -3263,7 +3263,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { } return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -3276,7 +3276,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3303,16 +3303,16 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id := int64(1) @@ -3329,7 +3329,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -3342,7 +3342,7 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3426,16 +3426,16 @@ func Test_mySQLClient_DeleteVectors(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id := int64(1) @@ -3452,7 +3452,7 @@ func Test_mySQLClient_DeleteVectors(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -3465,7 +3465,7 @@ func Test_mySQLClient_DeleteVectors(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3493,16 +3493,16 @@ func Test_mySQLClient_DeleteVectors(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id := int64(1) @@ -3519,7 +3519,7 @@ func Test_mySQLClient_DeleteVectors(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -3532,7 +3532,7 @@ func Test_mySQLClient_DeleteVectors(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3695,16 +3695,16 @@ func Test_mySQLClient_SetIPs(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = 1 @@ -3723,7 +3723,7 @@ func Test_mySQLClient_SetIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3754,16 +3754,16 @@ func Test_mySQLClient_SetIPs(t *testing.T) { RollbackUnlessCommittedFunc: func() {}, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { reflect.ValueOf(value).Elem().Set(reflect.ValueOf(id)) @@ -3781,7 +3781,7 @@ func Test_mySQLClient_SetIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3819,23 +3819,23 @@ func Test_mySQLClient_SetIPs(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, err } - s.RecordFunc = func(structValue interface{}) dbr.InsertStmt { + s.RecordFunc = func(structValue any) dbr.InsertStmt { return s } return s }, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = 1 @@ -3854,7 +3854,7 @@ func Test_mySQLClient_SetIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -3891,23 +3891,23 @@ func Test_mySQLClient_SetIPs(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.RecordFunc = func(structValue interface{}) dbr.InsertStmt { + s.RecordFunc = func(structValue any) dbr.InsertStmt { return s } return s }, SelectFunc: func(column ...string) dbr.SelectStmt { s := new(dbr.MockSelect) - s.FromFunc = func(table interface{}) dbr.SelectStmt { + s.FromFunc = func(table any) dbr.SelectStmt { return s } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.SelectStmt { + s.WhereFunc = func(query any, value ...any) dbr.SelectStmt { return s } s.LimitFunc = func(n uint64) dbr.SelectStmt { return s } - s.LoadContextFunc = func(ctx context.Context, value interface{}) (int, error) { + s.LoadContextFunc = func(ctx context.Context, value any) (int, error) { var id int64 if reflect.TypeOf(value) == reflect.TypeOf(&id) { id = 1 @@ -3926,7 +3926,7 @@ func Test_mySQLClient_SetIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -4087,7 +4087,7 @@ func Test_mySQLClient_RemoveIPs(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, err } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -4100,7 +4100,7 @@ func Test_mySQLClient_RemoveIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -4133,7 +4133,7 @@ func Test_mySQLClient_RemoveIPs(t *testing.T) { s.ExecContextFunc = func(ctx context.Context) (sql.Result, error) { return nil, nil } - s.WhereFunc = func(query interface{}, value ...interface{}) dbr.DeleteStmt { + s.WhereFunc = func(query any, value ...any) dbr.DeleteStmt { return s } return s @@ -4146,7 +4146,7 @@ func Test_mySQLClient_RemoveIPs(t *testing.T) { return }(), dbr: &dbr.MockDBR{ - EqFunc: func(col string, val interface{}) dbr.Builder { + EqFunc: func(col string, val any) dbr.Builder { return dbr.New().Eq(col, val) }, }, @@ -4214,8 +4214,7 @@ func Test_mySQLClient_RemoveIPs(t *testing.T) { // eventReceiver EventReceiver // dbr dbr.DBR // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/internal/db/rdb/mysql/option_test.go b/internal/db/rdb/mysql/option_test.go index 6072128524..fd315216b7 100644 --- a/internal/db/rdb/mysql/option_test.go +++ b/internal/db/rdb/mysql/option_test.go @@ -1416,7 +1416,6 @@ func TestWithEventReceiver(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1502,7 +1501,6 @@ func TestWithEventReceiver(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/storage/blob/cloudstorage/cloudstorage_test.go b/internal/db/storage/blob/cloudstorage/cloudstorage_test.go index 5ced13b102..2946721686 100644 --- a/internal/db/storage/blob/cloudstorage/cloudstorage_test.go +++ b/internal/db/storage/blob/cloudstorage/cloudstorage_test.go @@ -100,7 +100,6 @@ package cloudstorage // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -215,7 +214,6 @@ package cloudstorage // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -320,7 +318,6 @@ package cloudstorage // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -442,7 +439,6 @@ package cloudstorage // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -564,7 +560,6 @@ package cloudstorage // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/storage/blob/cloudstorage/option.go b/internal/db/storage/blob/cloudstorage/option.go index 575265a41c..28ccb2a056 100644 --- a/internal/db/storage/blob/cloudstorage/option.go +++ b/internal/db/storage/blob/cloudstorage/option.go @@ -50,7 +50,7 @@ func WithURLOpener(uo *gcsblob.URLOpener) Option { } // WithBeforeRead returns Option that sets c.readerOpts.BeforeRead. -func WithBeforeRead(fn func(asFunc func(interface{}) bool) error) Option { +func WithBeforeRead(fn func(asFunc func(any) bool) error) Option { return func(c *client) error { if fn != nil { if c.readerOpts == nil { @@ -167,7 +167,7 @@ func WithWriteMetadata(meta map[string]string) Option { } // WithBeforeWrite returns Option that sets c.writeOpts.BeforeWrite. -func WithBeforeWrite(f func(asFunc func(interface{}) bool) error) Option { +func WithBeforeWrite(f func(asFunc func(any) bool) error) Option { return func(c *client) error { if f != nil { if c.writerOpts == nil { diff --git a/internal/db/storage/blob/cloudstorage/option_test.go b/internal/db/storage/blob/cloudstorage/option_test.go index b7653f0908..9bea224737 100644 --- a/internal/db/storage/blob/cloudstorage/option_test.go +++ b/internal/db/storage/blob/cloudstorage/option_test.go @@ -96,7 +96,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,14 +181,13 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func TestWithBeforeRead(t *testing.T) { // type args struct { -// fn func(asFunc func(interface{}) bool) error +// fn func(asFunc func(any) bool) error // } // type want struct { // want Option @@ -268,7 +266,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -440,7 +436,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +521,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -612,7 +606,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -698,7 +691,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -784,7 +776,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -870,7 +861,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -956,14 +946,13 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func TestWithBeforeWrite(t *testing.T) { // type args struct { -// f func(asFunc func(interface{}) bool) error +// f func(asFunc func(any) bool) error // } // type want struct { // want Option @@ -1042,7 +1031,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/storage/blob/cloudstorage/urlopener/option.go b/internal/db/storage/blob/cloudstorage/urlopener/option.go index e962a50fff..f58bd2d822 100644 --- a/internal/db/storage/blob/cloudstorage/urlopener/option.go +++ b/internal/db/storage/blob/cloudstorage/urlopener/option.go @@ -13,9 +13,7 @@ // limitations under the License. package urlopener -import ( - "net/http" -) +import "net/http" type Option func(*urlOpener) error diff --git a/internal/db/storage/blob/cloudstorage/urlopener/option_test.go b/internal/db/storage/blob/cloudstorage/urlopener/option_test.go index da56deb00b..a54fcf31d0 100644 --- a/internal/db/storage/blob/cloudstorage/urlopener/option_test.go +++ b/internal/db/storage/blob/cloudstorage/urlopener/option_test.go @@ -96,7 +96,6 @@ package urlopener // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package urlopener // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package urlopener // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/storage/blob/cloudstorage/urlopener/urlopener_test.go b/internal/db/storage/blob/cloudstorage/urlopener/urlopener_test.go index 4e9b1756c9..92d71a1111 100644 --- a/internal/db/storage/blob/cloudstorage/urlopener/urlopener_test.go +++ b/internal/db/storage/blob/cloudstorage/urlopener/urlopener_test.go @@ -100,7 +100,6 @@ package urlopener // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -211,7 +210,6 @@ package urlopener // if err := checkFunc(test.want, gotGuo, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/storage/blob/s3/reader/io/io.go b/internal/db/storage/blob/s3/reader/io/io.go index c4acc67e73..b03da989a3 100644 --- a/internal/db/storage/blob/s3/reader/io/io.go +++ b/internal/db/storage/blob/s3/reader/io/io.go @@ -38,6 +38,8 @@ func (*ctxio) NewReaderWithContext(ctx context.Context, r io.Reader) (io.Reader, } // NewReadCloserWithContext calls io.NewReadCloserWithContext. -func (*ctxio) NewReadCloserWithContext(ctx context.Context, r io.ReadCloser) (io.ReadCloser, error) { +func (*ctxio) NewReadCloserWithContext( + ctx context.Context, r io.ReadCloser, +) (io.ReadCloser, error) { return io.NewReadCloserWithContext(ctx, r) } diff --git a/internal/db/storage/blob/s3/reader/io/io_test.go b/internal/db/storage/blob/s3/reader/io/io_test.go index 6ce35e4486..950e8bb34e 100644 --- a/internal/db/storage/blob/s3/reader/io/io_test.go +++ b/internal/db/storage/blob/s3/reader/io/io_test.go @@ -86,7 +86,6 @@ package io // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -181,7 +180,6 @@ package io // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -276,7 +274,6 @@ package io // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/db/storage/blob/s3/reader/reader.go b/internal/db/storage/blob/s3/reader/reader.go index 937d890c5d..3c994a8455 100644 --- a/internal/db/storage/blob/s3/reader/reader.go +++ b/internal/db/storage/blob/s3/reader/reader.go @@ -140,11 +140,13 @@ func (r *reader) Open(ctx context.Context, key string) (err error) { return nil } -func (r *reader) getObjectWithBackoff(ctx context.Context, key string, offset, length int64) (res io.Reader, err error) { +func (r *reader) getObjectWithBackoff( + ctx context.Context, key string, offset, length int64, +) (res io.Reader, err error) { if !r.backoffEnabled || r.bo == nil { return r.getObject(ctx, key, offset, length) } - _, err = r.bo.Do(ctx, func(ctx context.Context) (interface{}, bool, error) { + _, err = r.bo.Do(ctx, func(ctx context.Context) (any, bool, error) { res, err = r.getObject(ctx, key, offset, length) if err != nil { if errors.As(err, &errBlobNoSuchBucket) || @@ -162,7 +164,9 @@ func (r *reader) getObjectWithBackoff(ctx context.Context, key string, offset, l return res, nil } -func (r *reader) getObject(ctx context.Context, key string, offset, length int64) (io.Reader, error) { +func (r *reader) getObject( + ctx context.Context, key string, offset, length int64, +) (io.Reader, error) { rng := aws.String("bytes=" + strconv.FormatInt(offset, 10) + "-" + strconv.FormatInt(offset+length-1, 10)) log.Debugf("reading %s", *rng) resp, err := r.service.GetObjectWithContext( diff --git a/internal/db/storage/blob/s3/reader/reader_mock.go b/internal/db/storage/blob/s3/reader/reader_mock.go index 6a3bebdaf5..cc4af2bae3 100644 --- a/internal/db/storage/blob/s3/reader/reader_mock.go +++ b/internal/db/storage/blob/s3/reader/reader_mock.go @@ -35,7 +35,9 @@ type MockS3API struct { } // GetObjectWithContext calls GetObjectWithContextFunc. -func (m *MockS3API) GetObjectWithContext(ctx aws.Context, in *s3.GetObjectInput, opts ...request.Option) (*s3.GetObjectOutput, error) { +func (m *MockS3API) GetObjectWithContext( + ctx aws.Context, in *s3.GetObjectInput, opts ...request.Option, +) (*s3.GetObjectOutput, error) { return m.GetObjectWithContextFunc(ctx, in, opts...) } @@ -51,7 +53,9 @@ func (m *MockIO) NewReaderWithContext(ctx context.Context, r io.Reader) (io.Read } // NewReadCloserWithContext calls NewReadCloserWithContextFunc. -func (m *MockIO) NewReadCloserWithContext(ctx context.Context, r io.ReadCloser) (io.ReadCloser, error) { +func (m *MockIO) NewReadCloserWithContext( + ctx context.Context, r io.ReadCloser, +) (io.ReadCloser, error) { return m.NewReadCloserWithContextFunc(ctx, r) } diff --git a/internal/db/storage/blob/s3/sdk/s3/s3.go b/internal/db/storage/blob/s3/sdk/s3/s3.go index 01ca3e5153..fea202bcf6 100644 --- a/internal/db/storage/blob/s3/sdk/s3/s3.go +++ b/internal/db/storage/blob/s3/sdk/s3/s3.go @@ -13,9 +13,7 @@ // limitations under the License. package s3 -import ( - "github.com/aws/aws-sdk-go/service/s3" -) +import "github.com/aws/aws-sdk-go/service/s3" type ( // S3 is type alias for s3.S3. diff --git a/internal/db/storage/blob/s3/writer/writer_mock.go b/internal/db/storage/blob/s3/writer/writer_mock.go index 5b20fc9062..b6b61f6749 100644 --- a/internal/db/storage/blob/s3/writer/writer_mock.go +++ b/internal/db/storage/blob/s3/writer/writer_mock.go @@ -49,7 +49,9 @@ type MockS3Manager struct { } // NewUploaderWithClient calls NewUNewUploaderWithClientFunc. -func (m *MockS3Manager) NewUploaderWithClient(svc s3iface.S3API, opts ...func(*s3manager.Uploader)) s3manager.UploadClient { +func (m *MockS3Manager) NewUploaderWithClient( + svc s3iface.S3API, opts ...func(*s3manager.Uploader), +) s3manager.UploadClient { return m.NewUploaderWithClientFunc(svc, opts...) } @@ -57,7 +59,9 @@ type MockUploadClient struct { UploadWithContextFunc func(aws.Context, *s3manager.UploadInput, ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error) } -func (m *MockUploadClient) UploadWithContext(ctx aws.Context, input *s3manager.UploadInput, opts ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error) { +func (m *MockUploadClient) UploadWithContext( + ctx aws.Context, input *s3manager.UploadInput, opts ...func(*s3manager.Uploader), +) (*s3manager.UploadOutput, error) { return m.UploadWithContextFunc(ctx, input, opts...) } diff --git a/internal/encoding/json/json.go b/internal/encoding/json/json.go index c38a658205..030469eb3a 100644 --- a/internal/encoding/json/json.go +++ b/internal/encoding/json/json.go @@ -21,22 +21,22 @@ import ( "github.com/vdaas/vald/internal/io" ) -func Encode(w io.Writer, data interface{}) (err error) { +func Encode(w io.Writer, data any) (err error) { return json.NewEncoder(w).Encode(data) } -func Decode(r io.Reader, data interface{}) (err error) { +func Decode(r io.Reader, data any) (err error) { return json.NewDecoder(r).Decode(data) } -func Unmarshal(data []byte, i interface{}) error { +func Unmarshal(data []byte, i any) error { return json.Unmarshal(data, i) } -func Marshal(data interface{}) ([]byte, error) { +func Marshal(data any) ([]byte, error) { return json.Marshal(data) } -func MarshalIndent(data interface{}, pref, ind string) ([]byte, error) { +func MarshalIndent(data any, pref, ind string) ([]byte, error) { return json.MarshalIndent(data, pref, ind) } diff --git a/internal/encoding/json/json_test.go b/internal/encoding/json/json_test.go index ea2b258268..e7cebc7d53 100644 --- a/internal/encoding/json/json_test.go +++ b/internal/encoding/json/json_test.go @@ -26,7 +26,7 @@ import ( func TestEncode(t *testing.T) { type args struct { w io.Writer - data interface{} + data any } type test struct { @@ -165,7 +165,7 @@ func TestDecode(t *testing.T) { func TestMarshalIndent(t *testing.T) { type args struct { - data interface{} + data any pref string ind string } @@ -234,7 +234,7 @@ func TestMarshalIndent(t *testing.T) { // func TestUnmarshal(t *testing.T) { // type args struct { // data []byte -// i interface{} +// i any // } // type want struct { // err error @@ -315,14 +315,13 @@ func TestMarshalIndent(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func TestMarshal(t *testing.T) { // type args struct { -// data interface{} +// data any // } // type want struct { // want []byte @@ -405,7 +404,6 @@ func TestMarshalIndent(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/errors/agent_test.go b/internal/errors/agent_test.go index 3feb17129f..360045f847 100644 --- a/internal/errors/agent_test.go +++ b/internal/errors/agent_test.go @@ -17,9 +17,7 @@ // Package errors package errors -import ( - "testing" -) +import "testing" func TestErrObjectNotFound(t *testing.T) { type args struct { diff --git a/internal/errors/benchmark.go b/internal/errors/benchmark.go index e73f888009..191ee102f6 100644 --- a/internal/errors/benchmark.go +++ b/internal/errors/benchmark.go @@ -31,7 +31,7 @@ var ( } // ErrMismatchBenchmarkAtomics represents a function to generate an error that mismatch each atomic.Pointer stored corresponding to benchmark tasks. - ErrMismatchBenchmarkAtomics = func(job, benchjob, benchscenario interface{}) error { + ErrMismatchBenchmarkAtomics = func(job, benchjob, benchscenario any) error { return Errorf("mismatch atomics: job=%v\tbenchjob=%v\tbenchscenario=%v", job, benchjob, benchscenario) } ) diff --git a/internal/errors/blob_test.go b/internal/errors/blob_test.go index 030f926fa0..0388287143 100644 --- a/internal/errors/blob_test.go +++ b/internal/errors/blob_test.go @@ -666,7 +666,6 @@ func TestErrBlobNoSuchKey_Unwrap(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -755,7 +754,6 @@ func TestErrBlobNoSuchKey_Unwrap(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/errors/circuitbreaker_test.go b/internal/errors/circuitbreaker_test.go index b44560653b..ab4ebba569 100644 --- a/internal/errors/circuitbreaker_test.go +++ b/internal/errors/circuitbreaker_test.go @@ -96,7 +96,6 @@ package errors // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -185,7 +184,6 @@ package errors // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -274,7 +272,6 @@ package errors // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -360,7 +357,6 @@ package errors // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -449,7 +445,6 @@ package errors // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -538,7 +533,6 @@ package errors // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/errors/errors.go b/internal/errors/errors.go index b0e482ab26..4cb67e7c68 100644 --- a/internal/errors/errors.go +++ b/internal/errors/errors.go @@ -61,7 +61,7 @@ var ( } // ErrInvalidTypeConversion represents a function to generate an error that type conversion fails due to an invalid input type. - ErrInvalidTypeConversion = func(i interface{}, tgt interface{}) error { + ErrInvalidTypeConversion = func(i any, tgt any) error { return Errorf("invalid type conversion %v to %v", reflect.TypeOf(i), reflect.TypeOf(tgt)) } @@ -108,7 +108,7 @@ var ( // Wrapf represents a function to generate an error that is used by input error, format, and args. // When all of the input is nil, it will return a new error based on format and args even these are nil. // When the input error is not nil, it will return an error based on the input error. - Wrapf = func(err error, format string, args ...interface{}) error { + Wrapf = func(err error, format string, args ...any) error { if err != nil { if format != "" && len(args) != 0 { return Wrap(err, fmt.Sprintf(format, args...)) @@ -129,7 +129,7 @@ var ( // Errorf represents a function to generate an error based on format and args. // When format and args do not satisfy the condition, it will return nil. - Errorf = func(format string, args ...interface{}) error { + Errorf = func(format string, args ...any) error { const delim = " " if format == "" && len(args) == 0 { return nil @@ -263,12 +263,17 @@ func Join(errs ...error) error { var e *joinError switch x := errs[0].(type) { case *joinError: - e = x + if x != nil && len(x.errs) != 0 { + e = x + } errs = errs[1:] case interface{ Unwrap() []error }: - e = &joinError{errs: x.Unwrap()} + if x != nil && len(x.Unwrap()) != 0 { + e = &joinError{errs: x.Unwrap()} + } errs = errs[1:] - default: + } + if e == nil { e = &joinError{ errs: make([]error, 0, l), } @@ -278,6 +283,9 @@ func Join(errs ...error) error { e.errs = append(e.errs, err) } } + if len(e.errs) == 0 { + return nil + } return e } @@ -296,7 +304,7 @@ type joinError struct { } var sbPool = sync.Pool{ - New: func() interface{} { + New: func() any { return new(strings.Builder) }, } diff --git a/internal/errors/errors_benchmark_test.go b/internal/errors/errors_benchmark_test.go index 92ef365b93..c5af30b93e 100644 --- a/internal/errors/errors_benchmark_test.go +++ b/internal/errors/errors_benchmark_test.go @@ -51,9 +51,7 @@ func TestMain(m *testing.M) { bigData = nil } -func benchmark(b *testing.B, data map[string]error, - join func(err1, err2 error) error, -) { +func benchmark(b *testing.B, data map[string]error, join func(err1, err2 error) error) { b.Helper() b.SetParallelism(parallelism) b.ReportAllocs() diff --git a/internal/errors/errors_test.go b/internal/errors/errors_test.go index 43a5457d99..3e69498d23 100644 --- a/internal/errors/errors_test.go +++ b/internal/errors/errors_test.go @@ -18,6 +18,8 @@ import ( "math" "reflect" "testing" + + "github.com/vdaas/vald/internal/test/goleak" ) func TestErrTimeoutParseFailed(t *testing.T) { @@ -190,7 +192,7 @@ func TestErrOptionFailed(t *testing.T) { args: args{ err: New("option failed error"), ref: func() reflect.Value { - var i interface{} = fmt.Println + var i any = fmt.Println return reflect.ValueOf(i) }(), }, @@ -400,8 +402,8 @@ func TestErrBackoffTimeout(t *testing.T) { func TestErrInvalidTypeConversion(t *testing.T) { type args struct { - i interface{} - tgt interface{} + i any + tgt any } type want struct { want error @@ -530,7 +532,7 @@ func TestErrLoggingRetry(t *testing.T) { args: args{ err: New("logging retry"), ref: func() reflect.Value { - var i interface{} = fmt.Println + var i any = fmt.Println return reflect.ValueOf(i) }(), }, @@ -632,7 +634,7 @@ func TestErrLoggingFailed(t *testing.T) { args: args{ err: New("logging retry"), ref: func() reflect.Value { - var i interface{} = fmt.Println + var i any = fmt.Println return reflect.ValueOf(i) }(), }, @@ -864,7 +866,7 @@ func TestWrapf(t *testing.T) { type args struct { err error format string - args []interface{} + args []any } type want struct { want error @@ -887,7 +889,7 @@ func TestWrapf(t *testing.T) { func() test { err := New("err: ") format := "error is occurred: %v" - val := []interface{}{ + val := []any{ "timeout error", } wantErr := fmt.Errorf("%s: %w", fmt.Sprintf(format, val...), err) @@ -906,7 +908,7 @@ func TestWrapf(t *testing.T) { func() test { err := New("err: ") format := "error is occurred: %v : %v" - val := []interface{}{ + val := []any{ "invalid time_duration", 10, } @@ -925,7 +927,7 @@ func TestWrapf(t *testing.T) { }(), func() test { err := New("err: ") - val := []interface{}{ + val := []any{ "invalid time_duration", 10, } @@ -971,7 +973,7 @@ func TestWrapf(t *testing.T) { }(), func() test { format := "error is occurred: %v : %v" - val := []interface{}{ + val := []any{ "invalid time_duration", 10, } @@ -1008,7 +1010,7 @@ func TestWrapf(t *testing.T) { } }(), func() test { - val := []interface{}{ + val := []any{ "invalid time_duration", 10, } @@ -1024,7 +1026,7 @@ func TestWrapf(t *testing.T) { } }(), func() test { - val := []interface{}{ + val := []any{ map[string]int{"invalid time_duration": 10}, } wantErr := fmt.Errorf("%v", val[0]) @@ -1196,7 +1198,7 @@ func TestUnwarp(t *testing.T) { func TestErrorf(t *testing.T) { type args struct { format string - args []interface{} + args []any } type want struct { want error @@ -1218,7 +1220,7 @@ func TestErrorf(t *testing.T) { tests := []test{ func() test { format := "error is occurred: %v" - val := []interface{}{ + val := []any{ "timeout error", } wantErr := fmt.Errorf(format, val...) @@ -1235,7 +1237,7 @@ func TestErrorf(t *testing.T) { }(), func() test { format := "error is occurred: %v : %v" - val := []interface{}{ + val := []any{ "invalid time_duration", 10, } @@ -1252,7 +1254,7 @@ func TestErrorf(t *testing.T) { } }(), func() test { - val := []interface{}{ + val := []any{ "invalid time_duration", 10, } @@ -1268,7 +1270,7 @@ func TestErrorf(t *testing.T) { } }(), func() test { - val := []interface{}{ + val := []any{ map[string]int{"invalid time_duration": 10}, } wantErr := fmt.Errorf("%v", val[0]) @@ -1527,7 +1529,7 @@ func TestIs(t *testing.T) { func TestAs(t *testing.T) { type args struct { err error - target interface{} + target any } type want struct { want bool @@ -1649,6 +1651,87 @@ func TestRemoveDuplicates(t *testing.T) { } } +func TestJoin(t *testing.T) { + type args struct { + errs []error + } + 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{ + { + name: "return nil when all errors are nil", + args: args{ + errs: []error{ + nil, nil, nil, + }, + }, + }, + { + name: "returns an aggregated error when all errors are non-nil and different", + args: args{ + errs: []error{ + New("error1"), New("error2"), New("error3"), + }, + }, + want: want{ + err: &joinError{ + errs: []error{ + New("error1"), New("error2"), New("error3"), + }, + }, + }, + }, + { + name: "returns an error when errors are mixed nil and non-nil", + args: args{ + errs: []error{ + nil, New("error1"), nil, + }, + }, + want: want{ + err: New("error1"), + }, + }, + } + 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 := Join(test.args.errs...) + if err := checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + // NOT IMPLEMENTED BELOW // // func TestUnwrap(t *testing.T) { @@ -1732,93 +1815,6 @@ func TestRemoveDuplicates(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// -// }) -// } -// } -// -// func TestJoin(t *testing.T) { -// type args struct { -// errs []error -// } -// 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 { -// errs: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 { -// errs: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 -// } -// -// err := Join(test.args.errs...) -// if err := checkFunc(test.want, err); err != nil { -// tt.Errorf("error = %v", err) -// } -// // }) // } // } @@ -1907,7 +1903,6 @@ func TestRemoveDuplicates(t *testing.T) { // if err := checkFunc(test.want, gotStr); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1996,7 +1991,6 @@ func TestRemoveDuplicates(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/errors/faiss_test.go b/internal/errors/faiss_test.go new file mode 100644 index 0000000000..319562e690 --- /dev/null +++ b/internal/errors/faiss_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 TestNewFaissError(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 := NewFaissError(test.args.msg) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestFaissError_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 +// } +// f := FaissError{ +// Msg: test.fields.Msg, +// } +// +// got := f.Error() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/errors/file_test.go b/internal/errors/file_test.go index 6980689ca7..0d14e62b86 100644 --- a/internal/errors/file_test.go +++ b/internal/errors/file_test.go @@ -13,9 +13,7 @@ // limitations under the License. package errors -import ( - "testing" -) +import "testing" func TestErrWatchDirNotFound(t *testing.T) { type want struct { @@ -327,7 +325,6 @@ func TestErrPathNotAllowed(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/errors/filter_test.go b/internal/errors/filter_test.go index dd5a802ea5..e22c451398 100644 --- a/internal/errors/filter_test.go +++ b/internal/errors/filter_test.go @@ -17,9 +17,7 @@ // Package errors provides error types and function package errors -import ( - "testing" -) +import "testing" func TestErrTargetFilterNotFound(t *testing.T) { type args struct { diff --git a/internal/errors/grpc.go b/internal/errors/grpc.go index 296e978f7f..4df3243912 100644 --- a/internal/errors/grpc.go +++ b/internal/errors/grpc.go @@ -67,7 +67,7 @@ var ( } // ErrInvalidProtoMessageType represents an error that the gRPC protocol buffers message type is invalid. - ErrInvalidProtoMessageType = func(v interface{}) error { + ErrInvalidProtoMessageType = func(v any) error { return Errorf("failed to marshal/unmarshal proto message, message type is %T (missing vtprotobuf/protobuf helpers)", v) } diff --git a/internal/errors/info_test.go b/internal/errors/info_test.go index f79da1c52d..bc44be9f2b 100644 --- a/internal/errors/info_test.go +++ b/internal/errors/info_test.go @@ -17,9 +17,7 @@ // Package errors provides error types and function package errors -import ( - "testing" -) +import "testing" func TestErrFailedToInitInfo(t *testing.T) { type args struct { diff --git a/internal/errors/ngt.go b/internal/errors/ngt.go index 75c6eeabf9..f055892047 100644 --- a/internal/errors/ngt.go +++ b/internal/errors/ngt.go @@ -46,6 +46,10 @@ var ( } ErrSearchResultEmptyButNoDataStored = New("empty search result from cgo but no index data stored in ngt, this error can be ignored.") + + ErrNGTIndexStatisticsDisabled = New("ngt get statistics is disabled") + + ErrNGTIndexStatisticsNotReady = New("ngt get statistics is not ready") ) type NGTError struct { diff --git a/internal/errors/ngt_test.go b/internal/errors/ngt_test.go index 6c80cdc414..232ab1c46a 100644 --- a/internal/errors/ngt_test.go +++ b/internal/errors/ngt_test.go @@ -1505,7 +1505,6 @@ func TestErrRemoveRequestedBeforeIndexing(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1594,7 +1593,6 @@ func TestErrRemoveRequestedBeforeIndexing(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/errors/option.go b/internal/errors/option.go index 874e2c7525..8b3bda142b 100644 --- a/internal/errors/option.go +++ b/internal/errors/option.go @@ -20,7 +20,7 @@ type ErrInvalidOption struct { } // NewErrInvalidOption represents a function to generate a new error of ErrInvalidOption that invalid option. -func NewErrInvalidOption(name string, val interface{}, errs ...error) error { +func NewErrInvalidOption(name string, val any, errs ...error) error { if len(errs) == 0 { return &ErrInvalidOption{ err: Errorf("invalid option, name: %s, val: %v", name, val), @@ -65,7 +65,7 @@ type ErrCriticalOption struct { } // NewErrCriticalOption represents a function to generate a new error of ErrCriticalOption that invalid option. -func NewErrCriticalOption(name string, val interface{}, errs ...error) error { +func NewErrCriticalOption(name string, val any, errs ...error) error { if len(errs) == 0 { return &ErrCriticalOption{ err: Errorf("invalid critical option, name: %s, val: %v", name, val), diff --git a/internal/errors/option_test.go b/internal/errors/option_test.go index 314ac7e933..8fba808dde 100644 --- a/internal/errors/option_test.go +++ b/internal/errors/option_test.go @@ -23,7 +23,7 @@ import ( func TestNewErrInvalidOption(t *testing.T) { type args struct { name string - val interface{} + val any errs []error } type want struct { @@ -318,7 +318,7 @@ func TestNewErrCriticalOption(t *testing.T) { type T = error type args struct { name string - val interface{} + val any errs []error } type want struct { diff --git a/internal/errors/redis_test.go b/internal/errors/redis_test.go index 98add372c3..c399adf6e7 100644 --- a/internal/errors/redis_test.go +++ b/internal/errors/redis_test.go @@ -1026,7 +1026,6 @@ func TestIsRedisNotFoundError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/errors/runtime.go b/internal/errors/runtime.go index 337a86f3f7..01d3a1351d 100644 --- a/internal/errors/runtime.go +++ b/internal/errors/runtime.go @@ -21,7 +21,7 @@ import "runtime" var ( // ErrPanicRecovered represents a function to generate an error that the panic recovered. - ErrPanicRecovered = func(err error, rec interface{}) error { + ErrPanicRecovered = func(err error, rec any) error { return Wrap(err, Errorf("panic recovered: %v", rec).Error()) } diff --git a/internal/errors/runtime_test.go b/internal/errors/runtime_test.go index 4c532d57c0..77ccce3167 100644 --- a/internal/errors/runtime_test.go +++ b/internal/errors/runtime_test.go @@ -28,7 +28,7 @@ import ( func TestErrPanicRecovered(t *testing.T) { type args struct { err error - rec interface{} + rec any } type want struct { want error diff --git a/internal/errors/unit_test.go b/internal/errors/unit_test.go index 0d4ceca89e..210800f347 100644 --- a/internal/errors/unit_test.go +++ b/internal/errors/unit_test.go @@ -13,9 +13,7 @@ // limitations under the License. package errors -import ( - "testing" -) +import "testing" func TestErrParseUnitFailed(t *testing.T) { type args struct { diff --git a/internal/errors/vald_test.go b/internal/errors/vald_test.go index 2089cc4d60..9801de5802 100644 --- a/internal/errors/vald_test.go +++ b/internal/errors/vald_test.go @@ -13,9 +13,7 @@ // limitations under the License. package errors -import ( - "testing" -) +import "testing" func TestErrMetaDataAlreadyExists(t *testing.T) { type args struct { diff --git a/internal/file/file.go b/internal/file/file.go index 6e97b2f7c8..238a3b0de6 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -259,19 +259,27 @@ func CopyFileWithPerm(ctx context.Context, src, dst string, perm fs.FileMode) (n return n, nil } -func WriteFile(ctx context.Context, target string, r io.Reader, perm fs.FileMode) (n int64, err error) { +func WriteFile( + ctx context.Context, target string, r io.Reader, perm fs.FileMode, +) (n int64, err error) { return writeFileWithContext(ctx, target, r, os.O_CREATE|os.O_WRONLY|os.O_SYNC, perm) } -func OverWriteFile(ctx context.Context, target string, r io.Reader, perm fs.FileMode) (n int64, err error) { +func OverWriteFile( + ctx context.Context, target string, r io.Reader, perm fs.FileMode, +) (n int64, err error) { return writeFileWithContext(ctx, target, r, os.O_CREATE|os.O_TRUNC|os.O_WRONLY|os.O_SYNC, perm) } -func AppendFile(ctx context.Context, target string, r io.Reader, perm fs.FileMode) (n int64, err error) { +func AppendFile( + ctx context.Context, target string, r io.Reader, perm fs.FileMode, +) (n int64, err error) { return writeFileWithContext(ctx, target, r, os.O_CREATE|os.O_APPEND|os.O_RDWR|os.O_SYNC, perm) } -func writeFileWithContext(ctx context.Context, target string, r io.Reader, flg int, perm fs.FileMode) (n int64, err error) { +func writeFileWithContext( + ctx context.Context, target string, r io.Reader, flg int, perm fs.FileMode, +) (n int64, err error) { if len(target) == 0 || r == nil { return 0, nil } @@ -479,7 +487,7 @@ func ListInDir(path string) ([]string, error) { return files, nil } -// DeleteDir recursively deletes each file or directory based on the path specified as an argument +// DeleteDir recursively deletes each file or directory based on the path specified as an argument. func DeleteDir(ctx context.Context, path string) (err error) { exists, _, err := ExistsWithDetail(path) if err != nil { diff --git a/internal/file/file_test.go b/internal/file/file_test.go index 074320eb93..42f6a6dd40 100644 --- a/internal/file/file_test.go +++ b/internal/file/file_test.go @@ -565,7 +565,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -660,7 +659,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -752,7 +750,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -848,7 +845,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotN, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -947,7 +943,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotN, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1046,7 +1041,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotN, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1145,7 +1139,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotN, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1244,7 +1237,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotN, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1346,7 +1338,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotN, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1436,7 +1427,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotDirs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1526,7 +1516,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotN, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1615,7 +1604,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1705,7 +1693,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotPath, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1795,7 +1782,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotF, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1885,7 +1871,94 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func TestDeleteDir(t *testing.T) { +// type args struct { +// 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 := DeleteDir(test.args.ctx, test.args.path) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -1971,7 +2044,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotPath); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2057,7 +2129,6 @@ func TestExistsWithDetail(t *testing.T) { // if err := checkFunc(test.want, gotPath); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/hash/hash_test.go b/internal/hash/hash_test.go index 2d1a46b843..25217598a2 100644 --- a/internal/hash/hash_test.go +++ b/internal/hash/hash_test.go @@ -18,7 +18,7 @@ package hash // NOT IMPLEMENTED BELOW - +// // func TestString(t *testing.T) { // type args struct { // s string @@ -100,7 +100,6 @@ package hash // 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 f8c820701d..6f5f31e0f9 100644 --- a/internal/info/info.go +++ b/internal/info/info.go @@ -48,16 +48,20 @@ type info struct { // Detail represents environment information of system and stacktrace information. type Detail struct { - Version string `json:"vald_version,omitempty" yaml:"vald_version,omitempty"` - ServerName string `json:"server_name,omitempty" yaml:"server_name,omitempty"` - GitCommit string `json:"git_commit,omitempty" yaml:"git_commit,omitempty"` + AlgorithmInfo string `json:"algorithm_info,omitempty" yaml:"algorithm_info,omitempty"` BuildTime string `json:"build_time,omitempty" yaml:"build_time,omitempty"` - GoVersion string `json:"go_version,omitempty" yaml:"go_version,omitempty"` - GoOS string `json:"go_os,omitempty" yaml:"go_os,omitempty"` + CGOCall string `json:"cgo_call,omitempty" yaml:"cgo_call"` + CGOEnabled string `json:"cgo_enabled,omitempty" yaml:"cgo_enabled,omitempty"` + GitCommit string `json:"git_commit,omitempty" yaml:"git_commit,omitempty"` GoArch string `json:"go_arch,omitempty" yaml:"go_arch,omitempty"` + GoMaxProcs string `json:"go_max_procs,omitempty" yaml:"go_max_procs,omitempty"` + GoOS string `json:"go_os,omitempty" yaml:"go_os,omitempty"` GoRoot string `json:"go_root,omitempty" yaml:"go_root,omitempty"` - CGOEnabled string `json:"cgo_enabled,omitempty" yaml:"cgo_enabled,omitempty"` - AlgorithmInfo string `json:"algorithm_info,omitempty" yaml:"algorithm_info,omitempty"` + GoVersion string `json:"go_version,omitempty" yaml:"go_version,omitempty"` + GoroutineCount string `json:"goroutine_count,omitempty" yaml:"goroutine_count"` + RuntimeCPUCores string `json:"runtime_cpu_cores,omitempty" yaml:"runtime_cpu_cores,omitempty"` + ServerName string `json:"server_name,omitempty" yaml:"server_name,omitempty"` + Version string `json:"vald_version,omitempty" yaml:"vald_version,omitempty"` BuildCPUInfoFlags []string `json:"build_cpu_info_flags,omitempty" yaml:"build_cpu_info_flags,omitempty"` StackTrace []StackTrace `json:"stack_trace,omitempty" yaml:"stack_trace,omitempty"` } @@ -137,18 +141,19 @@ func Init(name string) { func New(opts ...Option) (Info, error) { i := &info{ detail: Detail{ - ServerName: "", - Version: Version, - GitCommit: GitCommit, + AlgorithmInfo: AlgorithmInfo, + BuildCPUInfoFlags: strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " "), BuildTime: BuildTime, - GoVersion: GoVersion, - GoOS: GoOS, + CGOEnabled: CGOEnabled, + GitCommit: GitCommit, GoArch: GoArch, + GoOS: GoOS, GoRoot: GoRoot, - CGOEnabled: CGOEnabled, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " "), + GoVersion: GoVersion, + RuntimeCPUCores: strconv.Itoa(runtime.NumCPU()), + ServerName: "", StackTrace: nil, + Version: Version, }, } @@ -177,7 +182,7 @@ func New(opts ...Option) (Info, error) { // String calls String method of global detail object. func String() string { if infoProvider == nil { - return "" + Init(log.Bold("WARNING: uninitialized info provider")) } return infoProvider.String() } @@ -185,7 +190,7 @@ func String() string { // Get calls Get method of global detail object. func Get() Detail { if infoProvider == nil { - return Detail{} + Init(log.Bold("WARNING: uninitialized info provider")) } return infoProvider.Get() } @@ -255,6 +260,12 @@ func (d Detail) String() string { if maxlen < l { maxlen = l } + switch tag { + case "cgo_call": + value = strconv.FormatInt(runtime.NumCgoCall(), 10) + case "goroutine_count": + value = strconv.Itoa(runtime.NumGoroutine()) + } info[tag] = value } @@ -370,6 +381,15 @@ func (i *info) prepare() { if i.baseURL == "" { i.baseURL = "https://" + valdRepo + "/tree/" + i.detail.GitCommit } + if len(i.detail.GoMaxProcs) == 0 { + i.detail.GoMaxProcs = strconv.Itoa(runtime.GOMAXPROCS(-1)) + } + if len(i.detail.CGOCall) == 0 { + i.detail.CGOCall = strconv.FormatInt(runtime.NumCgoCall(), 10) + } + if len(i.detail.GoroutineCount) == 0 { + i.detail.GoroutineCount = strconv.Itoa(runtime.NumGoroutine()) + } }) } diff --git a/internal/info/info_bench_test.go b/internal/info/info_bench_test.go index 1696235155..d91761c292 100644 --- a/internal/info/info_bench_test.go +++ b/internal/info/info_bench_test.go @@ -13,9 +13,7 @@ // limitations under the License. package info -import ( - "testing" -) +import "testing" func BenchmarkString(b *testing.B) { Init("benchmark") diff --git a/internal/info/info_test.go b/internal/info/info_test.go index 0d8e1e04b3..41f4150860 100644 --- a/internal/info/info_test.go +++ b/internal/info/info_test.go @@ -1,1735 +1,686 @@ -// // 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 +// 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 info + +// NOT IMPLEMENTED BELOW +// +// func TestInit(t *testing.T) { +// type args struct { +// name string +// } +// type want struct{} +// type test struct { +// name string +// args args +// 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 +// } +// +// Init(test.args.name) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Info +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Info, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Info, 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 TestString(t *testing.T) { +// type want struct { +// want string +// } +// type test struct { +// name string +// 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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// 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 +// } +// +// got := String() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestGet(t *testing.T) { +// type want struct { +// want Detail +// } +// type test struct { +// name string +// want want +// checkFunc func(want, Detail) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got Detail) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// 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 +// } +// +// got := Get() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_info_String(t *testing.T) { +// type fields struct { +// baseURL string +// detail Detail +// rtCaller func(skip int) (pc uintptr, file string, line int, ok bool) +// rtFuncForPC func(pc uintptr) *runtime.Func +// } +// 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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// baseURL:"", +// detail:Detail{}, +// rtCaller:nil, +// rtFuncForPC: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 { +// baseURL:"", +// detail:Detail{}, +// rtCaller:nil, +// rtFuncForPC: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 +// } +// i := &info{ +// baseURL: test.fields.baseURL, +// detail: test.fields.detail, +// rtCaller: test.fields.rtCaller, +// rtFuncForPC: test.fields.rtFuncForPC, +// } +// +// got := i.String() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestDetail_String(t *testing.T) { +// type fields struct { +// AlgorithmInfo string +// BuildTime string +// CGOCall string +// CGOEnabled string +// GitCommit string +// GoArch string +// GoMaxProcs string +// GoOS string +// GoRoot string +// GoVersion string +// GoroutineCount string +// RuntimeCPUCores string +// ServerName string +// Version string +// BuildCPUInfoFlags []string +// StackTrace []StackTrace +// } +// 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 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 { +// AlgorithmInfo:"", +// BuildTime:"", +// CGOCall:"", +// CGOEnabled:"", +// GitCommit:"", +// GoArch:"", +// GoMaxProcs:"", +// GoOS:"", +// GoRoot:"", +// GoVersion:"", +// GoroutineCount:"", +// RuntimeCPUCores:"", +// ServerName:"", +// Version:"", +// BuildCPUInfoFlags:nil, +// StackTrace: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 { +// AlgorithmInfo:"", +// BuildTime:"", +// CGOCall:"", +// CGOEnabled:"", +// GitCommit:"", +// GoArch:"", +// GoMaxProcs:"", +// GoOS:"", +// GoRoot:"", +// GoVersion:"", +// GoroutineCount:"", +// RuntimeCPUCores:"", +// ServerName:"", +// Version:"", +// BuildCPUInfoFlags:nil, +// StackTrace: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{ +// AlgorithmInfo: test.fields.AlgorithmInfo, +// BuildTime: test.fields.BuildTime, +// CGOCall: test.fields.CGOCall, +// CGOEnabled: test.fields.CGOEnabled, +// GitCommit: test.fields.GitCommit, +// GoArch: test.fields.GoArch, +// GoMaxProcs: test.fields.GoMaxProcs, +// GoOS: test.fields.GoOS, +// GoRoot: test.fields.GoRoot, +// GoVersion: test.fields.GoVersion, +// GoroutineCount: test.fields.GoroutineCount, +// RuntimeCPUCores: test.fields.RuntimeCPUCores, +// ServerName: test.fields.ServerName, +// Version: test.fields.Version, +// BuildCPUInfoFlags: test.fields.BuildCPUInfoFlags, +// StackTrace: test.fields.StackTrace, +// } +// +// got := d.String() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_info_Get(t *testing.T) { +// type fields struct { +// baseURL string +// detail Detail +// rtCaller func(skip int) (pc uintptr, file string, line int, ok bool) +// rtFuncForPC func(pc uintptr) *runtime.Func +// } +// type want struct { +// want Detail +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, Detail) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got Detail) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// baseURL:"", +// detail:Detail{}, +// rtCaller:nil, +// rtFuncForPC: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 { +// baseURL:"", +// detail:Detail{}, +// rtCaller:nil, +// rtFuncForPC:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } // -// 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. +// 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 +// } +// i := &info{ +// baseURL: test.fields.baseURL, +// detail: test.fields.detail, +// rtCaller: test.fields.rtCaller, +// rtFuncForPC: test.fields.rtFuncForPC, +// } // - -// Package info provides build-time info -package info - -import ( - "os" - "reflect" - "runtime" - "testing" - - "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/log" - "github.com/vdaas/vald/internal/log/logger" - "github.com/vdaas/vald/internal/strings" - "github.com/vdaas/vald/internal/sync" - "github.com/vdaas/vald/internal/test/comparator" - "github.com/vdaas/vald/internal/test/goleak" -) - -// Goroutine leak is detected by `fastime`, but it should be ignored in the test because it is an external package. -var goleakIgnoreOptions = []goleak.Option{ - goleak.IgnoreTopFunction("github.com/kpango/fastime.(*fastime).StartTimerD.func1"), -} - -func TestMain(m *testing.M) { - log.Init(log.WithLoggerType(logger.NOP.String())) - os.Exit(m.Run()) -} - -func TestString(t *testing.T) { - type want struct { - want *Detail - } - type test struct { - name string - want want - checkFunc func(want, string) error - beforeFunc func(*testing.T) - afterFunc func(*testing.T) - } - defaultCheckFunc := func(w want, got string) error { - if got == w.want.String() { - // check the position of "->" - var oldIdx int - for i, str := range strings.Split(strings.TrimPrefix(got, "\n"), "\n") { - idx := strings.Index(str, "->") - if i != 0 { - if oldIdx != idx { - return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want) - } - } - oldIdx = idx - } - return nil - } - return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want) - } - tests := []test{ - { - name: "return correct string with no stack trace initialized", - beforeFunc: func(t *testing.T) { - t.Helper() - infoProvider, _ = New(WithServerName(""), - WithRuntimeCaller(func(skip int) (pc uintptr, file string, line int, ok bool) { - return uintptr(0), "", 0, false - })) - }, - afterFunc: func(t *testing.T) { - t.Helper() - once = sync.Once{} - infoProvider = nil - }, - want: want{ - want: &Detail{ - Version: "v0.0.1", - ServerName: "", - GitCommit: GitCommit, - BuildTime: "", - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: "", - BuildCPUInfoFlags: nil, - StackTrace: nil, - }, - }, - }, - { - name: "return correct string with no information initialized", - beforeFunc: func(t *testing.T) { - t.Helper() - infoProvider = &info{ - rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) { - return uintptr(0), "", 0, false - }, - } - }, - afterFunc: func(t *testing.T) { - t.Helper() - once = sync.Once{} - infoProvider = nil - }, - want: want{ - want: &Detail{ - Version: "", - ServerName: "", - GitCommit: GitCommit, - BuildTime: "", - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: "", - BuildCPUInfoFlags: nil, - StackTrace: nil, - }, - }, - }, - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - if test.afterFunc != nil { - defer test.afterFunc(tt) - } - if test.beforeFunc != nil { - test.beforeFunc(tt) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - - got := String() - if err := checkFunc(test.want, got); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func TestGet(t *testing.T) { - type want struct { - want Detail - } - type test struct { - name string - want want - checkFunc func(want, Detail) error - beforeFunc func(*testing.T) - afterFunc func(*testing.T) - } - defaultCheckFunc := func(w want, got Detail) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) - } - return nil - } - tests := []test{ - { - name: "return detail with initialized runtime information", - beforeFunc: func(t *testing.T) { - t.Helper() - infoProvider, _ = New(WithServerName(""), WithRuntimeCaller(func(skip int) (pc uintptr, file string, line int, ok bool) { - return uintptr(0), "", 0, false - })) - }, - afterFunc: func(t *testing.T) { - t.Helper() - once = sync.Once{} - infoProvider = nil - }, - want: want{ - want: Detail{ - ServerName: "", - Version: Version, - BuildTime: "", - GitCommit: GitCommit, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: "", - BuildCPUInfoFlags: []string{""}, - StackTrace: make([]StackTrace, 0, 10), - }, - }, - }, - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - if test.beforeFunc != nil { - test.beforeFunc(tt) - } - if test.afterFunc != nil { - defer test.afterFunc(tt) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - - got := Get() - if err := checkFunc(test.want, got); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func TestInit(t *testing.T) { - type args struct { - name string - } - type want struct { - want Info - } - type test struct { - name string - args args - want want - checkFunc func(want, Info) error - beforeFunc func(*testing.T, args) - afterFunc func(*testing.T, args) - } - defaultCheckFunc := func(w want, got Info) error { - opts := []comparator.Option{ - comparator.AllowUnexported(info{}), - // skipcq: VET-V0008 - comparator.Comparer(func(x, y sync.Once) bool { - // skipcq: VET-V0008 - return reflect.DeepEqual(x, y) - }), - comparator.Comparer(func(x, y func(skip int) (pc uintptr, file string, line int, ok bool)) bool { - return reflect.ValueOf(x).Pointer() == reflect.ValueOf(y).Pointer() - }), - comparator.Comparer(func(x, y func(pc uintptr) *runtime.Func) bool { - return reflect.ValueOf(x).Pointer() == reflect.ValueOf(y).Pointer() - }), - } - if diff := comparator.Diff(w.want, got, opts...); len(diff) != 0 { - return errors.Errorf("err: %s", diff) - } - return nil - } - - gitCommit := GitCommit - version := Version - buildTime := BuildTime - cgoEnabled := CGOEnabled - ngtVersion := AlgorithmInfo - buildCPUInfoFlags := BuildCPUInfoFlags - tests := []test{ - { - name: "set success when the server name is not empty", - args: args{ - name: "gateway", - }, - want: want{ - want: &info{ - baseURL: "https://github.com/vdaas/vald/tree/gitcommit", - detail: Detail{ - GitCommit: "gitcommit", - ServerName: "gateway", - Version: "gitcommit", - BuildTime: "1s", - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoTrue, - AlgorithmInfo: "v1.11.6", - BuildCPUInfoFlags: []string{ - "avx512f", "avx512dq", - }, - StackTrace: nil, - }, - rtCaller: runtime.Caller, - rtFuncForPC: runtime.FuncForPC, - prepOnce: func() (o sync.Once) { - o.Do(func() {}) - return - }(), - }, - }, - beforeFunc: func(t *testing.T, _ args) { - t.Helper() - GitCommit = "gitcommit" - Version = "" - BuildTime = "1s" - CGOEnabled = cgoTrue - AlgorithmInfo = "v1.11.6" - BuildCPUInfoFlags = "\t\tavx512f avx512dq\t" - }, - afterFunc: func(t *testing.T, _ args) { - t.Helper() - once = sync.Once{} - infoProvider = nil - - GitCommit = gitCommit - Version = version - BuildTime = buildTime - CGOEnabled = cgoEnabled - AlgorithmInfo = ngtVersion - BuildCPUInfoFlags = buildCPUInfoFlags - }, - }, - { - name: "set success when the server name is an empty string", - args: args{ - name: "", - }, - want: want{ - want: &info{ - baseURL: "https://github.com/vdaas/vald/tree/gitcommit", - detail: Detail{ - GitCommit: "gitcommit", - ServerName: "", - Version: "gitcommit", - BuildTime: "1s", - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoTrue, - AlgorithmInfo: "v1.11.6", - BuildCPUInfoFlags: []string{ - "avx512f", "avx512dq", - }, - StackTrace: nil, - }, - rtCaller: runtime.Caller, - rtFuncForPC: runtime.FuncForPC, - prepOnce: func() (o sync.Once) { - o.Do(func() {}) - return - }(), - }, - }, - beforeFunc: func(t *testing.T, _ args) { - t.Helper() - GitCommit = "gitcommit" - Version = "" - BuildTime = "1s" - CGOEnabled = cgoTrue - AlgorithmInfo = "v1.11.6" - BuildCPUInfoFlags = "\t\tavx512f avx512dq\t" - }, - afterFunc: func(t *testing.T, _ args) { - t.Helper() - once = sync.Once{} - infoProvider = nil - - GitCommit = gitCommit - Version = version - BuildTime = buildTime - CGOEnabled = cgoEnabled - AlgorithmInfo = ngtVersion - BuildCPUInfoFlags = buildCPUInfoFlags - }, - }, - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - 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 - } - - Init(test.args.name) - if err := checkFunc(test.want, infoProvider); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func TestNew(t *testing.T) { - type args struct { - opts []Option - } - type want struct { - want Info - err error - } - type test struct { - name string - args args - want want - checkFunc func(want, Info, error) error - beforeFunc func(args) - afterFunc func(*testing.T, args) - } - defaultCheckFunc := func(w want, got Info, err error) error { - if !errors.Is(err, w.err) { - return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) - } - opts := []comparator.Option{ - comparator.AllowUnexported(info{}), - // skipcq: VET-V0008 - comparator.Comparer(func(x, y sync.Once) bool { - // skipcq: VET-V0008 - return reflect.DeepEqual(x, y) - }), - comparator.Comparer(func(x, y func(skip int) (pc uintptr, file string, line int, ok bool)) bool { - return reflect.ValueOf(x).Pointer() == reflect.ValueOf(y).Pointer() - }), - comparator.Comparer(func(x, y func(pc uintptr) *runtime.Func) bool { - return reflect.ValueOf(x).Pointer() == reflect.ValueOf(y).Pointer() - }), - } - if diff := comparator.Diff(got, w.want, opts...); diff != "" { - return errors.New(diff) - } - return nil - } - tests := []test{ - { - name: "return default info with no option set", - args: args{ - opts: nil, - }, - want: want{ - want: &info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - ServerName: "", - Version: Version, - GitCommit: GitCommit, - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " "), - StackTrace: nil, - }, - prepOnce: func() (o sync.Once) { - o.Do(func() {}) - return - }(), - rtCaller: runtime.Caller, - rtFuncForPC: runtime.FuncForPC, - }, - }, - }, - { - name: "return info when 1 option set", - args: args{ - opts: []Option{ - WithServerName("gateway"), - }, - }, - want: want{ - want: &info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - ServerName: "gateway", - Version: Version, - GitCommit: GitCommit, - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " "), - }, - prepOnce: func() (o sync.Once) { - o.Do(func() {}) - return - }(), - rtCaller: runtime.Caller, - rtFuncForPC: runtime.FuncForPC, - }, - }, - }, - { - name: "return info when multiple options set", - args: args{ - opts: []Option{ - WithServerName("vald"), - func(i *info) error { - i.detail.Version = "v1.0.0" - return nil - }, - }, - }, - want: want{ - want: &info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - ServerName: "vald", - Version: "v1.0.0", - GitCommit: GitCommit, - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " "), - StackTrace: nil, - }, - prepOnce: func() (o sync.Once) { - o.Do(func() {}) - return - }(), - rtCaller: runtime.Caller, - rtFuncForPC: runtime.FuncForPC, - }, - }, - }, - { - name: "return info and log the error when an invalid option set", - args: args{ - opts: []Option{ - func(i *info) error { - return errors.NewErrInvalidOption("field", "err") - }, - }, - }, - want: want{ - want: &info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - ServerName: "", - Version: Version, - GitCommit: GitCommit, - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " "), - StackTrace: nil, - }, - prepOnce: func() (o sync.Once) { - o.Do(func() {}) - return - }(), - rtCaller: runtime.Caller, - rtFuncForPC: runtime.FuncForPC, - }, - }, - }, - { - name: "return an error when a critical error occurred", - args: args{ - opts: []Option{ - func(i *info) error { - return errors.NewErrCriticalOption("field", "err") - }, - }, - }, - want: want{ - err: errors.NewErrCriticalOption("field", "err"), - }, - }, - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) - if test.beforeFunc != nil { - test.beforeFunc(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 Test_info_String(t *testing.T) { - type fields struct { - detail Detail - rtCaller func(skip int) (pc uintptr, file string, line int, ok bool) - rtFuncForPC func(pc uintptr) *runtime.Func - } - type want struct { - want *Detail - } - type test struct { - name string - fields fields - want want - checkFunc func(want, string) error - beforeFunc func() - afterFunc func(*testing.T) - } - defaultCheckFunc := func(w want, got string) error { - if got == w.want.String() { - // check the position of "->" - var oldIdx int - for i, str := range strings.Split(strings.TrimPrefix(got, "\n"), "\n") { - idx := strings.Index(str, "->") - if i != 0 { - if oldIdx != idx { - return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want) - } - } - oldIdx = idx - } - return nil - } - return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want) - } - tests := []test{ - { - name: "return string with stack trace initialized", - fields: fields{ - detail: Detail{ - Version: "1.0", - ServerName: "srv", - GitCommit: "commit", - BuildTime: "bt", - GoVersion: "1.1", - GoOS: "goos", - GoArch: "goarch", - GoRoot: "/usr/local/go", - CGOEnabled: cgoTrue, - AlgorithmInfo: "1.2", - BuildCPUInfoFlags: nil, - StackTrace: []StackTrace{ - { - URL: "url", - FuncName: "func", - File: "file", - Line: 10, - }, - }, - }, - }, - want: want{ - want: &Detail{ - Version: "1.0", - ServerName: "srv", - GitCommit: "commit", - BuildTime: "bt", - GoVersion: "1.1", - GoOS: "goos", - GoArch: "goarch", - GoRoot: "/usr/local/go", - CGOEnabled: cgoTrue, - AlgorithmInfo: "1.2", - BuildCPUInfoFlags: nil, - StackTrace: []StackTrace{ - { - URL: "url", - FuncName: "func", - File: "file", - Line: 10, - }, - }, - }, - }, - }, - { - name: "return string with no stack trace initialized", - fields: fields{ - detail: Detail{ - Version: "1.0", - ServerName: "srv", - GitCommit: "commit", - BuildTime: "bt", - GoVersion: "1.1", - GoOS: "goos", - GoArch: "goarch", - GoRoot: "/usr/local/go", - CGOEnabled: cgoTrue, - AlgorithmInfo: "1.2", - BuildCPUInfoFlags: nil, - StackTrace: []StackTrace{}, - }, - rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) { - return uintptr(0), "", 0, false - }, - }, - want: want{ - want: &Detail{ - Version: "1.0", - ServerName: "srv", - GitCommit: "commit", - BuildTime: "bt", - GoVersion: "1.1", - GoOS: "goos", - GoArch: "goarch", - GoRoot: "/usr/local/go", - CGOEnabled: cgoTrue, - AlgorithmInfo: "1.2", - BuildCPUInfoFlags: nil, - StackTrace: nil, - }, - }, - }, - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc(tt) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - i := info{ - detail: test.fields.detail, - rtCaller: test.fields.rtCaller, - rtFuncForPC: test.fields.rtFuncForPC, - } - - got := i.String() - if err := checkFunc(test.want, got); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func TestDetail_String(t *testing.T) { - type fields struct { - Version string - ServerName string - GitCommit string - BuildTime string - GoVersion string - GoOS string - GoArch string - CGOEnabled string - AlgorithmInfo string - BuildCPUInfoFlags []string - StackTrace []StackTrace - } - type want struct { - want *Detail - } - type test struct { - name string - fields fields - want want - checkFunc func(want, string) error - beforeFunc func() - afterFunc func(*testing.T) - } - defaultCheckFunc := func(w want, got string) error { - if got == w.want.String() { - // check the position of "->" - var oldIdx int - for i, str := range strings.Split(strings.TrimPrefix(got, "\n"), "\n") { - idx := strings.Index(str, "->") - if i != 0 { - if oldIdx != idx { - return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want) - } - } - oldIdx = idx - } - return nil - } - return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want) - } - tests := []test{ - { - name: "return string with stack trace initialized", - fields: fields{ - Version: "1.0", - ServerName: "srv", - GitCommit: "commit", - BuildTime: "bt", - GoVersion: "1.1", - GoOS: "goos", - GoArch: "goarch", - CGOEnabled: cgoTrue, - AlgorithmInfo: "1.2", - BuildCPUInfoFlags: nil, - StackTrace: []StackTrace{ - { - URL: "url", - FuncName: "func", - File: "file", - Line: 10, - }, - }, - }, - want: want{ - want: &Detail{ - Version: "1.0", - ServerName: "srv", - GitCommit: "commit", - BuildTime: "bt", - GoVersion: "1.1", - GoOS: "goos", - GoArch: "goarch", - CGOEnabled: cgoTrue, - AlgorithmInfo: "1.2", - BuildCPUInfoFlags: nil, - StackTrace: []StackTrace{ - { - URL: "url", - FuncName: "func", - File: "file", - Line: 10, - }, - }, - }, - }, - }, - { - name: "return string with no stack trace initialized", - fields: fields{ - Version: "1.0", - ServerName: "srv", - GitCommit: "commit", - BuildTime: "bt", - GoVersion: "1.1", - GoOS: "goos", - GoArch: "goarch", - CGOEnabled: cgoTrue, - AlgorithmInfo: "1.2", - BuildCPUInfoFlags: nil, - StackTrace: []StackTrace{}, - }, - want: want{ - want: &Detail{ - Version: "1.0", - ServerName: "srv", - GitCommit: "commit", - BuildTime: "bt", - GoVersion: "1.1", - GoOS: "goos", - GoArch: "goarch", - CGOEnabled: cgoTrue, - AlgorithmInfo: "1.2", - BuildCPUInfoFlags: nil, - StackTrace: nil, - }, - }, - }, - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc(tt) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - d := Detail{ - Version: test.fields.Version, - ServerName: test.fields.ServerName, - GitCommit: test.fields.GitCommit, - BuildTime: test.fields.BuildTime, - GoVersion: test.fields.GoVersion, - GoOS: test.fields.GoOS, - GoArch: test.fields.GoArch, - CGOEnabled: test.fields.CGOEnabled, - AlgorithmInfo: test.fields.AlgorithmInfo, - BuildCPUInfoFlags: test.fields.BuildCPUInfoFlags, - StackTrace: test.fields.StackTrace, - } - - got := d.String() - if err := checkFunc(test.want, got); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_info_Get(t *testing.T) { - type fields struct { - detail Detail - rtCaller func(skip int) (pc uintptr, file string, line int, ok bool) - rtFuncForPC func(pc uintptr) *runtime.Func - } - type want struct { - want Detail - } - type test struct { - name string - fields fields - want want - checkFunc func(want, Detail) error - beforeFunc func() - afterFunc func(*testing.T) - } - defaultCheckFunc := func(w want, got Detail) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want) - } - return nil - } - tests := []test{ - { - name: "return detail object with no stack trace", - fields: fields{ - rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) { - return uintptr(0), "", 0, false - }, - }, - want: want{ - want: Detail{ - ServerName: "", - Version: "", - GitCommit: GitCommit, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - StackTrace: []StackTrace{}, - AlgorithmInfo: AlgorithmInfo, - BuildTime: BuildTime, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - { - name: "return detail object with stack trace initialized", - fields: func() fields { - i := 0 - return fields{ - rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) { - if i == 0 { - i++ - return uintptr(0), "info_test.go", 100, true - } - return uintptr(1), "info_test.go", 100, false - }, - rtFuncForPC: func(ptr uintptr) *runtime.Func { - return runtime.FuncForPC(reflect.ValueOf(Test_info_Get).Pointer()) - }, - } - }(), - want: want{ - want: Detail{ - ServerName: "", - Version: "", - GitCommit: GitCommit, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - StackTrace: []StackTrace{ - { - URL: "https://github.com/vdaas/vald/tree/main", - FuncName: "github.com/vdaas/vald/internal/info.Test_info_Get", - File: "info_test.go", - Line: 100, - }, - }, - AlgorithmInfo: AlgorithmInfo, - BuildTime: BuildTime, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - { - name: "return detail object with the file name has goroot prefix", - fields: func() fields { - i := 0 - return fields{ - rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) { - if i == 0 { - i++ - return uintptr(0), runtime.GOROOT() + "/src/info_test.go", 100, true - } - return uintptr(1), "info_test.go", 100, false - }, - rtFuncForPC: func(ptr uintptr) *runtime.Func { - return runtime.FuncForPC(reflect.ValueOf(Test_info_Get).Pointer()) - }, - } - }(), - want: want{ - want: Detail{ - ServerName: "", - Version: "", - GitCommit: GitCommit, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - StackTrace: []StackTrace{ - { - URL: "https://github.com/golang/go/blob/" + runtime.Version() + "/src/info_test.go#L100", - FuncName: "github.com/vdaas/vald/internal/info.Test_info_Get", - File: runtime.GOROOT() + "/src/info_test.go", - Line: 100, - }, - }, - AlgorithmInfo: AlgorithmInfo, - BuildTime: BuildTime, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - { - name: "return detail object with the go mod path set", - fields: func() fields { - i := 0 - return fields{ - rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) { - if i == 0 { - i++ - return uintptr(0), "/tmp/go/pkg/mod/github.com/vdaas/vald/internal/info_test.go", 100, true - } - return uintptr(1), "info_test.go", 100, false - }, - rtFuncForPC: func(ptr uintptr) *runtime.Func { - return runtime.FuncForPC(reflect.ValueOf(Test_info_Get).Pointer()) - }, - } - }(), - want: want{ - want: Detail{ - Version: "", - GitCommit: GitCommit, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - StackTrace: []StackTrace{ - { - URL: "https://github.com/vdaas/vald/internal/info_test.go#L100", - FuncName: "github.com/vdaas/vald/internal/info.Test_info_Get", - File: "/tmp/go/pkg/mod/github.com/vdaas/vald/internal/info_test.go", - Line: 100, - }, - }, - AlgorithmInfo: AlgorithmInfo, - BuildTime: BuildTime, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - { - name: "return detail object with the go mod path with version set", - fields: func() fields { - i := 0 - return fields{ - rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) { - if i == 0 { - i++ - return uintptr(0), "/tmp/go/pkg/mod/github.com/vdaas@v0.0.0-20171023180738-a3a6125de932/vald/internal/info_test.go", 100, true - } - return uintptr(1), "info_test.go", 100, false - }, - rtFuncForPC: func(ptr uintptr) *runtime.Func { - return runtime.FuncForPC(reflect.ValueOf(Test_info_Get).Pointer()) - }, - } - }(), - want: want{ - want: Detail{ - Version: "", - GitCommit: GitCommit, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - StackTrace: []StackTrace{ - { - URL: "https://github.com/vdaas/blob/v0.0.0-20171023180738-a3a6125de932/vald/internal/info_test.go#L100", - FuncName: "github.com/vdaas/vald/internal/info.Test_info_Get", - File: "/tmp/go/pkg/mod/github.com/vdaas@v0.0.0-20171023180738-a3a6125de932/vald/internal/info_test.go", - Line: 100, - }, - }, - AlgorithmInfo: AlgorithmInfo, - BuildTime: BuildTime, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - { - name: "return detail object with the go mod path contains pseudo version", - fields: func() fields { - i := 0 - return fields{ - rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) { - if i == 0 { - i++ - return uintptr(0), "/tmp/go/pkg/mod/github.com/vdaas@v0.0.0-20171023180738-a3a6125de932-a843423387/vald/internal/info_test.go", 100, true - } - return uintptr(1), "info_test.go", 100, false - }, - rtFuncForPC: func(ptr uintptr) *runtime.Func { - return runtime.FuncForPC(reflect.ValueOf(Test_info_Get).Pointer()) - }, - } - }(), - want: want{ - want: Detail{ - Version: "", - GitCommit: GitCommit, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - StackTrace: []StackTrace{ - { - URL: "https://github.com/vdaas/blob/main/vald/internal/info_test.go#L100", - FuncName: "github.com/vdaas/vald/internal/info.Test_info_Get", - File: "/tmp/go/pkg/mod/github.com/vdaas@v0.0.0-20171023180738-a3a6125de932-a843423387/vald/internal/info_test.go", - Line: 100, - }, - }, - AlgorithmInfo: AlgorithmInfo, - BuildTime: BuildTime, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - { - name: "return detail object with the go src path set", - fields: func() fields { - i := 0 - return fields{ - rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) { - if i == 0 { - i++ - return uintptr(0), "/tmp/go/src/github.com/vdaas/vald/internal/info_test.go", 100, true - } - return uintptr(1), "info_test.go", 100, false - }, - rtFuncForPC: func(ptr uintptr) *runtime.Func { - return runtime.FuncForPC(reflect.ValueOf(Test_info_Get).Pointer()) - }, - } - }(), - want: want{ - want: Detail{ - Version: "", - GitCommit: GitCommit, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - StackTrace: []StackTrace{ - { - URL: "https://github.com/vdaas/vald/blob/main/internal/info_test.go#L100", - FuncName: "github.com/vdaas/vald/internal/info.Test_info_Get", - File: "/tmp/go/src/github.com/vdaas/vald/internal/info_test.go", - Line: 100, - }, - }, - AlgorithmInfo: AlgorithmInfo, - BuildTime: BuildTime, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc(tt) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - i := info{ - detail: test.fields.detail, - rtCaller: test.fields.rtCaller, - rtFuncForPC: test.fields.rtFuncForPC, - } - - got := i.Get() - if err := checkFunc(test.want, got); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_info_prepare(t *testing.T) { - type fields struct { - detail Detail - rtCaller func(skip int) (pc uintptr, file string, line int, ok bool) - rtFuncForPC func(pc uintptr) *runtime.Func - } - type want struct { - want info - } - type test struct { - name string - fields fields - want want - checkFunc func(info, want) error - beforeFunc func() - afterFunc func(*testing.T) - } - // skipcq: VET-V0008 - defaultCheckFunc := func(got info, w want) error { - opts := []comparator.Option{ - comparator.AllowUnexported(info{}), - comparator.IgnoreFields(info{}, "prepOnce"), - } - // skipcq: VET-V0008 - if diff := comparator.Diff(w.want, got, opts...); len(diff) != 0 { - return errors.Errorf("err: %s", diff) - } - return nil - } - tests := []*test{ - { - name: "set success with all fields are empty", - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "", - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with GitCommit set", - fields: fields{ - detail: Detail{ - GitCommit: "internal", - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/internal", - detail: Detail{ - GitCommit: "internal", - Version: "", - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with Version set", - fields: fields{ - detail: Detail{ - Version: "v1.0.0", - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "v1.0.0", - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with BuildTime set", - fields: fields{ - detail: Detail{ - BuildTime: "10s", - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "", - BuildTime: "10s", - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with GoVersion set", - fields: fields{ - detail: Detail{ - GoVersion: "1.14", - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "", - BuildTime: BuildTime, - GoVersion: "1.14", - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with GoOS set", - fields: fields{ - detail: Detail{ - GoOS: "linux", - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "", - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: "linux", - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with GoArch set", - fields: fields{ - detail: Detail{ - GoArch: "amd", - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "", - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: "amd", - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with CGOEnabled set as true", - fields: fields{ - detail: Detail{ - CGOEnabled: "1", - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "", - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoTrue, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with CGOEnabled set as false", - fields: fields{ - detail: Detail{ - CGOEnabled: "0", - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "", - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoFalse, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with AlgorithmInfo set", - fields: fields{ - detail: Detail{ - AlgorithmInfo: "v1.11.5", - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "", - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: "v1.11.5", - BuildCPUInfoFlags: func() []string { - if len(BuildCPUInfoFlags) == 0 { - return nil - } - return strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ") - }(), - }, - }, - }, - }, - { - name: "set success with BuildCPUInfoFlags set", - fields: fields{ - detail: Detail{ - BuildCPUInfoFlags: []string{"avx512f"}, - }, - }, - want: want{ - want: info{ - baseURL: "https://github.com/vdaas/vald/tree/main", - detail: Detail{ - GitCommit: GitCommit, - Version: "", - BuildTime: BuildTime, - GoVersion: runtime.Version(), - GoOS: runtime.GOOS, - GoArch: runtime.GOARCH, - GoRoot: runtime.GOROOT(), - CGOEnabled: cgoUnknown, - AlgorithmInfo: AlgorithmInfo, - BuildCPUInfoFlags: []string{"avx512f"}, - }, - }, - }, - }, - } - - for i := range tests { - test := tests[i] - t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc(tt) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - i := &info{ - detail: test.fields.detail, - rtCaller: test.fields.rtCaller, - rtFuncForPC: test.fields.rtFuncForPC, - } - i.prepare() - if err := checkFunc(*i, test.want); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func TestStackTrace_String(t *testing.T) { - type fields struct { - URL string - FuncName string - File string - Line int - } - type want struct { - want string - } - type test struct { - name string - fields fields - want want - checkFunc func(want, string) error - beforeFunc func() - afterFunc func(*testing.T) - } - 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{ - { - name: "return stack trace string", - fields: fields{ - URL: "https://github.com/golang/go/blob/v1.0.0/internal/info/info_test.go#L40", - FuncName: "TestStackTrace_String", - File: "info_test.go", - Line: 40, - }, - want: want{ - want: "URL: https://github.com/golang/go/blob/v1.0.0/internal/info/info_test.go#L40\tFile: info_test.go\tLine: #40\tFuncName: TestStackTrace_String", - }, - }, - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc(tt) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - s := StackTrace{ - URL: test.fields.URL, - FuncName: test.fields.FuncName, - File: test.fields.File, - Line: test.fields.Line, - } - - got := s.String() - if err := checkFunc(test.want, got); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -// NOT IMPLEMENTED BELOW +// got := i.Get() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } // // func Test_info_getDetail(t *testing.T) { // type fields struct { @@ -1827,7 +778,201 @@ func TestStackTrace_String(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_info_prepare(t *testing.T) { +// type fields struct { +// baseURL string +// detail Detail +// rtCaller func(skip int) (pc uintptr, file string, line int, ok bool) +// rtFuncForPC func(pc uintptr) *runtime.Func +// } +// 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 { +// baseURL:"", +// detail:Detail{}, +// rtCaller:nil, +// rtFuncForPC: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 { +// baseURL:"", +// detail:Detail{}, +// rtCaller:nil, +// rtFuncForPC: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 +// } +// i := &info{ +// baseURL: test.fields.baseURL, +// detail: test.fields.detail, +// rtCaller: test.fields.rtCaller, +// rtFuncForPC: test.fields.rtFuncForPC, +// } +// +// i.prepare() +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestStackTrace_String(t *testing.T) { +// type fields struct { +// URL string +// FuncName string +// File string +// Line int +// } +// 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 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 { +// URL:"", +// FuncName:"", +// File:"", +// Line:0, +// }, +// 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 { +// URL:"", +// FuncName:"", +// File:"", +// Line:0, +// }, +// 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 +// } +// s := StackTrace{ +// URL: test.fields.URL, +// FuncName: test.fields.FuncName, +// File: test.fields.File, +// Line: test.fields.Line, +// } // +// got := s.String() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/internal/info/option_test.go b/internal/info/option_test.go index b73b026daf..63c58e79b8 100644 --- a/internal/info/option_test.go +++ b/internal/info/option_test.go @@ -24,6 +24,11 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +// Goroutine leak is detected by `fastime`, but it should be ignored in the test because it is an external package. +var goleakIgnoreOptions = []goleak.Option{ + goleak.IgnoreTopFunction("github.com/kpango/fastime.(*fastime).StartTimerD.func1"), +} + func TestWithServerName(t *testing.T) { type T = info type args struct { diff --git a/internal/io/copy.go b/internal/io/copy.go index b7d1c7c6c2..a31a21b12f 100644 --- a/internal/io/copy.go +++ b/internal/io/copy.go @@ -58,7 +58,7 @@ func NewCopier(size int) Copier { atomic.StoreInt64(&c.bufSize, int64(defaultBufferSize)) } c.pool = sync.Pool{ - New: func() interface{} { + New: func() any { return bytes.NewBuffer(make([]byte, int(atomic.LoadInt64(&c.bufSize)))) }, } @@ -81,7 +81,9 @@ func (c *copier) CopyBuffer(dst io.Writer, src io.Reader, buf []byte) (written i return c.copyBuffer(dst, src, b) } -func (c *copier) copyBuffer(dst io.Writer, src io.Reader, buf *bytes.Buffer) (written int64, err error) { +func (c *copier) copyBuffer( + dst io.Writer, src io.Reader, buf *bytes.Buffer, +) (written int64, err error) { if dst == nil || src == nil { return 0, errors.New("empty source or destination") } diff --git a/internal/io/copy_test.go b/internal/io/copy_test.go index 9c3aafb88f..6f5cd48054 100644 --- a/internal/io/copy_test.go +++ b/internal/io/copy_test.go @@ -328,7 +328,7 @@ func Test_copier_Copy(t *testing.T) { bufSize: test.fields.bufSize, } c.pool = sync.Pool{ - New: func() interface{} { + New: func() any { return bytes.NewBuffer(make([]byte, int(atomic.LoadInt64(&c.bufSize)))) }, } @@ -437,7 +437,6 @@ func Test_copier_Copy(t *testing.T) { // if err := checkFunc(test.want, gotWritten, err, dst.String()); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -548,7 +547,6 @@ func Test_copier_Copy(t *testing.T) { // if err := checkFunc(test.want, gotWritten, err, dst.String()); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -659,7 +657,6 @@ func Test_copier_Copy(t *testing.T) { // if err := checkFunc(test.want, gotWritten, err, dst.String()); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/io/io.go b/internal/io/io.go index 51fb0fa637..13680c7924 100644 --- a/internal/io/io.go +++ b/internal/io/io.go @@ -48,7 +48,7 @@ var ( ErrShortBuffer = io.ErrShortBuffer bufferPool = sync.Pool{ - New: func() interface{} { + New: func() any { return bytes.NewBuffer(make([]byte, 0, bytes.MinRead*2)) }, } diff --git a/internal/io/io_test.go b/internal/io/io_test.go index 5e36958014..82fd55b922 100644 --- a/internal/io/io_test.go +++ b/internal/io/io_test.go @@ -867,7 +867,6 @@ func Test_ctxWriter_Close(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -959,7 +958,6 @@ func Test_ctxWriter_Close(t *testing.T) { // if err := checkFunc(test.want, gotN, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1049,7 +1047,6 @@ func Test_ctxWriter_Close(t *testing.T) { // if err := checkFunc(test.want, gotB, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/client/client.go b/internal/k8s/client/client.go index f02d15b7f7..a580438aec 100644 --- a/internal/k8s/client/client.go +++ b/internal/k8s/client/client.go @@ -117,7 +117,9 @@ func New(opts ...Option) (_ Client, err error) { return c, nil } -func (c *client) Get(ctx context.Context, name, namespace string, obj cli.Object, opts ...cli.GetOption) error { +func (c *client) Get( + ctx context.Context, name, namespace string, obj cli.Object, opts ...cli.GetOption, +) error { return c.withWatch.Get( ctx, cli.ObjectKey{ @@ -145,11 +147,15 @@ func (c *client) Update(ctx context.Context, obj k8s.Object, opts ...cli.UpdateO return c.withWatch.Update(ctx, obj, opts...) } -func (c *client) Patch(ctx context.Context, obj k8s.Object, patch cli.Patch, opts ...cli.PatchOption) error { +func (c *client) Patch( + ctx context.Context, obj k8s.Object, patch cli.Patch, opts ...cli.PatchOption, +) error { return c.withWatch.Patch(ctx, obj, patch, opts...) } -func (c *client) Watch(ctx context.Context, obj cli.ObjectList, opts ...k8s.ListOption) (watch.Interface, error) { +func (c *client) Watch( + ctx context.Context, obj cli.ObjectList, opts ...k8s.ListOption, +) (watch.Interface, error) { return c.withWatch.Watch(ctx, obj, opts...) } @@ -157,7 +163,9 @@ func (*client) MatchingLabels(labels map[string]string) cli.MatchingLabels { return cli.MatchingLabels(labels) } -func (*client) LabelSelector(key string, op selection.Operator, vals []string) (labels.Selector, error) { +func (*client) LabelSelector( + key string, op selection.Operator, vals []string, +) (labels.Selector, error) { requirements, err := labels.NewRequirement(key, op, vals) if err != nil { return nil, fmt.Errorf("failed to create requirement on creating label selector: %w", err) @@ -222,7 +230,9 @@ func NewPatcher(fieldManager string) (Patcher, error) { }, nil } -func (s *patcher) ApplyPodAnnotations(ctx context.Context, name, namespace string, entries map[string]string) error { +func (s *patcher) ApplyPodAnnotations( + ctx context.Context, name, namespace string, entries map[string]string, +) error { var podList corev1.PodList if err := s.client.List(ctx, &podList, &cli.ListOptions{ Namespace: namespace, @@ -235,7 +245,7 @@ func (s *patcher) ApplyPodAnnotations(ctx context.Context, name, namespace strin return errors.New("agent pod not found on exporting metrics") } - //nolint: gomnd + //nolint:gomnd if len(podList.Items) >= 2 { return errors.New("multiple agent pods found on exporting metrics. pods with same name exist in the same namespace?") } diff --git a/internal/k8s/client/client_test.go b/internal/k8s/client/client_test.go index 4922ef0952..20c2b43e9d 100644 --- a/internal/k8s/client/client_test.go +++ b/internal/k8s/client/client_test.go @@ -100,7 +100,6 @@ package client // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -115,7 +114,6 @@ package client // } // type fields struct { // scheme *runtime.Scheme -// reader cli.Reader // withWatch cli.WithWatch // } // type want struct { @@ -150,7 +148,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -178,7 +175,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -211,7 +207,6 @@ package client // } // c := &client{ // scheme: test.fields.scheme, -// reader: test.fields.reader, // withWatch: test.fields.withWatch, // } // @@ -219,7 +214,6 @@ package client // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -232,7 +226,6 @@ package client // } // type fields struct { // scheme *runtime.Scheme -// reader cli.Reader // withWatch cli.WithWatch // } // type want struct { @@ -265,7 +258,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -291,7 +283,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -324,7 +315,6 @@ package client // } // c := &client{ // scheme: test.fields.scheme, -// reader: test.fields.reader, // withWatch: test.fields.withWatch, // } // @@ -332,7 +322,6 @@ package client // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -340,12 +329,11 @@ package client // func Test_client_Create(t *testing.T) { // type args struct { // ctx context.Context -// obj Object -// opts []CreateOption +// obj k8s.Object +// opts []k8s.CreateOption // } // type fields struct { // scheme *runtime.Scheme -// reader cli.Reader // withWatch cli.WithWatch // } // type want struct { @@ -378,7 +366,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -404,7 +391,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -437,7 +423,6 @@ package client // } // c := &client{ // scheme: test.fields.scheme, -// reader: test.fields.reader, // withWatch: test.fields.withWatch, // } // @@ -445,7 +430,6 @@ package client // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -453,12 +437,11 @@ package client // func Test_client_Delete(t *testing.T) { // type args struct { // ctx context.Context -// obj Object +// obj k8s.Object // opts []cli.DeleteOption // } // type fields struct { // scheme *runtime.Scheme -// reader cli.Reader // withWatch cli.WithWatch // } // type want struct { @@ -491,7 +474,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -517,7 +499,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -550,7 +531,6 @@ package client // } // c := &client{ // scheme: test.fields.scheme, -// reader: test.fields.reader, // withWatch: test.fields.withWatch, // } // @@ -558,7 +538,6 @@ package client // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -566,12 +545,11 @@ package client // func Test_client_Update(t *testing.T) { // type args struct { // ctx context.Context -// obj Object +// obj k8s.Object // opts []cli.UpdateOption // } // type fields struct { // scheme *runtime.Scheme -// reader cli.Reader // withWatch cli.WithWatch // } // type want struct { @@ -604,7 +582,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -630,7 +607,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -663,7 +639,6 @@ package client // } // c := &client{ // scheme: test.fields.scheme, -// reader: test.fields.reader, // withWatch: test.fields.withWatch, // } // @@ -671,7 +646,117 @@ package client // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_client_Patch(t *testing.T) { +// type args struct { +// ctx context.Context +// obj k8s.Object +// patch cli.Patch +// opts []cli.PatchOption +// } +// type fields struct { +// scheme *runtime.Scheme +// withWatch cli.WithWatch +// } +// 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 { +// ctx:nil, +// obj:nil, +// patch:nil, +// opts:nil, +// }, +// fields: fields { +// scheme:nil, +// withWatch: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 { +// ctx:nil, +// obj:nil, +// patch:nil, +// opts:nil, +// }, +// fields: fields { +// scheme:nil, +// withWatch: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 +// } +// c := &client{ +// scheme: test.fields.scheme, +// withWatch: test.fields.withWatch, +// } +// +// err := c.Patch(test.args.ctx, test.args.obj, test.args.patch, test.args.opts...) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -680,11 +765,10 @@ package client // type args struct { // ctx context.Context // obj cli.ObjectList -// opts []ListOption +// opts []k8s.ListOption // } // type fields struct { // scheme *runtime.Scheme -// reader cli.Reader // withWatch cli.WithWatch // } // type want struct { @@ -721,7 +805,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -747,7 +830,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -780,7 +862,6 @@ package client // } // c := &client{ // scheme: test.fields.scheme, -// reader: test.fields.reader, // withWatch: test.fields.withWatch, // } // @@ -788,7 +869,108 @@ package client // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_client_MatchingLabels(t *testing.T) { +// type args struct { +// labels map[string]string +// } +// type fields struct { +// scheme *runtime.Scheme +// withWatch cli.WithWatch +// } +// type want struct { +// want cli.MatchingLabels +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, cli.MatchingLabels) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got cli.MatchingLabels) 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 { +// labels:nil, +// }, +// fields: fields { +// scheme:nil, +// withWatch: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 { +// labels:nil, +// }, +// fields: fields { +// scheme:nil, +// withWatch: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 +// } +// c := &client{ +// scheme: test.fields.scheme, +// withWatch: test.fields.withWatch, +// } // +// got := c.MatchingLabels(test.args.labels) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -801,7 +983,6 @@ package client // } // type fields struct { // scheme *runtime.Scheme -// reader cli.Reader // withWatch cli.WithWatch // } // type want struct { @@ -838,7 +1019,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -864,7 +1044,6 @@ package client // }, // fields: fields { // scheme:nil, -// reader:nil, // withWatch:nil, // }, // want: want{}, @@ -897,7 +1076,6 @@ package client // } // c := &client{ // scheme: test.fields.scheme, -// reader: test.fields.reader, // withWatch: test.fields.withWatch, // } // @@ -905,7 +1083,291 @@ package client // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func TestPodPredicates(t *testing.T) { +// type args struct { +// filter func(pod *corev1.Pod) bool +// } +// type want struct { +// want builder.Predicates +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, builder.Predicates) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got builder.Predicates) 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 { +// filter: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 { +// filter: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 := PodPredicates(test.args.filter) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestNewPatcher(t *testing.T) { +// type args struct { +// fieldManager string +// } +// type want struct { +// want Patcher +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Patcher, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Patcher, 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 { +// fieldManager:"", +// }, +// 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 { +// fieldManager:"", +// }, +// 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 := NewPatcher(test.args.fieldManager) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } // +// func Test_patcher_ApplyPodAnnotations(t *testing.T) { +// type args struct { +// ctx context.Context +// name string +// namespace string +// entries map[string]string +// } +// type fields struct { +// client Client +// fieldManager string +// } +// 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 { +// ctx:nil, +// name:"", +// namespace:"", +// entries:nil, +// }, +// fields: fields { +// client:nil, +// fieldManager:"", +// }, +// 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, +// name:"", +// namespace:"", +// entries:nil, +// }, +// fields: fields { +// client:nil, +// fieldManager:"", +// }, +// 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 +// } +// s := &patcher{ +// client: test.fields.client, +// fieldManager: test.fields.fieldManager, +// } +// +// err := s.ApplyPodAnnotations(test.args.ctx, test.args.name, test.args.namespace, test.args.entries) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/internal/k8s/client/option.go b/internal/k8s/client/option.go index cdde4fc2c1..31590191ac 100644 --- a/internal/k8s/client/option.go +++ b/internal/k8s/client/option.go @@ -17,9 +17,7 @@ // Package client is Kubernetes client for getting resource from Kubernetes cluster. package client -import ( - "sigs.k8s.io/controller-runtime/pkg/scheme" -) +import "sigs.k8s.io/controller-runtime/pkg/scheme" type Option func(*client) error diff --git a/internal/k8s/client/option_test.go b/internal/k8s/client/option_test.go index 0edcfd5612..8a61153abc 100644 --- a/internal/k8s/client/option_test.go +++ b/internal/k8s/client/option_test.go @@ -96,7 +96,6 @@ package client // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/job/job.go b/internal/k8s/job/job.go index d714900d69..db984ef28c 100644 --- a/internal/k8s/job/job.go +++ b/internal/k8s/job/job.go @@ -49,7 +49,7 @@ type reconciler struct { func New(opts ...Option) (JobWatcher, error) { r := &reconciler{ jobsByAppNamePool: sync.Pool{ - New: func() interface{} { + New: func() any { return make(map[string][]k8s.Job) }, }, @@ -72,7 +72,9 @@ func New(opts ...Option) (JobWatcher, error) { } // Reconcile implements k8s reconciliation loop to retrieve the Job information from k8s. -func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res reconcile.Result, err error) { +func (r *reconciler) Reconcile( + ctx context.Context, _ reconcile.Request, +) (res reconcile.Result, err error) { js := new(batchv1.JobList) err = r.mgr.GetClient().List(ctx, js, r.listOpts...) diff --git a/internal/k8s/job/job_test.go b/internal/k8s/job/job_test.go new file mode 100644 index 0000000000..76842b0c20 --- /dev/null +++ b/internal/k8s/job/job_test.go @@ -0,0 +1,799 @@ +// 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 job + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want JobWatcher +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, JobWatcher, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got JobWatcher, 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 Test_reconciler_Reconcile(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 reconcile.Request +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string][]k8s.Job) +// listOpts []client.ListOption +// } +// type want struct { +// wantRes reconcile.Result +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, reconcile.Result, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes reconcile.Result, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// listOpts: test.fields.listOpts, +// } +// +// gotRes, err := r.Reconcile(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_GetName(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string][]k8s.Job) +// listOpts []client.ListOption +// } +// 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 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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// listOpts: test.fields.listOpts, +// } +// +// got := r.GetName() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_NewReconciler(t *testing.T) { +// type args struct { +// in0 context.Context +// mgr manager.Manager +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string][]k8s.Job) +// listOpts []client.ListOption +// } +// type want struct { +// want reconcile.Reconciler +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, reconcile.Reconciler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got reconcile.Reconciler) 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 { +// in0:nil, +// mgr:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 { +// in0:nil, +// mgr:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// listOpts: test.fields.listOpts, +// } +// +// got := r.NewReconciler(test.args.in0, test.args.mgr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_For(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string][]k8s.Job) +// listOpts []client.ListOption +// } +// type want struct { +// want client.Object +// want1 []builder.ForOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, []builder.ForOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 []builder.ForOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// listOpts: test.fields.listOpts, +// } +// +// got, got1 := r.For() +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Owns(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string][]k8s.Job) +// listOpts []client.ListOption +// } +// type want struct { +// want client.Object +// want1 []builder.OwnsOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, []builder.OwnsOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 []builder.OwnsOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// listOpts: test.fields.listOpts, +// } +// +// got, got1 := r.Owns() +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Watches(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string][]k8s.Job) +// listOpts []client.ListOption +// } +// type want struct { +// want client.Object +// want1 handler.EventHandler +// want2 []builder.WatchesOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, handler.EventHandler, []builder.WatchesOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 handler.EventHandler, got2 []builder.WatchesOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// if !reflect.DeepEqual(got2, w.want2) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got2, w.want2) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// listOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// listOpts: test.fields.listOpts, +// } +// +// got, got1, got2 := r.Watches() +// if err := checkFunc(test.want, got, got1, got2); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/job/option_test.go b/internal/k8s/job/option_test.go new file mode 100644 index 0000000000..9be60f211b --- /dev/null +++ b/internal/k8s/job/option_test.go @@ -0,0 +1,441 @@ +// 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 job + +// NOT IMPLEMENTED BELOW +// +// func TestWithControllerName(t *testing.T) { +// type args struct { +// name 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithControllerName(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithManager(t *testing.T) { +// type args struct { +// mgr manager.Manager +// } +// 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 { +// mgr: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 { +// mgr: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 := WithManager(test.args.mgr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithNamespaces(t *testing.T) { +// type args struct { +// nss []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 { +// nss: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 { +// nss: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 := WithNamespaces(test.args.nss...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOnErrorFunc(t *testing.T) { +// type args struct { +// f func(err error) +// } +// 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 { +// f: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 { +// f: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 := WithOnErrorFunc(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOnReconcileFunc(t *testing.T) { +// type args struct { +// f func(ctx context.Context, jobList map[string][]k8s.Job) +// } +// 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 { +// f: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 { +// f: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 := WithOnReconcileFunc(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/metrics/node/node.go b/internal/k8s/metrics/node/node.go index ab8fb8eb4e..ae4eeacb27 100644 --- a/internal/k8s/metrics/node/node.go +++ b/internal/k8s/metrics/node/node.go @@ -69,7 +69,9 @@ func (r *reconciler) addListOpts(opt client.ListOption) { r.lopts = append(r.lopts, opt) } -func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res reconcile.Result, err error) { +func (r *reconciler) Reconcile( + ctx context.Context, _ reconcile.Request, +) (res reconcile.Result, err error) { m := &metrics.NodeMetricsList{} if r.lopts != nil { diff --git a/internal/k8s/metrics/node/node_test.go b/internal/k8s/metrics/node/node_test.go index ac8b42d13b..51b1c34efc 100644 --- a/internal/k8s/metrics/node/node_test.go +++ b/internal/k8s/metrics/node/node_test.go @@ -100,7 +100,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -117,8 +116,7 @@ package node // onReconcile func(nodeList map[string]Node) // lopts []client.ListOption // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -340,7 +338,6 @@ package node // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -449,7 +446,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -571,7 +567,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -684,7 +679,6 @@ package node // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -797,7 +791,6 @@ package node // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -914,7 +907,6 @@ package node // if err := checkFunc(test.want, got, got1, got2); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/metrics/node/option_test.go b/internal/k8s/metrics/node/option_test.go index 515b2d1c55..cbd61cd169 100644 --- a/internal/k8s/metrics/node/option_test.go +++ b/internal/k8s/metrics/node/option_test.go @@ -100,7 +100,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/metrics/pod/option_test.go b/internal/k8s/metrics/pod/option_test.go index ce531f040b..18b326fbff 100644 --- a/internal/k8s/metrics/pod/option_test.go +++ b/internal/k8s/metrics/pod/option_test.go @@ -100,7 +100,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/metrics/pod/pod.go b/internal/k8s/metrics/pod/pod.go index 6eb1e46844..398861fa23 100644 --- a/internal/k8s/metrics/pod/pod.go +++ b/internal/k8s/metrics/pod/pod.go @@ -69,7 +69,9 @@ func (r *reconciler) addListOpts(opt client.ListOption) { r.lopts = append(r.lopts, opt) } -func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res reconcile.Result, err error) { +func (r *reconciler) Reconcile( + ctx context.Context, _ reconcile.Request, +) (res reconcile.Result, err error) { m := &metrics.PodMetricsList{} if r.lopts != nil { diff --git a/internal/k8s/metrics/pod/pod_test.go b/internal/k8s/metrics/pod/pod_test.go index 4769484949..4b7b99f10b 100644 --- a/internal/k8s/metrics/pod/pod_test.go +++ b/internal/k8s/metrics/pod/pod_test.go @@ -100,7 +100,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -117,8 +116,7 @@ package pod // onReconcile func(podList map[string]Pod) // lopts []client.ListOption // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -340,7 +338,6 @@ package pod // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -449,7 +446,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -571,7 +567,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -684,7 +679,6 @@ package pod // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -797,7 +791,6 @@ package pod // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -914,7 +907,6 @@ package pod // if err := checkFunc(test.want, got, got1, got2); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/node/node.go b/internal/k8s/node/node.go index 5a9d649666..8d5d57452f 100644 --- a/internal/k8s/node/node.go +++ b/internal/k8s/node/node.go @@ -73,7 +73,9 @@ func (r *reconciler) addListOpts(opt client.ListOption) { r.lopts = append(r.lopts, opt) } -func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res reconcile.Result, err error) { +func (r *reconciler) Reconcile( + ctx context.Context, _ reconcile.Request, +) (res reconcile.Result, err error) { ns := &corev1.NodeList{} if r.lopts != nil { @@ -91,10 +93,11 @@ func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res re RequeueAfter: time.Millisecond * 100, } if errors.IsNotFound(err) { - res = reconcile.Result{ + log.Errorf("not found: %s", err) + return reconcile.Result{ Requeue: true, RequeueAfter: time.Second, - } + }, nil } return } @@ -149,12 +152,12 @@ func (r *reconciler) GetName() string { return r.name } -func (r *reconciler) NewReconciler(_ context.Context, mgr manager.Manager) reconcile.Reconciler { +func (r *reconciler) NewReconciler(ctx context.Context, mgr manager.Manager) reconcile.Reconciler { if r.mgr == nil && mgr != nil { r.mgr = mgr } corev1.AddToScheme(r.mgr.GetScheme()) - if err := r.mgr.GetFieldIndexer().IndexField(context.Background(), &corev1.Node{}, "status.phase", func(obj client.Object) []string { + if err := r.mgr.GetFieldIndexer().IndexField(ctx, &corev1.Node{}, "status.phase", func(obj client.Object) []string { node, ok := obj.(*corev1.Node) if !ok || node.GetDeletionTimestamp() != nil { return nil diff --git a/internal/k8s/node/node_test.go b/internal/k8s/node/node_test.go index f779c710f4..05d0bbb442 100644 --- a/internal/k8s/node/node_test.go +++ b/internal/k8s/node/node_test.go @@ -17,9 +17,7 @@ // Package node provides kubernetes node information and preriodically update package node -import ( - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" -) +import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // NOT IMPLEMENTED BELOW // @@ -104,7 +102,6 @@ import ( // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -121,8 +118,7 @@ import ( // onReconcile func(nodes []Node) // lopts []client.ListOption // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -344,7 +340,6 @@ import ( // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -453,14 +448,13 @@ import ( // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func Test_reconciler_NewReconciler(t *testing.T) { // type args struct { -// in0 context.Context +// ctx context.Context // mgr manager.Manager // } // type fields struct { @@ -495,7 +489,7 @@ import ( // { // name: "test_case_1", // args: args { -// in0:nil, +// ctx:nil, // mgr:nil, // }, // fields: fields { @@ -523,7 +517,7 @@ import ( // return test { // name: "test_case_2", // args: args { -// in0:nil, +// ctx:nil, // mgr:nil, // }, // fields: fields { @@ -571,11 +565,10 @@ import ( // lopts: test.fields.lopts, // } // -// got := r.NewReconciler(test.args.in0, test.args.mgr) +// got := r.NewReconciler(test.args.ctx, test.args.mgr) // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -688,7 +681,6 @@ import ( // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -801,7 +793,6 @@ import ( // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -918,7 +909,6 @@ import ( // if err := checkFunc(test.want, got, got1, got2); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/node/option_test.go b/internal/k8s/node/option_test.go index 0be488383d..8ae464455b 100644 --- a/internal/k8s/node/option_test.go +++ b/internal/k8s/node/option_test.go @@ -100,7 +100,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package node // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/option_test.go b/internal/k8s/option_test.go index cda300deba..ea4305949e 100644 --- a/internal/k8s/option_test.go +++ b/internal/k8s/option_test.go @@ -100,7 +100,6 @@ package k8s // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package k8s // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package k8s // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package k8s // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,97 +440,26 @@ package k8s // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func TestWithEnableLeaderElection(t *testing.T) { -// type want struct { -// want Option -// } -// type test struct { -// name string -// want want -// checkFunc func(want, Option) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) -// } -// 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", -// 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 -// } -// -// got := WithEnableLeaderElection() -// if err := checkFunc(test.want, got); err != nil { -// tt.Errorf("error = %v", err) -// } -// -// }) +// func TestWithLeaderElection(t *testing.T) { +// type args struct { +// enabled bool +// id string +// namespace string // } -// } -// -// func TestWithDisableLeaderElection(t *testing.T) { // type want struct { // want Option // } // type test struct { // name string +// args args // want want // checkFunc func(want, Option) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) // } // defaultCheckFunc := func(w want, got Option) error { // if !reflect.DeepEqual(got, w.want) { @@ -547,12 +472,17 @@ package k8s // /* // { // name: "test_case_1", +// args: args { +// enabled:false, +// id:"", +// namespace:"", +// }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // }, @@ -563,12 +493,17 @@ package k8s // func() test { // return test { // name: "test_case_2", +// args: args { +// enabled:false, +// id:"", +// namespace:"", +// }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // } @@ -582,21 +517,20 @@ package k8s // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt) +// test.beforeFunc(tt, test.args) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt) +// defer test.afterFunc(tt, test.args) // } // checkFunc := test.checkFunc // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } // -// got := WithDisableLeaderElection() +// got := WithLeaderElection(test.args.enabled, test.args.id, test.args.namespace) // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -682,7 +616,6 @@ package k8s // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/pod/option_test.go b/internal/k8s/pod/option_test.go index 713eef90de..6f4c475fc3 100644 --- a/internal/k8s/pod/option_test.go +++ b/internal/k8s/pod/option_test.go @@ -100,7 +100,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,14 +270,13 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func TestWithOnReconcileFunc(t *testing.T) { // type args struct { -// f func(podList map[string][]Pod) +// f func(ctx context.Context, podList map[string][]Pod) // } // type want struct { // want Option @@ -358,7 +355,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/pod/pod.go b/internal/k8s/pod/pod.go index 1229f1620c..065ec1419c 100644 --- a/internal/k8s/pod/pod.go +++ b/internal/k8s/pod/pod.go @@ -76,7 +76,9 @@ func (r *reconciler) addListOpts(opt client.ListOption) { r.lopts = append(r.lopts, opt) } -func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res reconcile.Result, err error) { +func (r *reconciler) Reconcile( + ctx context.Context, _ reconcile.Request, +) (res reconcile.Result, err error) { ps := &corev1.PodList{} if r.lopts != nil { diff --git a/internal/k8s/pod/pod_test.go b/internal/k8s/pod/pod_test.go index 267e56e970..499ce84a90 100644 --- a/internal/k8s/pod/pod_test.go +++ b/internal/k8s/pod/pod_test.go @@ -100,7 +100,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -114,11 +113,10 @@ package pod // name string // namespace string // onError func(err error) -// onReconcile func(podList map[string][]Pod) +// onReconcile func(ctx context.Context, podList map[string][]Pod) // lopts []client.ListOption // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -229,7 +227,7 @@ package pod // name string // namespace string // onError func(err error) -// onReconcile func(podList map[string][]Pod) +// onReconcile func(ctx context.Context, podList map[string][]Pod) // lopts []client.ListOption // } // type want struct { @@ -340,7 +338,6 @@ package pod // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -351,7 +348,7 @@ package pod // name string // namespace string // onError func(err error) -// onReconcile func(podList map[string][]Pod) +// onReconcile func(ctx context.Context, podList map[string][]Pod) // lopts []client.ListOption // } // type want struct { @@ -449,7 +446,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -464,7 +460,7 @@ package pod // name string // namespace string // onError func(err error) -// onReconcile func(podList map[string][]Pod) +// onReconcile func(ctx context.Context, podList map[string][]Pod) // lopts []client.ListOption // } // type want struct { @@ -571,7 +567,6 @@ package pod // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -582,7 +577,7 @@ package pod // name string // namespace string // onError func(err error) -// onReconcile func(podList map[string][]Pod) +// onReconcile func(ctx context.Context, podList map[string][]Pod) // lopts []client.ListOption // } // type want struct { @@ -684,7 +679,6 @@ package pod // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -695,7 +689,7 @@ package pod // name string // namespace string // onError func(err error) -// onReconcile func(podList map[string][]Pod) +// onReconcile func(ctx context.Context, podList map[string][]Pod) // lopts []client.ListOption // } // type want struct { @@ -797,7 +791,6 @@ package pod // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -808,7 +801,7 @@ package pod // name string // namespace string // onError func(err error) -// onReconcile func(podList map[string][]Pod) +// onReconcile func(ctx context.Context, podList map[string][]Pod) // lopts []client.ListOption // } // type want struct { @@ -914,7 +907,6 @@ package pod // if err := checkFunc(test.want, got, got1, got2); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/reconciler_test.go b/internal/k8s/reconciler_test.go index 42e071211e..deb583f401 100644 --- a/internal/k8s/reconciler_test.go +++ b/internal/k8s/reconciler_test.go @@ -104,7 +104,6 @@ package k8s // if err := checkFunc(test.want, gotCl, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -114,13 +113,15 @@ package k8s // ctx context.Context // } // type fields struct { -// eg errgroup.Group -// name string -// merticsAddr string -// leaderElection bool -// mgr manager.Manager -// rcs []ResourceController -// der net.Dialer +// eg errgroup.Group +// name string +// merticsAddr string +// leaderElection bool +// leaderElectionID string +// leaderElectionNamespace string +// mgr manager.Manager +// rcs []ResourceController +// der net.Dialer // } // type want struct { // want <-chan error @@ -157,6 +158,8 @@ package k8s // name:"", // merticsAddr:"", // leaderElection:false, +// leaderElectionID:"", +// leaderElectionNamespace:"", // mgr:nil, // rcs:nil, // der:nil, @@ -185,6 +188,8 @@ package k8s // name:"", // merticsAddr:"", // leaderElection:false, +// leaderElectionID:"", +// leaderElectionNamespace:"", // mgr:nil, // rcs:nil, // der:nil, @@ -218,20 +223,141 @@ package k8s // checkFunc = defaultCheckFunc // } // c := &controller{ -// eg: test.fields.eg, -// name: test.fields.name, -// merticsAddr: test.fields.merticsAddr, -// leaderElection: test.fields.leaderElection, -// mgr: test.fields.mgr, -// rcs: test.fields.rcs, -// der: test.fields.der, +// eg: test.fields.eg, +// name: test.fields.name, +// merticsAddr: test.fields.merticsAddr, +// leaderElection: test.fields.leaderElection, +// leaderElectionID: test.fields.leaderElectionID, +// leaderElectionNamespace: test.fields.leaderElectionNamespace, +// mgr: test.fields.mgr, +// rcs: test.fields.rcs, +// der: test.fields.der, // } // // got, err := c.Start(test.args.ctx) // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_controller_GetManager(t *testing.T) { +// type fields struct { +// eg errgroup.Group +// name string +// merticsAddr string +// leaderElection bool +// leaderElectionID string +// leaderElectionNamespace string +// mgr manager.Manager +// rcs []ResourceController +// der net.Dialer +// } +// type want struct { +// want Manager +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, Manager) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got Manager) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// eg:nil, +// name:"", +// merticsAddr:"", +// leaderElection:false, +// leaderElectionID:"", +// leaderElectionNamespace:"", +// mgr:nil, +// rcs:nil, +// der: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 { +// eg:nil, +// name:"", +// merticsAddr:"", +// leaderElection:false, +// leaderElectionID:"", +// leaderElectionNamespace:"", +// mgr:nil, +// rcs:nil, +// der: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 +// } +// c := &controller{ +// eg: test.fields.eg, +// name: test.fields.name, +// merticsAddr: test.fields.merticsAddr, +// leaderElection: test.fields.leaderElection, +// leaderElectionID: test.fields.leaderElectionID, +// leaderElectionNamespace: test.fields.leaderElectionNamespace, +// mgr: test.fields.mgr, +// rcs: test.fields.rcs, +// der: test.fields.der, +// } // +// got := c.GetManager() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/internal/k8s/service/option_test.go b/internal/k8s/service/option_test.go index a78b92fca6..7855f2d308 100644 --- a/internal/k8s/service/option_test.go +++ b/internal/k8s/service/option_test.go @@ -96,7 +96,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -440,7 +436,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +521,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -612,7 +606,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/service/service.go b/internal/k8s/service/service.go index f15b62d4dd..0a499ac483 100644 --- a/internal/k8s/service/service.go +++ b/internal/k8s/service/service.go @@ -94,7 +94,9 @@ func extractAPIPorts(ports []corev1.ServicePort) []servicePort { } // Reconcile reconciles the service resources and put the information into the Service struct. -func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res reconcile.Result, err error) { +func (r *reconciler) Reconcile( + ctx context.Context, _ reconcile.Request, +) (res reconcile.Result, err error) { svcList := &corev1.ServiceList{} if r.lopts != nil { diff --git a/internal/k8s/service/service_test.go b/internal/k8s/service/service_test.go index 390d2bbdcb..e6e0a3d5b3 100644 --- a/internal/k8s/service/service_test.go +++ b/internal/k8s/service/service_test.go @@ -270,7 +270,6 @@ func Test_extractAPIPorts(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -287,8 +286,7 @@ func Test_extractAPIPorts(t *testing.T) { // onReconcile func(svcs []Service) // lopts []client.ListOption // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -510,12 +508,10 @@ func Test_extractAPIPorts(t *testing.T) { // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// // func Test_reconciler_GetName(t *testing.T) { // type fields struct { // mgr manager.Manager @@ -620,7 +616,6 @@ func Test_extractAPIPorts(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -742,7 +737,6 @@ func Test_extractAPIPorts(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -855,7 +849,6 @@ func Test_extractAPIPorts(t *testing.T) { // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -968,7 +961,6 @@ func Test_extractAPIPorts(t *testing.T) { // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1085,7 +1077,6 @@ func Test_extractAPIPorts(t *testing.T) { // if err := checkFunc(test.want, got, got1, got2); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/k8s/v2/pod/option.go b/internal/k8s/v2/pod/option.go index 88839d4395..b6bb554763 100644 --- a/internal/k8s/v2/pod/option.go +++ b/internal/k8s/v2/pod/option.go @@ -52,7 +52,9 @@ func WithOnErrorFunc(f func(err error)) Option { } } -func WithOnReconcileFunc(f func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error)) Option { +func WithOnReconcileFunc( + f func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error), +) Option { return func(r *reconciler) error { r.onReconcile = f return nil diff --git a/internal/k8s/v2/pod/option_test.go b/internal/k8s/v2/pod/option_test.go new file mode 100644 index 0000000000..fcebb618cc --- /dev/null +++ b/internal/k8s/v2/pod/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 pod + +// NOT IMPLEMENTED BELOW +// +// func TestWithControllerName(t *testing.T) { +// type args struct { +// name 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithControllerName(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithManager(t *testing.T) { +// type args struct { +// mgr manager.Manager +// } +// 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 { +// mgr: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 { +// mgr: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 := WithManager(test.args.mgr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOnErrorFunc(t *testing.T) { +// type args struct { +// f func(err error) +// } +// 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 { +// f: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 { +// f: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 := WithOnErrorFunc(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOnReconcileFunc(t *testing.T) { +// type args struct { +// f func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error) +// } +// 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 { +// f: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 { +// f: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 := WithOnReconcileFunc(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithNamespace(t *testing.T) { +// type args struct { +// ns 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 { +// ns:"", +// }, +// 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 { +// ns:"", +// }, +// 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 := WithNamespace(test.args.ns) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithLabels(t *testing.T) { +// type args struct { +// ls map[string]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 { +// ls: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 { +// ls: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 := WithLabels(test.args.ls) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithFields(t *testing.T) { +// type args struct { +// fs map[string]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 { +// fs: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 { +// fs: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 := WithFields(test.args.fs) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithForOpts(t *testing.T) { +// type args struct { +// fopts []builder.ForOption +// } +// 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 { +// fopts: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 { +// fopts: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 := WithForOpts(test.args.fopts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/v2/pod/pod.go b/internal/k8s/v2/pod/pod.go index e24cf48e19..7ec2e1b2ff 100644 --- a/internal/k8s/v2/pod/pod.go +++ b/internal/k8s/v2/pod/pod.go @@ -74,7 +74,9 @@ func (r *reconciler) addListOpts(opt client.ListOption) { r.lopts = append(r.lopts, opt) } -func (r *reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { +func (r *reconciler) Reconcile( + ctx context.Context, req reconcile.Request, +) (reconcile.Result, error) { var pod corev1.Pod r.mgr.GetClient().Get(ctx, req.NamespacedName, &pod) if r.onReconcile != nil { diff --git a/internal/k8s/v2/pod/pod_test.go b/internal/k8s/v2/pod/pod_test.go new file mode 100644 index 0000000000..7e4dcc3392 --- /dev/null +++ b/internal/k8s/v2/pod/pod_test.go @@ -0,0 +1,936 @@ +// 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 pod + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want PodWatcher +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, PodWatcher) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got PodWatcher) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_addListOpts(t *testing.T) { +// type args struct { +// opt client.ListOption +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespace string +// onError func(err error) +// onReconcile func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error) +// lopts []client.ListOption +// forOpts []builder.ForOption +// } +// 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 { +// opt:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 { +// opt:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespace: test.fields.namespace, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// forOpts: test.fields.forOpts, +// } +// +// r.addListOpts(test.args.opt) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Reconcile(t *testing.T) { +// type args struct { +// ctx context.Context +// req reconcile.Request +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespace string +// onError func(err error) +// onReconcile func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error) +// lopts []client.ListOption +// forOpts []builder.ForOption +// } +// type want struct { +// want reconcile.Result +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, reconcile.Result, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got reconcile.Result, 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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespace: test.fields.namespace, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// forOpts: test.fields.forOpts, +// } +// +// got, err := r.Reconcile(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_GetName(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespace string +// onError func(err error) +// onReconcile func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error) +// lopts []client.ListOption +// forOpts []builder.ForOption +// } +// 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 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 { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespace: test.fields.namespace, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// forOpts: test.fields.forOpts, +// } +// +// got := r.GetName() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_NewReconciler(t *testing.T) { +// type args struct { +// ctx context.Context +// mgr manager.Manager +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespace string +// onError func(err error) +// onReconcile func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error) +// lopts []client.ListOption +// forOpts []builder.ForOption +// } +// type want struct { +// want reconcile.Reconciler +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, reconcile.Reconciler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got reconcile.Reconciler) 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 { +// ctx:nil, +// mgr:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 { +// ctx:nil, +// mgr:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespace: test.fields.namespace, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// forOpts: test.fields.forOpts, +// } +// +// got := r.NewReconciler(test.args.ctx, test.args.mgr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_For(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespace string +// onError func(err error) +// onReconcile func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error) +// lopts []client.ListOption +// forOpts []builder.ForOption +// } +// type want struct { +// want client.Object +// want1 []builder.ForOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, []builder.ForOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 []builder.ForOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespace: test.fields.namespace, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// forOpts: test.fields.forOpts, +// } +// +// got, got1 := r.For() +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Owns(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespace string +// onError func(err error) +// onReconcile func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error) +// lopts []client.ListOption +// forOpts []builder.ForOption +// } +// type want struct { +// want client.Object +// want1 []builder.OwnsOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, []builder.OwnsOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 []builder.OwnsOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespace: test.fields.namespace, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// forOpts: test.fields.forOpts, +// } +// +// got, got1 := r.Owns() +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Watches(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespace string +// onError func(err error) +// onReconcile func(ctx context.Context, pod *corev1.Pod) (reconcile.Result, error) +// lopts []client.ListOption +// forOpts []builder.ForOption +// } +// type want struct { +// want client.Object +// want1 handler.EventHandler +// want2 []builder.WatchesOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, handler.EventHandler, []builder.WatchesOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 handler.EventHandler, got2 []builder.WatchesOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// if !reflect.DeepEqual(got2, w.want2) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got2, w.want2) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 { +// mgr:nil, +// name:"", +// namespace:"", +// onError:nil, +// onReconcile:nil, +// lopts:nil, +// forOpts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespace: test.fields.namespace, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// forOpts: test.fields.forOpts, +// } +// +// got, got1, got2 := r.Watches() +// if err := checkFunc(test.want, got, got1, got2); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/benchmark/api/v1/job_types_test.go b/internal/k8s/vald/benchmark/api/v1/job_types_test.go new file mode 100644 index 0000000000..8cbf2867cc --- /dev/null +++ b/internal/k8s/vald/benchmark/api/v1/job_types_test.go @@ -0,0 +1,1559 @@ +// 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 v1 + +// NOT IMPLEMENTED BELOW +// +// func TestBenchmarkDataset_DeepCopyInto(t *testing.T) { +// type args struct { +// out *BenchmarkDataset +// } +// type want struct{} +// type test struct { +// name string +// args args +// in *BenchmarkDataset +// 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 { +// out: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 { +// out: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 +// } +// +// test.in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkDataset_DeepCopy(t *testing.T) { +// type want struct { +// want *BenchmarkDataset +// } +// type test struct { +// name string +// in *BenchmarkDataset +// want want +// checkFunc func(want, *BenchmarkDataset) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkDataset) 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", +// 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 +// } +// +// got := test.in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkDatasetRange_DeepCopyInto(t *testing.T) { +// type args struct { +// out *BenchmarkDatasetRange +// } +// type want struct{} +// type test struct { +// name string +// args args +// in *BenchmarkDatasetRange +// 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 { +// out: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 { +// out: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 +// } +// +// test.in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkDatasetRange_DeepCopy(t *testing.T) { +// type want struct { +// want *BenchmarkDatasetRange +// } +// type test struct { +// name string +// in *BenchmarkDatasetRange +// want want +// checkFunc func(want, *BenchmarkDatasetRange) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkDatasetRange) 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", +// 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 +// } +// +// got := test.in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkJobRule_DeepCopyInto(t *testing.T) { +// type args struct { +// out *BenchmarkJobRule +// } +// type want struct{} +// type test struct { +// name string +// args args +// in *BenchmarkJobRule +// 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 { +// out: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 { +// out: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 +// } +// +// test.in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkJobRule_DeepCopy(t *testing.T) { +// type want struct { +// want *BenchmarkJobRule +// } +// type test struct { +// name string +// in *BenchmarkJobRule +// want want +// checkFunc func(want, *BenchmarkJobRule) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkJobRule) 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", +// 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 +// } +// +// got := test.in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkJobSpec_DeepCopyInto(t *testing.T) { +// type args struct { +// out *BenchmarkJobSpec +// } +// type fields struct { +// GlobalConfig *config.GlobalConfig +// ServerConfig *config.Servers +// Target *BenchmarkTarget +// Dataset *BenchmarkDataset +// Replica int +// Repetition int +// JobType string +// InsertConfig *config.InsertConfig +// UpdateConfig *config.UpdateConfig +// UpsertConfig *config.UpsertConfig +// SearchConfig *config.SearchConfig +// RemoveConfig *config.RemoveConfig +// ObjectConfig *config.ObjectConfig +// ClientConfig *config.GRPCClient +// Rules []*config.BenchmarkJobRule +// RPS int +// ConcurrencyLimit int +// TTLSecondsAfterFinished int +// } +// 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 { +// out:BenchmarkJobSpec{}, +// }, +// fields: fields { +// GlobalConfig:nil, +// ServerConfig:nil, +// Target:nil, +// Dataset:nil, +// Replica:0, +// Repetition:0, +// JobType:"", +// InsertConfig:nil, +// UpdateConfig:nil, +// UpsertConfig:nil, +// SearchConfig:nil, +// RemoveConfig:nil, +// ObjectConfig:nil, +// ClientConfig:nil, +// Rules:nil, +// RPS:0, +// ConcurrencyLimit:0, +// TTLSecondsAfterFinished: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 { +// out:BenchmarkJobSpec{}, +// }, +// fields: fields { +// GlobalConfig:nil, +// ServerConfig:nil, +// Target:nil, +// Dataset:nil, +// Replica:0, +// Repetition:0, +// JobType:"", +// InsertConfig:nil, +// UpdateConfig:nil, +// UpsertConfig:nil, +// SearchConfig:nil, +// RemoveConfig:nil, +// ObjectConfig:nil, +// ClientConfig:nil, +// Rules:nil, +// RPS:0, +// ConcurrencyLimit:0, +// TTLSecondsAfterFinished: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 +// } +// in := &BenchmarkJobSpec{ +// GlobalConfig: test.fields.GlobalConfig, +// ServerConfig: test.fields.ServerConfig, +// Target: test.fields.Target, +// Dataset: test.fields.Dataset, +// Replica: test.fields.Replica, +// Repetition: test.fields.Repetition, +// JobType: test.fields.JobType, +// InsertConfig: test.fields.InsertConfig, +// UpdateConfig: test.fields.UpdateConfig, +// UpsertConfig: test.fields.UpsertConfig, +// SearchConfig: test.fields.SearchConfig, +// RemoveConfig: test.fields.RemoveConfig, +// ObjectConfig: test.fields.ObjectConfig, +// ClientConfig: test.fields.ClientConfig, +// Rules: test.fields.Rules, +// RPS: test.fields.RPS, +// ConcurrencyLimit: test.fields.ConcurrencyLimit, +// TTLSecondsAfterFinished: test.fields.TTLSecondsAfterFinished, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkJobSpec_DeepCopy(t *testing.T) { +// type fields struct { +// GlobalConfig *config.GlobalConfig +// ServerConfig *config.Servers +// Target *BenchmarkTarget +// Dataset *BenchmarkDataset +// Replica int +// Repetition int +// JobType string +// InsertConfig *config.InsertConfig +// UpdateConfig *config.UpdateConfig +// UpsertConfig *config.UpsertConfig +// SearchConfig *config.SearchConfig +// RemoveConfig *config.RemoveConfig +// ObjectConfig *config.ObjectConfig +// ClientConfig *config.GRPCClient +// Rules []*config.BenchmarkJobRule +// RPS int +// ConcurrencyLimit int +// TTLSecondsAfterFinished int +// } +// type want struct { +// want *BenchmarkJobSpec +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *BenchmarkJobSpec) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkJobSpec) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// GlobalConfig:nil, +// ServerConfig:nil, +// Target:nil, +// Dataset:nil, +// Replica:0, +// Repetition:0, +// JobType:"", +// InsertConfig:nil, +// UpdateConfig:nil, +// UpsertConfig:nil, +// SearchConfig:nil, +// RemoveConfig:nil, +// ObjectConfig:nil, +// ClientConfig:nil, +// Rules:nil, +// RPS:0, +// ConcurrencyLimit:0, +// TTLSecondsAfterFinished:0, +// }, +// 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 { +// GlobalConfig:nil, +// ServerConfig:nil, +// Target:nil, +// Dataset:nil, +// Replica:0, +// Repetition:0, +// JobType:"", +// InsertConfig:nil, +// UpdateConfig:nil, +// UpsertConfig:nil, +// SearchConfig:nil, +// RemoveConfig:nil, +// ObjectConfig:nil, +// ClientConfig:nil, +// Rules:nil, +// RPS:0, +// ConcurrencyLimit:0, +// TTLSecondsAfterFinished:0, +// }, +// 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 +// } +// in := &BenchmarkJobSpec{ +// GlobalConfig: test.fields.GlobalConfig, +// ServerConfig: test.fields.ServerConfig, +// Target: test.fields.Target, +// Dataset: test.fields.Dataset, +// Replica: test.fields.Replica, +// Repetition: test.fields.Repetition, +// JobType: test.fields.JobType, +// InsertConfig: test.fields.InsertConfig, +// UpdateConfig: test.fields.UpdateConfig, +// UpsertConfig: test.fields.UpsertConfig, +// SearchConfig: test.fields.SearchConfig, +// RemoveConfig: test.fields.RemoveConfig, +// ObjectConfig: test.fields.ObjectConfig, +// ClientConfig: test.fields.ClientConfig, +// Rules: test.fields.Rules, +// RPS: test.fields.RPS, +// ConcurrencyLimit: test.fields.ConcurrencyLimit, +// TTLSecondsAfterFinished: test.fields.TTLSecondsAfterFinished, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkTarget_DeepCopyInto(t *testing.T) { +// type args struct { +// out *BenchmarkTarget +// } +// type want struct{} +// type test struct { +// name string +// args args +// in *BenchmarkTarget +// 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 { +// out: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 { +// out: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 +// } +// +// test.in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestBenchmarkTarget_DeepCopy(t *testing.T) { +// type want struct { +// want *BenchmarkTarget +// } +// type test struct { +// name string +// in *BenchmarkTarget +// want want +// checkFunc func(want, *BenchmarkTarget) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *BenchmarkTarget) 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", +// 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 +// } +// +// got := test.in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkJob_DeepCopyInto(t *testing.T) { +// type args struct { +// out *ValdBenchmarkJob +// } +// type fields struct { +// TypeMeta metav1.TypeMeta +// ObjectMeta metav1.ObjectMeta +// Spec BenchmarkJobSpec +// Status BenchmarkJobStatus +// } +// 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 { +// out:ValdBenchmarkJob{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:BenchmarkJobSpec{}, +// Status: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 { +// out:ValdBenchmarkJob{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:BenchmarkJobSpec{}, +// Status: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 +// } +// in := &ValdBenchmarkJob{ +// TypeMeta: test.fields.TypeMeta, +// ObjectMeta: test.fields.ObjectMeta, +// Spec: test.fields.Spec, +// Status: test.fields.Status, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkJob_DeepCopy(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ObjectMeta metav1.ObjectMeta +// Spec BenchmarkJobSpec +// Status BenchmarkJobStatus +// } +// type want struct { +// want *ValdBenchmarkJob +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *ValdBenchmarkJob) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *ValdBenchmarkJob) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:BenchmarkJobSpec{}, +// Status: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 { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:BenchmarkJobSpec{}, +// Status: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 +// } +// in := &ValdBenchmarkJob{ +// TypeMeta: test.fields.TypeMeta, +// ObjectMeta: test.fields.ObjectMeta, +// Spec: test.fields.Spec, +// Status: test.fields.Status, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkJob_DeepCopyObject(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ObjectMeta metav1.ObjectMeta +// Spec BenchmarkJobSpec +// Status BenchmarkJobStatus +// } +// type want struct { +// want runtime.Object +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, runtime.Object) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got runtime.Object) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:BenchmarkJobSpec{}, +// Status: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 { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:BenchmarkJobSpec{}, +// Status: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 +// } +// in := &ValdBenchmarkJob{ +// TypeMeta: test.fields.TypeMeta, +// ObjectMeta: test.fields.ObjectMeta, +// Spec: test.fields.Spec, +// Status: test.fields.Status, +// } +// +// got := in.DeepCopyObject() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkJobList_DeepCopyInto(t *testing.T) { +// type args struct { +// out *ValdBenchmarkJobList +// } +// type fields struct { +// TypeMeta metav1.TypeMeta +// ListMeta metav1.ListMeta +// Items []ValdBenchmarkJob +// } +// 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 { +// out:ValdBenchmarkJobList{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 { +// out:ValdBenchmarkJobList{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 +// } +// in := &ValdBenchmarkJobList{ +// TypeMeta: test.fields.TypeMeta, +// ListMeta: test.fields.ListMeta, +// Items: test.fields.Items, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkJobList_DeepCopy(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ListMeta metav1.ListMeta +// Items []ValdBenchmarkJob +// } +// type want struct { +// want *ValdBenchmarkJobList +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *ValdBenchmarkJobList) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *ValdBenchmarkJobList) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 +// } +// in := &ValdBenchmarkJobList{ +// TypeMeta: test.fields.TypeMeta, +// ListMeta: test.fields.ListMeta, +// Items: test.fields.Items, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkJobList_DeepCopyObject(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ListMeta metav1.ListMeta +// Items []ValdBenchmarkJob +// } +// type want struct { +// want runtime.Object +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, runtime.Object) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got runtime.Object) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 +// } +// in := &ValdBenchmarkJobList{ +// TypeMeta: test.fields.TypeMeta, +// ListMeta: test.fields.ListMeta, +// Items: test.fields.Items, +// } +// +// got := in.DeepCopyObject() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/benchmark/api/v1/scenario_types_test.go b/internal/k8s/vald/benchmark/api/v1/scenario_types_test.go new file mode 100644 index 0000000000..95c6f276dd --- /dev/null +++ b/internal/k8s/vald/benchmark/api/v1/scenario_types_test.go @@ -0,0 +1,811 @@ +// 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 v1 + +// NOT IMPLEMENTED BELOW +// +// func TestValdBenchmarkScenario_DeepCopyInto(t *testing.T) { +// type args struct { +// out *ValdBenchmarkScenario +// } +// type fields struct { +// TypeMeta metav1.TypeMeta +// ObjectMeta metav1.ObjectMeta +// Spec ValdBenchmarkScenarioSpec +// Status ValdBenchmarkScenarioStatus +// } +// 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 { +// out:ValdBenchmarkScenario{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:ValdBenchmarkScenarioSpec{}, +// Status: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 { +// out:ValdBenchmarkScenario{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:ValdBenchmarkScenarioSpec{}, +// Status: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 +// } +// in := &ValdBenchmarkScenario{ +// TypeMeta: test.fields.TypeMeta, +// ObjectMeta: test.fields.ObjectMeta, +// Spec: test.fields.Spec, +// Status: test.fields.Status, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkScenario_DeepCopy(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ObjectMeta metav1.ObjectMeta +// Spec ValdBenchmarkScenarioSpec +// Status ValdBenchmarkScenarioStatus +// } +// type want struct { +// want *ValdBenchmarkScenario +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *ValdBenchmarkScenario) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *ValdBenchmarkScenario) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:ValdBenchmarkScenarioSpec{}, +// Status: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 { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:ValdBenchmarkScenarioSpec{}, +// Status: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 +// } +// in := &ValdBenchmarkScenario{ +// TypeMeta: test.fields.TypeMeta, +// ObjectMeta: test.fields.ObjectMeta, +// Spec: test.fields.Spec, +// Status: test.fields.Status, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkScenario_DeepCopyObject(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ObjectMeta metav1.ObjectMeta +// Spec ValdBenchmarkScenarioSpec +// Status ValdBenchmarkScenarioStatus +// } +// type want struct { +// want runtime.Object +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, runtime.Object) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got runtime.Object) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:ValdBenchmarkScenarioSpec{}, +// Status: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 { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:ValdBenchmarkScenarioSpec{}, +// Status: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 +// } +// in := &ValdBenchmarkScenario{ +// TypeMeta: test.fields.TypeMeta, +// ObjectMeta: test.fields.ObjectMeta, +// Spec: test.fields.Spec, +// Status: test.fields.Status, +// } +// +// got := in.DeepCopyObject() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkScenarioList_DeepCopyInto(t *testing.T) { +// type args struct { +// out *ValdBenchmarkScenarioList +// } +// type fields struct { +// TypeMeta metav1.TypeMeta +// ListMeta metav1.ListMeta +// Items []ValdBenchmarkScenario +// } +// 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 { +// out:ValdBenchmarkScenarioList{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 { +// out:ValdBenchmarkScenarioList{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 +// } +// in := &ValdBenchmarkScenarioList{ +// TypeMeta: test.fields.TypeMeta, +// ListMeta: test.fields.ListMeta, +// Items: test.fields.Items, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkScenarioList_DeepCopy(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ListMeta metav1.ListMeta +// Items []ValdBenchmarkScenario +// } +// type want struct { +// want *ValdBenchmarkScenarioList +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *ValdBenchmarkScenarioList) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *ValdBenchmarkScenarioList) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 +// } +// in := &ValdBenchmarkScenarioList{ +// TypeMeta: test.fields.TypeMeta, +// ListMeta: test.fields.ListMeta, +// Items: test.fields.Items, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkScenarioList_DeepCopyObject(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ListMeta metav1.ListMeta +// Items []ValdBenchmarkScenario +// } +// type want struct { +// want runtime.Object +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, runtime.Object) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got runtime.Object) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 +// } +// in := &ValdBenchmarkScenarioList{ +// TypeMeta: test.fields.TypeMeta, +// ListMeta: test.fields.ListMeta, +// Items: test.fields.Items, +// } +// +// got := in.DeepCopyObject() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkScenarioSpec_DeepCopyInto(t *testing.T) { +// type args struct { +// out *ValdBenchmarkScenarioSpec +// } +// type fields struct { +// Target *BenchmarkTarget +// Dataset *BenchmarkDataset +// Jobs []*BenchmarkJobSpec +// } +// 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 { +// out:ValdBenchmarkScenarioSpec{}, +// }, +// fields: fields { +// Target:nil, +// Dataset:nil, +// Jobs: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 { +// out:ValdBenchmarkScenarioSpec{}, +// }, +// fields: fields { +// Target:nil, +// Dataset:nil, +// Jobs: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 +// } +// in := &ValdBenchmarkScenarioSpec{ +// Target: test.fields.Target, +// Dataset: test.fields.Dataset, +// Jobs: test.fields.Jobs, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdBenchmarkScenarioSpec_DeepCopy(t *testing.T) { +// type fields struct { +// Target *BenchmarkTarget +// Dataset *BenchmarkDataset +// Jobs []*BenchmarkJobSpec +// } +// type want struct { +// want *ValdBenchmarkScenarioSpec +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *ValdBenchmarkScenarioSpec) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *ValdBenchmarkScenarioSpec) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Target:nil, +// Dataset:nil, +// Jobs: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 { +// Target:nil, +// Dataset:nil, +// Jobs: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 +// } +// in := &ValdBenchmarkScenarioSpec{ +// Target: test.fields.Target, +// Dataset: test.fields.Dataset, +// Jobs: test.fields.Jobs, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/benchmark/job/job.go b/internal/k8s/vald/benchmark/job/job.go index 60538c5b56..7325f5037c 100644 --- a/internal/k8s/vald/benchmark/job/job.go +++ b/internal/k8s/vald/benchmark/job/job.go @@ -76,7 +76,9 @@ func (r *reconciler) AddListOpts(opt client.ListOption) { r.lopts = append(r.lopts, opt) } -func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res reconcile.Result, err error) { +func (r *reconciler) Reconcile( + ctx context.Context, _ reconcile.Request, +) (res reconcile.Result, err error) { bj := new(v1.ValdBenchmarkJobList) err = r.mgr.GetClient().List(ctx, bj, r.lopts...) diff --git a/internal/k8s/vald/benchmark/job/job_template_option_test.go b/internal/k8s/vald/benchmark/job/job_template_option_test.go new file mode 100644 index 0000000000..629fd525e9 --- /dev/null +++ b/internal/k8s/vald/benchmark/job/job_template_option_test.go @@ -0,0 +1,1206 @@ +// 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 job + +// NOT IMPLEMENTED BELOW +// +// func TestWithContainerName(t *testing.T) { +// type args struct { +// name string +// } +// type want struct { +// want BenchmarkJobTplOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobTplOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobTplOption) 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithContainerName(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithContainerImage(t *testing.T) { +// type args struct { +// name string +// } +// type want struct { +// want BenchmarkJobTplOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobTplOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobTplOption) 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithContainerImage(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithImagePullPolicy(t *testing.T) { +// type args struct { +// p ImagePullPolicy +// } +// type want struct { +// want BenchmarkJobTplOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobTplOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobTplOption) 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 { +// p: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 { +// p: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 := WithImagePullPolicy(test.args.p) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOperatorConfigMap(t *testing.T) { +// type args struct { +// cm string +// } +// type want struct { +// want BenchmarkJobTplOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobTplOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobTplOption) 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 { +// cm:"", +// }, +// 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 { +// cm:"", +// }, +// 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 := WithOperatorConfigMap(test.args.cm) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithSvcAccountName(t *testing.T) { +// type args struct { +// name string +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithSvcAccountName(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithRestartPolicy(t *testing.T) { +// type args struct { +// rp RestartPolicy +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// rp: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 { +// rp: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 := WithRestartPolicy(test.args.rp) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithBackoffLimit(t *testing.T) { +// type args struct { +// bo int32 +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// bo: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 { +// bo: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 := WithBackoffLimit(test.args.bo) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithName(t *testing.T) { +// type args struct { +// name string +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithName(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithNamespace(t *testing.T) { +// type args struct { +// ns string +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// ns:"", +// }, +// 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 { +// ns:"", +// }, +// 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 := WithNamespace(test.args.ns) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOwnerRef(t *testing.T) { +// type args struct { +// refs []k8s.OwnerReference +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// refs: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 { +// refs: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 := WithOwnerRef(test.args.refs) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithCompletions(t *testing.T) { +// type args struct { +// com int32 +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// com: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 { +// com: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 := WithCompletions(test.args.com) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithParallelism(t *testing.T) { +// type args struct { +// parallelism int32 +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// parallelism: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 { +// parallelism: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 := WithParallelism(test.args.parallelism) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithLabel(t *testing.T) { +// type args struct { +// label map[string]string +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// label: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 { +// label: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 := WithLabel(test.args.label) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTTLSecondsAfterFinished(t *testing.T) { +// type args struct { +// ttl int32 +// } +// type want struct { +// want BenchmarkJobOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobOption) 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 { +// ttl: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 { +// ttl: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 := WithTTLSecondsAfterFinished(test.args.ttl) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/benchmark/job/job_template_test.go b/internal/k8s/vald/benchmark/job/job_template_test.go new file mode 100644 index 0000000000..73108136a2 --- /dev/null +++ b/internal/k8s/vald/benchmark/job/job_template_test.go @@ -0,0 +1,223 @@ +// 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 job + +// NOT IMPLEMENTED BELOW +// +// func TestNewBenchmarkJob(t *testing.T) { +// type args struct { +// opts []BenchmarkJobTplOption +// } +// type want struct { +// want BenchmarkJobTpl +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobTpl, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobTpl, 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 := NewBenchmarkJob(test.args.opts...) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_benchmarkJobTpl_CreateJobTpl(t *testing.T) { +// type args struct { +// opts []BenchmarkJobOption +// } +// type fields struct { +// containerName string +// containerImageName string +// configMapName string +// imagePullPolicy ImagePullPolicy +// jobTpl k8s.Job +// } +// type want struct { +// want k8s.Job +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, k8s.Job, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got k8s.Job, 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, +// }, +// fields: fields { +// containerName:"", +// containerImageName:"", +// configMapName:"", +// imagePullPolicy:nil, +// jobTpl: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, +// }, +// fields: fields { +// containerName:"", +// containerImageName:"", +// configMapName:"", +// imagePullPolicy:nil, +// jobTpl: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 +// } +// b := &benchmarkJobTpl{ +// containerName: test.fields.containerName, +// containerImageName: test.fields.containerImageName, +// configMapName: test.fields.configMapName, +// imagePullPolicy: test.fields.imagePullPolicy, +// jobTpl: test.fields.jobTpl, +// } +// +// got, err := b.CreateJobTpl(test.args.opts...) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/benchmark/job/job_test.go b/internal/k8s/vald/benchmark/job/job_test.go new file mode 100644 index 0000000000..52787d40de --- /dev/null +++ b/internal/k8s/vald/benchmark/job/job_test.go @@ -0,0 +1,912 @@ +// 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 job + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want BenchmarkJobWatcher +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkJobWatcher, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkJobWatcher, 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 Test_reconciler_AddListOpts(t *testing.T) { +// type args struct { +// opt client.ListOption +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob) +// lopts []client.ListOption +// } +// 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 { +// opt:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// opt:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// r.AddListOpts(test.args.opt) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Reconcile(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 reconcile.Request +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob) +// lopts []client.ListOption +// } +// type want struct { +// wantRes reconcile.Result +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, reconcile.Result, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes reconcile.Result, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// gotRes, err := r.Reconcile(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_GetName(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob) +// lopts []client.ListOption +// } +// 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 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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got := r.GetName() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_NewReconciler(t *testing.T) { +// type args struct { +// in0 context.Context +// mgr manager.Manager +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob) +// lopts []client.ListOption +// } +// type want struct { +// want reconcile.Reconciler +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, reconcile.Reconciler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got reconcile.Reconciler) 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 { +// in0:nil, +// mgr:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// in0:nil, +// mgr:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got := r.NewReconciler(test.args.in0, test.args.mgr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_For(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob) +// lopts []client.ListOption +// } +// type want struct { +// want client.Object +// want1 []builder.ForOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, []builder.ForOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 []builder.ForOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got, got1 := r.For() +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Owns(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob) +// lopts []client.ListOption +// } +// type want struct { +// want client.Object +// want1 []builder.OwnsOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, []builder.OwnsOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 []builder.OwnsOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got, got1 := r.Owns() +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Watches(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob) +// lopts []client.ListOption +// } +// type want struct { +// want client.Object +// want1 handler.EventHandler +// want2 []builder.WatchesOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, handler.EventHandler, []builder.WatchesOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 handler.EventHandler, got2 []builder.WatchesOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// if !reflect.DeepEqual(got2, w.want2) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got2, w.want2) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got, got1, got2 := r.Watches() +// if err := checkFunc(test.want, got, got1, got2); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/benchmark/job/option.go b/internal/k8s/vald/benchmark/job/option.go index f0d231f153..a6fdffa683 100644 --- a/internal/k8s/vald/benchmark/job/option.go +++ b/internal/k8s/vald/benchmark/job/option.go @@ -60,7 +60,9 @@ func WithOnErrorFunc(f func(err error)) Option { } // WithOnReconcileFunc returns Option that sets r.onReconcile. -func WithOnReconcileFunc(f func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob)) Option { +func WithOnReconcileFunc( + f func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob), +) Option { return func(r *reconciler) error { r.onReconcile = f return nil diff --git a/internal/k8s/vald/benchmark/job/option_test.go b/internal/k8s/vald/benchmark/job/option_test.go new file mode 100644 index 0000000000..d478ec4832 --- /dev/null +++ b/internal/k8s/vald/benchmark/job/option_test.go @@ -0,0 +1,441 @@ +// 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 job + +// NOT IMPLEMENTED BELOW +// +// func TestWithControllerName(t *testing.T) { +// type args struct { +// name 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithControllerName(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithManager(t *testing.T) { +// type args struct { +// mgr manager.Manager +// } +// 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 { +// mgr: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 { +// mgr: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 := WithManager(test.args.mgr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithNamespaces(t *testing.T) { +// type args struct { +// nss []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 { +// nss: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 { +// nss: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 := WithNamespaces(test.args.nss...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOnErrorFunc(t *testing.T) { +// type args struct { +// f func(err error) +// } +// 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 { +// f: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 { +// f: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 := WithOnErrorFunc(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOnReconcileFunc(t *testing.T) { +// type args struct { +// f func(ctx context.Context, jobList map[string]v1.ValdBenchmarkJob) +// } +// 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 { +// f: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 { +// f: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 := WithOnReconcileFunc(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/benchmark/scenario/option.go b/internal/k8s/vald/benchmark/scenario/option.go index 6a1b7d0e26..1880426720 100644 --- a/internal/k8s/vald/benchmark/scenario/option.go +++ b/internal/k8s/vald/benchmark/scenario/option.go @@ -60,7 +60,9 @@ func WithOnErrorFunc(f func(err error)) Option { } // WithOnReconcileFunc returns Option that sets r.onReconcile. -func WithOnReconcileFunc(f func(ctx context.Context, scenarioList map[string]v1.ValdBenchmarkScenario)) Option { +func WithOnReconcileFunc( + f func(ctx context.Context, scenarioList map[string]v1.ValdBenchmarkScenario), +) Option { return func(r *reconciler) error { r.onReconcile = f return nil diff --git a/internal/k8s/vald/benchmark/scenario/option_test.go b/internal/k8s/vald/benchmark/scenario/option_test.go new file mode 100644 index 0000000000..67d8653783 --- /dev/null +++ b/internal/k8s/vald/benchmark/scenario/option_test.go @@ -0,0 +1,441 @@ +// 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 scenario + +// NOT IMPLEMENTED BELOW +// +// func TestWithControllerName(t *testing.T) { +// type args struct { +// name 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithControllerName(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithManager(t *testing.T) { +// type args struct { +// mgr manager.Manager +// } +// 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 { +// mgr: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 { +// mgr: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 := WithManager(test.args.mgr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithNamespaces(t *testing.T) { +// type args struct { +// nss []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 { +// nss: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 { +// nss: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 := WithNamespaces(test.args.nss...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOnErrorFunc(t *testing.T) { +// type args struct { +// f func(err error) +// } +// 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 { +// f: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 { +// f: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 := WithOnErrorFunc(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithOnReconcileFunc(t *testing.T) { +// type args struct { +// f func(ctx context.Context, scenarioList map[string]v1.ValdBenchmarkScenario) +// } +// 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 { +// f: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 { +// f: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 := WithOnReconcileFunc(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/benchmark/scenario/scenario.go b/internal/k8s/vald/benchmark/scenario/scenario.go index eb1d7f89ac..6e07d0a2e8 100644 --- a/internal/k8s/vald/benchmark/scenario/scenario.go +++ b/internal/k8s/vald/benchmark/scenario/scenario.go @@ -65,7 +65,9 @@ func (r *reconciler) AddListOpts(opt client.ListOption) { r.lopts = append(r.lopts, opt) } -func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res reconcile.Result, err error) { +func (r *reconciler) Reconcile( + ctx context.Context, _ reconcile.Request, +) (res reconcile.Result, err error) { bs := new(v1.ValdBenchmarkScenarioList) err = r.mgr.GetClient().List(ctx, bs, r.lopts...) diff --git a/internal/k8s/vald/benchmark/scenario/scenario_test.go b/internal/k8s/vald/benchmark/scenario/scenario_test.go new file mode 100644 index 0000000000..328251e357 --- /dev/null +++ b/internal/k8s/vald/benchmark/scenario/scenario_test.go @@ -0,0 +1,912 @@ +// 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 scenario + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want BenchmarkScenarioWatcher +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, BenchmarkScenarioWatcher, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got BenchmarkScenarioWatcher, 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 Test_reconciler_AddListOpts(t *testing.T) { +// type args struct { +// opt client.ListOption +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, operatorList map[string]v1.ValdBenchmarkScenario) +// lopts []client.ListOption +// } +// 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 { +// opt:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// opt:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// r.AddListOpts(test.args.opt) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Reconcile(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 reconcile.Request +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, operatorList map[string]v1.ValdBenchmarkScenario) +// lopts []client.ListOption +// } +// type want struct { +// wantRes reconcile.Result +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, reconcile.Result, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes reconcile.Result, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// gotRes, err := r.Reconcile(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_GetName(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, operatorList map[string]v1.ValdBenchmarkScenario) +// lopts []client.ListOption +// } +// 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 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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got := r.GetName() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_NewReconciler(t *testing.T) { +// type args struct { +// in0 context.Context +// mgr manager.Manager +// } +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, operatorList map[string]v1.ValdBenchmarkScenario) +// lopts []client.ListOption +// } +// type want struct { +// want reconcile.Reconciler +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, reconcile.Reconciler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got reconcile.Reconciler) 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 { +// in0:nil, +// mgr:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// in0:nil, +// mgr:nil, +// }, +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got := r.NewReconciler(test.args.in0, test.args.mgr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_For(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, operatorList map[string]v1.ValdBenchmarkScenario) +// lopts []client.ListOption +// } +// type want struct { +// want client.Object +// want1 []builder.ForOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, []builder.ForOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 []builder.ForOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got, got1 := r.For() +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Owns(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, operatorList map[string]v1.ValdBenchmarkScenario) +// lopts []client.ListOption +// } +// type want struct { +// want client.Object +// want1 []builder.OwnsOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, []builder.OwnsOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 []builder.OwnsOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got, got1 := r.Owns() +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_reconciler_Watches(t *testing.T) { +// type fields struct { +// mgr manager.Manager +// name string +// namespaces []string +// onError func(err error) +// onReconcile func(ctx context.Context, operatorList map[string]v1.ValdBenchmarkScenario) +// lopts []client.ListOption +// } +// type want struct { +// want client.Object +// want1 handler.EventHandler +// want2 []builder.WatchesOption +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, client.Object, handler.EventHandler, []builder.WatchesOption) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got client.Object, got1 handler.EventHandler, got2 []builder.WatchesOption) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// if !reflect.DeepEqual(got2, w.want2) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got2, w.want2) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 { +// mgr:nil, +// name:"", +// namespaces:nil, +// onError:nil, +// onReconcile:nil, +// lopts: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 +// } +// r := &reconciler{ +// mgr: test.fields.mgr, +// name: test.fields.name, +// namespaces: test.fields.namespaces, +// onError: test.fields.onError, +// onReconcile: test.fields.onReconcile, +// lopts: test.fields.lopts, +// } +// +// got, got1, got2 := r.Watches() +// if err := checkFunc(test.want, got, got1, got2); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/mirror/api/v1/target_types_test.go b/internal/k8s/vald/mirror/api/v1/target_types_test.go new file mode 100644 index 0000000000..1cd7656e29 --- /dev/null +++ b/internal/k8s/vald/mirror/api/v1/target_types_test.go @@ -0,0 +1,992 @@ +// 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 v1 + +// NOT IMPLEMENTED BELOW +// +// func TestValdMirrorTarget_DeepCopyInto(t *testing.T) { +// type args struct { +// out *ValdMirrorTarget +// } +// type fields struct { +// TypeMeta metav1.TypeMeta +// ObjectMeta metav1.ObjectMeta +// Spec MirrorTargetSpec +// Status MirrorTargetStatus +// } +// 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 { +// out:ValdMirrorTarget{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:MirrorTargetSpec{}, +// Status:MirrorTargetStatus{}, +// }, +// 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 { +// out:ValdMirrorTarget{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:MirrorTargetSpec{}, +// Status:MirrorTargetStatus{}, +// }, +// 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 +// } +// in := &ValdMirrorTarget{ +// TypeMeta: test.fields.TypeMeta, +// ObjectMeta: test.fields.ObjectMeta, +// Spec: test.fields.Spec, +// Status: test.fields.Status, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdMirrorTarget_DeepCopy(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ObjectMeta metav1.ObjectMeta +// Spec MirrorTargetSpec +// Status MirrorTargetStatus +// } +// type want struct { +// want *ValdMirrorTarget +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *ValdMirrorTarget) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *ValdMirrorTarget) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:MirrorTargetSpec{}, +// Status:MirrorTargetStatus{}, +// }, +// 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 { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:MirrorTargetSpec{}, +// Status:MirrorTargetStatus{}, +// }, +// 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 +// } +// in := &ValdMirrorTarget{ +// TypeMeta: test.fields.TypeMeta, +// ObjectMeta: test.fields.ObjectMeta, +// Spec: test.fields.Spec, +// Status: test.fields.Status, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdMirrorTarget_DeepCopyObject(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ObjectMeta metav1.ObjectMeta +// Spec MirrorTargetSpec +// Status MirrorTargetStatus +// } +// type want struct { +// want runtime.Object +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, runtime.Object) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got runtime.Object) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:MirrorTargetSpec{}, +// Status:MirrorTargetStatus{}, +// }, +// 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 { +// TypeMeta:nil, +// ObjectMeta:nil, +// Spec:MirrorTargetSpec{}, +// Status:MirrorTargetStatus{}, +// }, +// 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 +// } +// in := &ValdMirrorTarget{ +// TypeMeta: test.fields.TypeMeta, +// ObjectMeta: test.fields.ObjectMeta, +// Spec: test.fields.Spec, +// Status: test.fields.Status, +// } +// +// got := in.DeepCopyObject() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestMirrorTargetSpec_DeepCopyInto(t *testing.T) { +// type args struct { +// out *MirrorTargetSpec +// } +// type fields struct { +// Colocation string +// Target MirrorTarget +// } +// 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 { +// out:MirrorTargetSpec{}, +// }, +// fields: fields { +// Colocation:"", +// Target:MirrorTarget{}, +// }, +// 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 { +// out:MirrorTargetSpec{}, +// }, +// fields: fields { +// Colocation:"", +// Target:MirrorTarget{}, +// }, +// 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 +// } +// in := &MirrorTargetSpec{ +// Colocation: test.fields.Colocation, +// Target: test.fields.Target, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestMirrorTargetSpec_DeepCopy(t *testing.T) { +// type fields struct { +// Colocation string +// Target MirrorTarget +// } +// type want struct { +// want *MirrorTargetSpec +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *MirrorTargetSpec) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *MirrorTargetSpec) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Colocation:"", +// Target:MirrorTarget{}, +// }, +// 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 { +// Colocation:"", +// Target:MirrorTarget{}, +// }, +// 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 +// } +// in := &MirrorTargetSpec{ +// Colocation: test.fields.Colocation, +// Target: test.fields.Target, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestMirrorTarget_DeepCopyInto(t *testing.T) { +// type args struct { +// out *MirrorTarget +// } +// type fields struct { +// Host string +// Port int +// } +// 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 { +// out:MirrorTarget{}, +// }, +// fields: fields { +// Host:"", +// Port: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 { +// out:MirrorTarget{}, +// }, +// fields: fields { +// Host:"", +// Port: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 +// } +// in := &MirrorTarget{ +// Host: test.fields.Host, +// Port: test.fields.Port, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestMirrorTarget_DeepCopy(t *testing.T) { +// type fields struct { +// Host string +// Port int +// } +// type want struct { +// want *MirrorTarget +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *MirrorTarget) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *MirrorTarget) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// Host:"", +// Port:0, +// }, +// 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 { +// Host:"", +// Port:0, +// }, +// 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 +// } +// in := &MirrorTarget{ +// Host: test.fields.Host, +// Port: test.fields.Port, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdMirrorTargetList_DeepCopyInto(t *testing.T) { +// type args struct { +// out *ValdMirrorTargetList +// } +// type fields struct { +// TypeMeta metav1.TypeMeta +// ListMeta metav1.ListMeta +// Items []ValdMirrorTarget +// } +// 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 { +// out:ValdMirrorTargetList{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 { +// out:ValdMirrorTargetList{}, +// }, +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 +// } +// in := &ValdMirrorTargetList{ +// TypeMeta: test.fields.TypeMeta, +// ListMeta: test.fields.ListMeta, +// Items: test.fields.Items, +// } +// +// in.DeepCopyInto(test.args.out) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdMirrorTargetList_DeepCopy(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ListMeta metav1.ListMeta +// Items []ValdMirrorTarget +// } +// type want struct { +// want *ValdMirrorTargetList +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *ValdMirrorTargetList) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *ValdMirrorTargetList) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 +// } +// in := &ValdMirrorTargetList{ +// TypeMeta: test.fields.TypeMeta, +// ListMeta: test.fields.ListMeta, +// Items: test.fields.Items, +// } +// +// got := in.DeepCopy() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestValdMirrorTargetList_DeepCopyObject(t *testing.T) { +// type fields struct { +// TypeMeta metav1.TypeMeta +// ListMeta metav1.ListMeta +// Items []ValdMirrorTarget +// } +// type want struct { +// want runtime.Object +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, runtime.Object) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got runtime.Object) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 { +// TypeMeta:nil, +// ListMeta:nil, +// Items: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 +// } +// in := &ValdMirrorTargetList{ +// TypeMeta: test.fields.TypeMeta, +// ListMeta: test.fields.ListMeta, +// Items: test.fields.Items, +// } +// +// got := in.DeepCopyObject() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/k8s/vald/mirror/target/target.go b/internal/k8s/vald/mirror/target/target.go index cbfb1f60ae..aeba23c73e 100644 --- a/internal/k8s/vald/mirror/target/target.go +++ b/internal/k8s/vald/mirror/target/target.go @@ -87,7 +87,9 @@ func (r *reconciler) addListOpts(opt client.ListOption) { r.lopts = append(r.lopts, opt) } -func (r *reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (res reconcile.Result, err error) { +func (r *reconciler) Reconcile( + ctx context.Context, _ reconcile.Request, +) (res reconcile.Result, err error) { ml := &mirrv1.ValdMirrorTargetList{} err = r.mgr.GetClient().List(ctx, ml, r.lopts...) if err != nil { diff --git a/internal/log/glg/glg.go b/internal/log/glg/glg.go index 8b5912ac3a..de0d6da925 100644 --- a/internal/log/glg/glg.go +++ b/internal/log/glg/glg.go @@ -89,15 +89,15 @@ func (*logger) Close() error { return nil } -func (l *logger) Info(vals ...interface{}) { +func (l *logger) Info(vals ...any) { l.retry.Out(l.glg.Info, vals...) } -func (l *logger) Infof(format string, vals ...interface{}) { +func (l *logger) Infof(format string, vals ...any) { l.retry.Outf(l.glg.Infof, format, vals...) } -func (l *logger) Infod(msg string, details ...interface{}) { +func (l *logger) Infod(msg string, details ...any) { lf := l.glg.Infof var dstr string switch len(details) { @@ -122,15 +122,15 @@ func (l *logger) Infod(msg string, details ...interface{}) { l.retry.Outf(lf, detailsFormat, msg, dstr) } -func (l *logger) Debug(vals ...interface{}) { +func (l *logger) Debug(vals ...any) { l.retry.Out(l.glg.Debug, vals...) } -func (l *logger) Debugf(format string, vals ...interface{}) { +func (l *logger) Debugf(format string, vals ...any) { l.retry.Outf(l.glg.Debugf, format, vals...) } -func (l *logger) Debugd(msg string, details ...interface{}) { +func (l *logger) Debugd(msg string, details ...any) { lf := l.glg.Debugf var dstr string switch len(details) { @@ -155,15 +155,15 @@ func (l *logger) Debugd(msg string, details ...interface{}) { l.retry.Outf(lf, detailsFormat, msg, dstr) } -func (l *logger) Warn(vals ...interface{}) { +func (l *logger) Warn(vals ...any) { l.retry.Out(l.glg.Warn, vals...) } -func (l *logger) Warnf(format string, vals ...interface{}) { +func (l *logger) Warnf(format string, vals ...any) { l.retry.Outf(l.glg.Warnf, format, vals...) } -func (l *logger) Warnd(msg string, details ...interface{}) { +func (l *logger) Warnd(msg string, details ...any) { lf := l.glg.Warnf var dstr string switch len(details) { @@ -188,15 +188,15 @@ func (l *logger) Warnd(msg string, details ...interface{}) { l.retry.Outf(lf, detailsFormat, msg, dstr) } -func (l *logger) Error(vals ...interface{}) { +func (l *logger) Error(vals ...any) { l.retry.Out(l.glg.Error, vals...) } -func (l *logger) Errorf(format string, vals ...interface{}) { +func (l *logger) Errorf(format string, vals ...any) { l.retry.Outf(l.glg.Errorf, format, vals...) } -func (l *logger) Errord(msg string, details ...interface{}) { +func (l *logger) Errord(msg string, details ...any) { lf := l.glg.Errorf var dstr string switch len(details) { @@ -221,15 +221,15 @@ func (l *logger) Errord(msg string, details ...interface{}) { l.retry.Outf(lf, detailsFormat, msg, dstr) } -func (l *logger) Fatal(vals ...interface{}) { +func (l *logger) Fatal(vals ...any) { l.glg.SetCallerDepth(4).Fatal(vals...) } -func (l *logger) Fatalf(format string, vals ...interface{}) { +func (l *logger) Fatalf(format string, vals ...any) { l.glg.SetCallerDepth(4).Fatalf(format, vals...) } -func (l *logger) Fatald(msg string, details ...interface{}) { +func (l *logger) Fatald(msg string, details ...any) { var dstr string switch len(details) { case 0: diff --git a/internal/log/glg/glg_test.go b/internal/log/glg/glg_test.go index ddbd410284..dfe07a2a99 100644 --- a/internal/log/glg/glg_test.go +++ b/internal/log/glg/glg_test.go @@ -334,7 +334,7 @@ func TestSetLogFormat(t *testing.T) { got.glg.SetLevelWriter(glg.INFO, buf) got.glg.Info("vald") - var obj map[string]interface{} + var obj map[string]any if err := json.NewDecoder(buf).Decode(&obj); err != nil { return errors.New("not in JSON output logger") } @@ -355,7 +355,7 @@ func TestSetLogFormat(t *testing.T) { got.glg.AddLevelWriter(glg.INFO, buf) got.glg.Info("vald") - var obj map[string]interface{} + var obj map[string]any if err := json.NewDecoder(buf).Decode(&obj); err == nil { return errors.New("not in RAW output logger") } @@ -379,7 +379,7 @@ func TestSetLogFormat(t *testing.T) { func TestInfo(t *testing.T) { type args struct { - vals interface{} + vals any } type field struct { @@ -398,7 +398,7 @@ func TestInfo(t *testing.T) { func() test { var gotVals string retry := &mock.Retry{ - OutFunc: func(fn func(vals ...interface{}) error, vals ...interface{}) { + OutFunc: func(fn func(vals ...any) error, vals ...any) { gotVals = vals[0].(string) }, } @@ -440,7 +440,7 @@ func TestInfo(t *testing.T) { func TestInfof(t *testing.T) { type args struct { - vals interface{} + vals any format string } @@ -463,7 +463,7 @@ func TestInfof(t *testing.T) { gotFormat string ) retry := &mock.Retry{ - OutfFunc: func(fn func(format string, vals ...interface{}) error, format string, vals ...interface{}) { + OutfFunc: func(fn func(format string, vals ...any) error, format string, vals ...any) { gotFormat = format gotVals = vals[0].(string) }, @@ -512,7 +512,7 @@ func TestInfof(t *testing.T) { func TestDebug(t *testing.T) { type args struct { - vals interface{} + vals any } type field struct { @@ -531,7 +531,7 @@ func TestDebug(t *testing.T) { func() test { var gotVals string retry := &mock.Retry{ - OutFunc: func(fn func(vals ...interface{}) error, vals ...interface{}) { + OutFunc: func(fn func(vals ...any) error, vals ...any) { gotVals = vals[0].(string) }, } @@ -573,7 +573,7 @@ func TestDebug(t *testing.T) { func TestDebugf(t *testing.T) { type args struct { - vals interface{} + vals any format string } @@ -596,7 +596,7 @@ func TestDebugf(t *testing.T) { gotFormat string ) retry := &mock.Retry{ - OutfFunc: func(fn func(format string, vals ...interface{}) error, format string, vals ...interface{}) { + OutfFunc: func(fn func(format string, vals ...any) error, format string, vals ...any) { gotFormat = format gotVals = vals[0].(string) }, @@ -645,7 +645,7 @@ func TestDebugf(t *testing.T) { func TestWarn(t *testing.T) { type args struct { - vals interface{} + vals any } type field struct { @@ -664,7 +664,7 @@ func TestWarn(t *testing.T) { func() test { var gotVals string retry := &mock.Retry{ - OutFunc: func(fn func(vals ...interface{}) error, vals ...interface{}) { + OutFunc: func(fn func(vals ...any) error, vals ...any) { gotVals = vals[0].(string) }, } @@ -706,7 +706,7 @@ func TestWarn(t *testing.T) { func TestWarnf(t *testing.T) { type args struct { - vals interface{} + vals any format string } @@ -729,7 +729,7 @@ func TestWarnf(t *testing.T) { gotFormat string ) retry := &mock.Retry{ - OutfFunc: func(fn func(format string, vals ...interface{}) error, format string, vals ...interface{}) { + OutfFunc: func(fn func(format string, vals ...any) error, format string, vals ...any) { gotFormat = format gotVals = vals[0].(string) }, @@ -778,7 +778,7 @@ func TestWarnf(t *testing.T) { func TestError(t *testing.T) { type args struct { - vals interface{} + vals any } type field struct { @@ -797,7 +797,7 @@ func TestError(t *testing.T) { func() test { var gotVals string retry := &mock.Retry{ - OutFunc: func(fn func(vals ...interface{}) error, vals ...interface{}) { + OutFunc: func(fn func(vals ...any) error, vals ...any) { gotVals = vals[0].(string) }, } @@ -839,7 +839,7 @@ func TestError(t *testing.T) { func TestErrorf(t *testing.T) { type args struct { - vals interface{} + vals any format string } @@ -862,7 +862,7 @@ func TestErrorf(t *testing.T) { gotFormat string ) retry := &mock.Retry{ - OutfFunc: func(fn func(format string, vals ...interface{}) error, format string, vals ...interface{}) { + OutfFunc: func(fn func(format string, vals ...any) error, format string, vals ...any) { gotFormat = format gotVals = vals[0].(string) }, @@ -1017,7 +1017,6 @@ func TestErrorf(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1128,7 +1127,6 @@ func TestErrorf(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1229,14 +1227,13 @@ func TestErrorf(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func Test_logger_Info(t *testing.T) { // type args struct { -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -1244,8 +1241,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1343,7 +1339,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Infof(t *testing.T) { // type args struct { // format string -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -1351,8 +1347,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1452,7 +1447,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Infod(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { // format format.Format @@ -1460,8 +1455,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1560,7 +1554,7 @@ func TestErrorf(t *testing.T) { // // func Test_logger_Debug(t *testing.T) { // type args struct { -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -1568,8 +1562,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1667,7 +1660,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Debugf(t *testing.T) { // type args struct { // format string -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -1675,8 +1668,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1776,7 +1768,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Debugd(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { // format format.Format @@ -1784,8 +1776,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1884,7 +1875,7 @@ func TestErrorf(t *testing.T) { // // func Test_logger_Warn(t *testing.T) { // type args struct { -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -1892,8 +1883,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1991,7 +1981,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Warnf(t *testing.T) { // type args struct { // format string -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -1999,8 +1989,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -2100,7 +2089,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Warnd(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { // format format.Format @@ -2108,8 +2097,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -2208,7 +2196,7 @@ func TestErrorf(t *testing.T) { // // func Test_logger_Error(t *testing.T) { // type args struct { -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -2216,8 +2204,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -2315,7 +2302,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Errorf(t *testing.T) { // type args struct { // format string -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -2323,8 +2310,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -2424,7 +2410,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Errord(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { // format format.Format @@ -2432,8 +2418,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -2532,7 +2517,7 @@ func TestErrorf(t *testing.T) { // // func Test_logger_Fatal(t *testing.T) { // type args struct { -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -2540,8 +2525,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -2639,7 +2623,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Fatalf(t *testing.T) { // type args struct { // format string -// vals []interface{} +// vals []any // } // type fields struct { // format format.Format @@ -2647,8 +2631,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -2748,7 +2731,7 @@ func TestErrorf(t *testing.T) { // func Test_logger_Fatald(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { // format format.Format @@ -2756,8 +2739,7 @@ func TestErrorf(t *testing.T) { // retry retry.Retry // glg *glg.Glg // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/internal/log/log.go b/internal/log/log.go index 461c1f5f5b..b3ec1edc03 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -95,62 +95,62 @@ func Bold(str string) string { return "\033[1m" + str + "\033[22m" } -func Debug(vals ...interface{}) { +func Debug(vals ...any) { l.Debug(vals...) } -func Debugf(format string, vals ...interface{}) { +func Debugf(format string, vals ...any) { l.Debugf(format, vals...) } -func Debugd(msg string, details ...interface{}) { +func Debugd(msg string, details ...any) { l.Debugd(msg, details...) } -func Info(vals ...interface{}) { +func Info(vals ...any) { l.Info(vals...) } -func Infof(format string, vals ...interface{}) { +func Infof(format string, vals ...any) { l.Infof(format, vals...) } -func Infod(msg string, details ...interface{}) { +func Infod(msg string, details ...any) { l.Infod(msg, details...) } -func Warn(vals ...interface{}) { +func Warn(vals ...any) { l.Warn(vals...) } -func Warnf(format string, vals ...interface{}) { +func Warnf(format string, vals ...any) { l.Warnf(format, vals...) } -func Warnd(msg string, details ...interface{}) { +func Warnd(msg string, details ...any) { l.Warnd(msg, details...) } -func Error(vals ...interface{}) { +func Error(vals ...any) { l.Error(vals...) } -func Errorf(format string, vals ...interface{}) { +func Errorf(format string, vals ...any) { l.Errorf(format, vals...) } -func Errord(msg string, details ...interface{}) { +func Errord(msg string, details ...any) { l.Errord(msg, details...) } -func Fatal(vals ...interface{}) { +func Fatal(vals ...any) { l.Fatal(vals...) } -func Fatalf(format string, vals ...interface{}) { +func Fatalf(format string, vals ...any) { l.Fatalf(format, vals...) } -func Fatald(msg string, details ...interface{}) { +func Fatald(msg string, details ...any) { l.Fatald(msg, details...) } diff --git a/internal/log/log_test.go b/internal/log/log_test.go index d7ecbe6f8a..f3c0b5d96f 100644 --- a/internal/log/log_test.go +++ b/internal/log/log_test.go @@ -288,10 +288,10 @@ func TestBold(t *testing.T) { func TestDebug(t *testing.T) { type args struct { - vals []interface{} + vals []any } type want struct { - vals []interface{} + vals []any } type test struct { name string @@ -303,16 +303,16 @@ func TestDebug(t *testing.T) { } tests := []test{ func() test { - var got []interface{} + var got []any ml := &mock.Logger{ - DebugFunc: func(vals ...interface{}) { + DebugFunc: func(vals ...any) { got = vals }, } w := want{ - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -363,11 +363,11 @@ func TestDebug(t *testing.T) { func TestDebugf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type want struct { format string - vals []interface{} + vals []any } type test struct { name string @@ -381,18 +381,18 @@ func TestDebugf(t *testing.T) { func() test { var ( gotFormat string - gotVals []interface{} + gotVals []any ) ml := &mock.Logger{ - DebugfFunc: func(format string, vals ...interface{}) { + DebugfFunc: func(format string, vals ...any) { gotFormat, gotVals = format, vals }, } w := want{ format: "format", - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -446,10 +446,10 @@ func TestDebugf(t *testing.T) { func TestInfo(t *testing.T) { type args struct { - vals []interface{} + vals []any } type want struct { - vals []interface{} + vals []any } type test struct { name string @@ -461,16 +461,16 @@ func TestInfo(t *testing.T) { } tests := []test{ func() test { - var got []interface{} + var got []any ml := &mock.Logger{ - InfoFunc: func(vals ...interface{}) { + InfoFunc: func(vals ...any) { got = vals }, } w := want{ - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -521,11 +521,11 @@ func TestInfo(t *testing.T) { func TestInfof(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type want struct { format string - vals []interface{} + vals []any } type test struct { name string @@ -539,18 +539,18 @@ func TestInfof(t *testing.T) { func() test { var ( gotFormat string - gotVals []interface{} + gotVals []any ) ml := &mock.Logger{ - InfofFunc: func(format string, vals ...interface{}) { + InfofFunc: func(format string, vals ...any) { gotFormat, gotVals = format, vals }, } w := want{ format: "format", - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -604,10 +604,10 @@ func TestInfof(t *testing.T) { func TestWarn(t *testing.T) { type args struct { - vals []interface{} + vals []any } type want struct { - vals []interface{} + vals []any } type test struct { name string @@ -619,16 +619,16 @@ func TestWarn(t *testing.T) { } tests := []test{ func() test { - var got []interface{} + var got []any ml := &mock.Logger{ - WarnFunc: func(vals ...interface{}) { + WarnFunc: func(vals ...any) { got = vals }, } w := want{ - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -679,11 +679,11 @@ func TestWarn(t *testing.T) { func TestWarnf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type want struct { format string - vals []interface{} + vals []any } type test struct { name string @@ -697,18 +697,18 @@ func TestWarnf(t *testing.T) { func() test { var ( gotFormat string - gotVals []interface{} + gotVals []any ) ml := &mock.Logger{ - WarnfFunc: func(format string, vals ...interface{}) { + WarnfFunc: func(format string, vals ...any) { gotFormat, gotVals = format, vals }, } w := want{ format: "format", - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -762,10 +762,10 @@ func TestWarnf(t *testing.T) { func TestError(t *testing.T) { type args struct { - vals []interface{} + vals []any } type want struct { - vals []interface{} + vals []any } type test struct { name string @@ -777,16 +777,16 @@ func TestError(t *testing.T) { } tests := []test{ func() test { - var got []interface{} + var got []any ml := &mock.Logger{ - ErrorFunc: func(vals ...interface{}) { + ErrorFunc: func(vals ...any) { got = vals }, } w := want{ - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -837,11 +837,11 @@ func TestError(t *testing.T) { func TestErrorf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type want struct { format string - vals []interface{} + vals []any } type test struct { name string @@ -855,18 +855,18 @@ func TestErrorf(t *testing.T) { func() test { var ( gotFormat string - gotVals []interface{} + gotVals []any ) ml := &mock.Logger{ - ErrorfFunc: func(format string, vals ...interface{}) { + ErrorfFunc: func(format string, vals ...any) { gotFormat, gotVals = format, vals }, } w := want{ format: "format", - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -920,10 +920,10 @@ func TestErrorf(t *testing.T) { func TestFatal(t *testing.T) { type args struct { - vals []interface{} + vals []any } type want struct { - vals []interface{} + vals []any } type test struct { name string @@ -935,16 +935,16 @@ func TestFatal(t *testing.T) { } tests := []test{ func() test { - var got []interface{} + var got []any ml := &mock.Logger{ - FatalFunc: func(vals ...interface{}) { + FatalFunc: func(vals ...any) { got = vals }, } w := want{ - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -995,11 +995,11 @@ func TestFatal(t *testing.T) { func TestFatalf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type want struct { format string - vals []interface{} + vals []any } type test struct { name string @@ -1013,18 +1013,18 @@ func TestFatalf(t *testing.T) { func() test { var ( gotFormat string - gotVals []interface{} + gotVals []any ) ml := &mock.Logger{ - FatalfFunc: func(format string, vals ...interface{}) { + FatalfFunc: func(format string, vals ...any) { gotFormat, gotVals = format, vals }, } w := want{ format: "format", - vals: []interface{}{ + vals: []any{ "vald", }, } @@ -1149,7 +1149,6 @@ func TestFatalf(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1157,10 +1156,9 @@ func TestFatalf(t *testing.T) { // func TestDebugd(t *testing.T) { // type args struct { // msg string -// details []interface{} -// } -// type want struct { +// details []any // } +// type want struct{} // type test struct { // name string // args args @@ -1241,10 +1239,9 @@ func TestFatalf(t *testing.T) { // func TestInfod(t *testing.T) { // type args struct { // msg string -// details []interface{} -// } -// type want struct { +// details []any // } +// type want struct{} // type test struct { // name string // args args @@ -1325,10 +1322,9 @@ func TestFatalf(t *testing.T) { // func TestWarnd(t *testing.T) { // type args struct { // msg string -// details []interface{} -// } -// type want struct { +// details []any // } +// type want struct{} // type test struct { // name string // args args @@ -1409,10 +1405,9 @@ func TestFatalf(t *testing.T) { // func TestErrord(t *testing.T) { // type args struct { // msg string -// details []interface{} -// } -// type want struct { +// details []any // } +// type want struct{} // type test struct { // name string // args args @@ -1493,10 +1488,9 @@ func TestFatalf(t *testing.T) { // func TestFatald(t *testing.T) { // type args struct { // msg string -// details []interface{} -// } -// type want struct { +// details []any // } +// type want struct{} // type test struct { // name string // args args diff --git a/internal/log/logger/iface.go b/internal/log/logger/iface.go index b34290d8ab..b14bf0237c 100644 --- a/internal/log/logger/iface.go +++ b/internal/log/logger/iface.go @@ -18,49 +18,49 @@ package logger type Logger interface { // Debug logs the vals at Debug level. - Debug(vals ...interface{}) + Debug(vals ...any) // Debugf logs the formatted message at Debug level. - Debugf(format string, vals ...interface{}) + Debugf(format string, vals ...any) // Debugd logs the message with details at Debug level. - Debugd(msg string, details ...interface{}) + Debugd(msg string, details ...any) // Info logs the vals at Info level. - Info(vals ...interface{}) + Info(vals ...any) // Infof logs the formatted message at Info level. - Infof(format string, vals ...interface{}) + Infof(format string, vals ...any) // Infod logs the message with details at Info level. - Infod(msg string, details ...interface{}) + Infod(msg string, details ...any) // Warn logs the vals at Warn level. - Warn(vals ...interface{}) + Warn(vals ...any) // Warnf logs the formatted message at Warn level. - Warnf(format string, vals ...interface{}) + Warnf(format string, vals ...any) // Warnd logs the message with details at Warn level. - Warnd(msg string, details ...interface{}) + Warnd(msg string, details ...any) // Error logs the vals at Error level. - Error(vals ...interface{}) + Error(vals ...any) // Errorf logs the formatted message at Error level. - Errorf(format string, vals ...interface{}) + Errorf(format string, vals ...any) // Errord logs the message with details at Error level. - Errord(msg string, details ...interface{}) + Errord(msg string, details ...any) // Fatal logs the vals at Fatal level, then calls os.Exit(1). - Fatal(vals ...interface{}) + Fatal(vals ...any) // Fatalf logs the formatted message at Fatal level, then calls os.Exit(1). - Fatalf(format string, vals ...interface{}) + Fatalf(format string, vals ...any) // Fatald logs the message with details at Fatal level, then calls os.Exit(1). - Fatald(msg string, details ...interface{}) + Fatald(msg string, details ...any) // Close calls finalizer of logger implementations. Close() error diff --git a/internal/log/mock/logger.go b/internal/log/mock/logger.go index 7c5f15ec07..2d205461ab 100644 --- a/internal/log/mock/logger.go +++ b/internal/log/mock/logger.go @@ -15,90 +15,90 @@ package mock // Logger represents struct of each log level function. type Logger struct { - DebugFunc func(vals ...interface{}) - DebugfFunc func(format string, vals ...interface{}) - InfoFunc func(vals ...interface{}) - InfofFunc func(format string, vals ...interface{}) - WarnFunc func(vals ...interface{}) - WarnfFunc func(format string, vals ...interface{}) - ErrorFunc func(vals ...interface{}) - ErrorfFunc func(format string, vals ...interface{}) - FatalFunc func(vals ...interface{}) - FatalfFunc func(format string, vals ...interface{}) + DebugFunc func(vals ...any) + DebugfFunc func(format string, vals ...any) + InfoFunc func(vals ...any) + InfofFunc func(format string, vals ...any) + WarnFunc func(vals ...any) + WarnfFunc func(format string, vals ...any) + ErrorFunc func(vals ...any) + ErrorfFunc func(format string, vals ...any) + FatalFunc func(vals ...any) + FatalfFunc func(format string, vals ...any) } // Debug calls DebugFunc of Logger. -func (l *Logger) Debug(vals ...interface{}) { +func (l *Logger) Debug(vals ...any) { l.DebugFunc(vals...) } // Debugf calls DebugfFunc of Logger. -func (l *Logger) Debugf(format string, vals ...interface{}) { +func (l *Logger) Debugf(format string, vals ...any) { l.DebugfFunc(format, vals...) } // Debugd calls DebugfFunc of Logger. -func (l *Logger) Debugd(msg string, details ...interface{}) { +func (l *Logger) Debugd(msg string, details ...any) { l.DebugfFunc(msg, details...) } // Info calls InfoFunc of Logger. -func (l *Logger) Info(vals ...interface{}) { +func (l *Logger) Info(vals ...any) { l.InfoFunc(vals...) } // Infof calls InfofFunc of Logger. -func (l *Logger) Infof(format string, vals ...interface{}) { +func (l *Logger) Infof(format string, vals ...any) { l.InfofFunc(format, vals...) } // Infod calls InfofFunc of Logger. -func (l *Logger) Infod(msg string, details ...interface{}) { +func (l *Logger) Infod(msg string, details ...any) { l.InfofFunc(msg, details...) } // Warn calls WarnFunc of Logger. -func (l *Logger) Warn(vals ...interface{}) { +func (l *Logger) Warn(vals ...any) { l.WarnFunc(vals...) } // Warnf calls WarnfFunc of Logger. -func (l *Logger) Warnf(format string, vals ...interface{}) { +func (l *Logger) Warnf(format string, vals ...any) { l.WarnfFunc(format, vals...) } // Warnd calls WarnfFunc of Logger. -func (l *Logger) Warnd(msg string, details ...interface{}) { +func (l *Logger) Warnd(msg string, details ...any) { l.WarnfFunc(msg, details...) } // Error calls ErrorFunc of Logger. -func (l *Logger) Error(vals ...interface{}) { +func (l *Logger) Error(vals ...any) { l.ErrorFunc(vals...) } // Errorf calls ErrorfFunc of Logger. -func (l *Logger) Errorf(format string, vals ...interface{}) { +func (l *Logger) Errorf(format string, vals ...any) { l.ErrorfFunc(format, vals...) } // Errord calls ErrorfFunc of Logger. -func (l *Logger) Errord(msg string, details ...interface{}) { +func (l *Logger) Errord(msg string, details ...any) { l.ErrorfFunc(msg, details...) } // Fatal calls FatalFunc of Logger. -func (l *Logger) Fatal(vals ...interface{}) { +func (l *Logger) Fatal(vals ...any) { l.FatalFunc(vals...) } // Fatalf calls FatalfFunc of Logger. -func (l *Logger) Fatalf(format string, vals ...interface{}) { +func (l *Logger) Fatalf(format string, vals ...any) { l.FatalfFunc(format, vals...) } // Fatald calls FatalfFunc of Logger. -func (l *Logger) Fatald(msg string, details ...interface{}) { +func (l *Logger) Fatald(msg string, details ...any) { l.FatalfFunc(msg, details...) } diff --git a/internal/log/mock/logger_test.go b/internal/log/mock/logger_test.go index 5f30169ea1..e09ad01af7 100644 --- a/internal/log/mock/logger_test.go +++ b/internal/log/mock/logger_test.go @@ -23,10 +23,10 @@ import ( func TestLogger_Debug(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { - DebugFunc func(vals ...interface{}) + DebugFunc func(vals ...any) } type want struct{} type test struct { @@ -43,7 +43,7 @@ func TestLogger_Debug(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } var cnt int @@ -55,7 +55,7 @@ func TestLogger_Debug(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - DebugFunc: func(vals ...interface{}) { + DebugFunc: func(vals ...any) { if !reflect.DeepEqual(vals, wantVals) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -103,10 +103,10 @@ func TestLogger_Debug(t *testing.T) { func TestLogger_Debugf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { - DebugfFunc func(format string, vals ...interface{}) + DebugfFunc func(format string, vals ...any) } type want struct{} type test struct { @@ -123,7 +123,7 @@ func TestLogger_Debugf(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } wantFormat := "json" @@ -137,7 +137,7 @@ func TestLogger_Debugf(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - DebugfFunc: func(format string, vals ...interface{}) { + DebugfFunc: func(format string, vals ...any) { if !reflect.DeepEqual(vals, wantVals) || !reflect.DeepEqual(format, wantFormat) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -184,10 +184,10 @@ func TestLogger_Debugf(t *testing.T) { func TestLogger_Info(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { - InfoFunc func(vals ...interface{}) + InfoFunc func(vals ...any) } type want struct{} type test struct { @@ -204,7 +204,7 @@ func TestLogger_Info(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } var cnt int @@ -216,7 +216,7 @@ func TestLogger_Info(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - InfoFunc: func(vals ...interface{}) { + InfoFunc: func(vals ...any) { if !reflect.DeepEqual(vals, wantVals) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -264,10 +264,10 @@ func TestLogger_Info(t *testing.T) { func TestLogger_Infof(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { - InfofFunc func(format string, vals ...interface{}) + InfofFunc func(format string, vals ...any) } type want struct{} type test struct { @@ -284,7 +284,7 @@ func TestLogger_Infof(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } wantFormat := "json" @@ -298,7 +298,7 @@ func TestLogger_Infof(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - InfofFunc: func(format string, vals ...interface{}) { + InfofFunc: func(format string, vals ...any) { if !reflect.DeepEqual(vals, wantVals) || !reflect.DeepEqual(format, wantFormat) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -345,10 +345,10 @@ func TestLogger_Infof(t *testing.T) { func TestLogger_Warn(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { - WarnFunc func(vals ...interface{}) + WarnFunc func(vals ...any) } type want struct{} type test struct { @@ -365,7 +365,7 @@ func TestLogger_Warn(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } var cnt int @@ -377,7 +377,7 @@ func TestLogger_Warn(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - WarnFunc: func(vals ...interface{}) { + WarnFunc: func(vals ...any) { if !reflect.DeepEqual(vals, wantVals) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -425,10 +425,10 @@ func TestLogger_Warn(t *testing.T) { func TestLogger_Warnf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { - WarnfFunc func(format string, vals ...interface{}) + WarnfFunc func(format string, vals ...any) } type want struct{} type test struct { @@ -445,7 +445,7 @@ func TestLogger_Warnf(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } wantFormat := "json" @@ -459,7 +459,7 @@ func TestLogger_Warnf(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - WarnfFunc: func(format string, vals ...interface{}) { + WarnfFunc: func(format string, vals ...any) { if !reflect.DeepEqual(vals, wantVals) || !reflect.DeepEqual(format, wantFormat) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -506,10 +506,10 @@ func TestLogger_Warnf(t *testing.T) { func TestLogger_Error(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { - ErrorFunc func(vals ...interface{}) + ErrorFunc func(vals ...any) } type want struct{} type test struct { @@ -526,7 +526,7 @@ func TestLogger_Error(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } var cnt int @@ -538,7 +538,7 @@ func TestLogger_Error(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - ErrorFunc: func(vals ...interface{}) { + ErrorFunc: func(vals ...any) { if !reflect.DeepEqual(vals, wantVals) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -586,10 +586,10 @@ func TestLogger_Error(t *testing.T) { func TestLogger_Errorf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { - ErrorfFunc func(format string, vals ...interface{}) + ErrorfFunc func(format string, vals ...any) } type want struct{} type test struct { @@ -606,7 +606,7 @@ func TestLogger_Errorf(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } wantFormat := "json" @@ -620,7 +620,7 @@ func TestLogger_Errorf(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - ErrorfFunc: func(format string, vals ...interface{}) { + ErrorfFunc: func(format string, vals ...any) { if !reflect.DeepEqual(vals, wantVals) || !reflect.DeepEqual(format, wantFormat) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -667,10 +667,10 @@ func TestLogger_Errorf(t *testing.T) { func TestLogger_Fatal(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { - FatalFunc func(vals ...interface{}) + FatalFunc func(vals ...any) } type want struct{} type test struct { @@ -687,7 +687,7 @@ func TestLogger_Fatal(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } var cnt int @@ -699,7 +699,7 @@ func TestLogger_Fatal(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - FatalFunc: func(vals ...interface{}) { + FatalFunc: func(vals ...any) { if !reflect.DeepEqual(vals, wantVals) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -747,10 +747,10 @@ func TestLogger_Fatal(t *testing.T) { func TestLogger_Fatalf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { - FatalfFunc func(format string, vals ...interface{}) + FatalfFunc func(format string, vals ...any) } type want struct{} type test struct { @@ -767,7 +767,7 @@ func TestLogger_Fatalf(t *testing.T) { } tests := []test{ func() test { - wantVals := []interface{}{ + wantVals := []any{ "Vald", } wantFormat := "json" @@ -781,7 +781,7 @@ func TestLogger_Fatalf(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - FatalfFunc: func(format string, vals ...interface{}) { + FatalfFunc: func(format string, vals ...any) { if !reflect.DeepEqual(vals, wantVals) || !reflect.DeepEqual(format, wantFormat) { t.Errorf("got = %v, want = %v", vals, wantVals) } @@ -831,22 +831,21 @@ func TestLogger_Fatalf(t *testing.T) { // func TestLogger_Debugd(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { -// DebugFunc func(vals ...interface{}) -// DebugfFunc func(format string, vals ...interface{}) -// InfoFunc func(vals ...interface{}) -// InfofFunc func(format string, vals ...interface{}) -// WarnFunc func(vals ...interface{}) -// WarnfFunc func(format string, vals ...interface{}) -// ErrorFunc func(vals ...interface{}) -// ErrorfFunc func(format string, vals ...interface{}) -// FatalFunc func(vals ...interface{}) -// FatalfFunc func(format string, vals ...interface{}) -// } -// type want struct { +// DebugFunc func(vals ...any) +// DebugfFunc func(format string, vals ...any) +// InfoFunc func(vals ...any) +// InfofFunc func(format string, vals ...any) +// WarnFunc func(vals ...any) +// WarnfFunc func(format string, vals ...any) +// ErrorFunc func(vals ...any) +// ErrorfFunc func(format string, vals ...any) +// FatalFunc func(vals ...any) +// FatalfFunc func(format string, vals ...any) // } +// type want struct{} // type test struct { // name string // args args @@ -964,22 +963,21 @@ func TestLogger_Fatalf(t *testing.T) { // func TestLogger_Infod(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { -// DebugFunc func(vals ...interface{}) -// DebugfFunc func(format string, vals ...interface{}) -// InfoFunc func(vals ...interface{}) -// InfofFunc func(format string, vals ...interface{}) -// WarnFunc func(vals ...interface{}) -// WarnfFunc func(format string, vals ...interface{}) -// ErrorFunc func(vals ...interface{}) -// ErrorfFunc func(format string, vals ...interface{}) -// FatalFunc func(vals ...interface{}) -// FatalfFunc func(format string, vals ...interface{}) -// } -// type want struct { +// DebugFunc func(vals ...any) +// DebugfFunc func(format string, vals ...any) +// InfoFunc func(vals ...any) +// InfofFunc func(format string, vals ...any) +// WarnFunc func(vals ...any) +// WarnfFunc func(format string, vals ...any) +// ErrorFunc func(vals ...any) +// ErrorfFunc func(format string, vals ...any) +// FatalFunc func(vals ...any) +// FatalfFunc func(format string, vals ...any) // } +// type want struct{} // type test struct { // name string // args args @@ -1097,22 +1095,21 @@ func TestLogger_Fatalf(t *testing.T) { // func TestLogger_Warnd(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { -// DebugFunc func(vals ...interface{}) -// DebugfFunc func(format string, vals ...interface{}) -// InfoFunc func(vals ...interface{}) -// InfofFunc func(format string, vals ...interface{}) -// WarnFunc func(vals ...interface{}) -// WarnfFunc func(format string, vals ...interface{}) -// ErrorFunc func(vals ...interface{}) -// ErrorfFunc func(format string, vals ...interface{}) -// FatalFunc func(vals ...interface{}) -// FatalfFunc func(format string, vals ...interface{}) -// } -// type want struct { +// DebugFunc func(vals ...any) +// DebugfFunc func(format string, vals ...any) +// InfoFunc func(vals ...any) +// InfofFunc func(format string, vals ...any) +// WarnFunc func(vals ...any) +// WarnfFunc func(format string, vals ...any) +// ErrorFunc func(vals ...any) +// ErrorfFunc func(format string, vals ...any) +// FatalFunc func(vals ...any) +// FatalfFunc func(format string, vals ...any) // } +// type want struct{} // type test struct { // name string // args args @@ -1230,22 +1227,21 @@ func TestLogger_Fatalf(t *testing.T) { // func TestLogger_Errord(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { -// DebugFunc func(vals ...interface{}) -// DebugfFunc func(format string, vals ...interface{}) -// InfoFunc func(vals ...interface{}) -// InfofFunc func(format string, vals ...interface{}) -// WarnFunc func(vals ...interface{}) -// WarnfFunc func(format string, vals ...interface{}) -// ErrorFunc func(vals ...interface{}) -// ErrorfFunc func(format string, vals ...interface{}) -// FatalFunc func(vals ...interface{}) -// FatalfFunc func(format string, vals ...interface{}) -// } -// type want struct { +// DebugFunc func(vals ...any) +// DebugfFunc func(format string, vals ...any) +// InfoFunc func(vals ...any) +// InfofFunc func(format string, vals ...any) +// WarnFunc func(vals ...any) +// WarnfFunc func(format string, vals ...any) +// ErrorFunc func(vals ...any) +// ErrorfFunc func(format string, vals ...any) +// FatalFunc func(vals ...any) +// FatalfFunc func(format string, vals ...any) // } +// type want struct{} // type test struct { // name string // args args @@ -1363,22 +1359,21 @@ func TestLogger_Fatalf(t *testing.T) { // func TestLogger_Fatald(t *testing.T) { // type args struct { // msg string -// details []interface{} +// details []any // } // type fields struct { -// DebugFunc func(vals ...interface{}) -// DebugfFunc func(format string, vals ...interface{}) -// InfoFunc func(vals ...interface{}) -// InfofFunc func(format string, vals ...interface{}) -// WarnFunc func(vals ...interface{}) -// WarnfFunc func(format string, vals ...interface{}) -// ErrorFunc func(vals ...interface{}) -// ErrorfFunc func(format string, vals ...interface{}) -// FatalFunc func(vals ...interface{}) -// FatalfFunc func(format string, vals ...interface{}) -// } -// type want struct { +// DebugFunc func(vals ...any) +// DebugfFunc func(format string, vals ...any) +// InfoFunc func(vals ...any) +// InfofFunc func(format string, vals ...any) +// WarnFunc func(vals ...any) +// WarnfFunc func(format string, vals ...any) +// ErrorFunc func(vals ...any) +// ErrorfFunc func(format string, vals ...any) +// FatalFunc func(vals ...any) +// FatalfFunc func(format string, vals ...any) // } +// type want struct{} // type test struct { // name string // args args @@ -1495,16 +1490,16 @@ func TestLogger_Fatalf(t *testing.T) { // // func TestLogger_Close(t *testing.T) { // type fields struct { -// DebugFunc func(vals ...interface{}) -// DebugfFunc func(format string, vals ...interface{}) -// InfoFunc func(vals ...interface{}) -// InfofFunc func(format string, vals ...interface{}) -// WarnFunc func(vals ...interface{}) -// WarnfFunc func(format string, vals ...interface{}) -// ErrorFunc func(vals ...interface{}) -// ErrorfFunc func(format string, vals ...interface{}) -// FatalFunc func(vals ...interface{}) -// FatalfFunc func(format string, vals ...interface{}) +// DebugFunc func(vals ...any) +// DebugfFunc func(format string, vals ...any) +// InfoFunc func(vals ...any) +// InfofFunc func(format string, vals ...any) +// WarnFunc func(vals ...any) +// WarnfFunc func(format string, vals ...any) +// ErrorFunc func(vals ...any) +// ErrorfFunc func(format string, vals ...any) +// FatalFunc func(vals ...any) +// FatalfFunc func(format string, vals ...any) // } // type want struct { // err error @@ -1613,7 +1608,6 @@ func TestLogger_Fatalf(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/log/mock/retry.go b/internal/log/mock/retry.go index dc7fac6ee8..edc39ce74d 100644 --- a/internal/log/mock/retry.go +++ b/internal/log/mock/retry.go @@ -16,29 +16,23 @@ package mock // Retry represents struct of mock retry structure. type Retry struct { OutFunc func( - fn func(vals ...interface{}) error, - vals ...interface{}, + fn func(vals ...any) error, + vals ...any, ) OutfFunc func( - fn func(format string, vals ...interface{}) error, + fn func(format string, vals ...any) error, format string, - vals ...interface{}, + vals ...any, ) } // Out calls OutFunc. -func (r *Retry) Out( - fn func(vals ...interface{}) error, - vals ...interface{}, -) { +func (r *Retry) Out(fn func(vals ...any) error, vals ...any) { r.OutFunc(fn, vals...) } // Outf calls OutfFunc. -func (r *Retry) Outf( - fn func(format string, vals ...interface{}) error, - format string, vals ...interface{}, -) { +func (r *Retry) Outf(fn func(format string, vals ...any) error, format string, vals ...any) { r.OutfFunc(fn, format, vals...) } diff --git a/internal/log/mock/retry_test.go b/internal/log/mock/retry_test.go index f9fa60f34b..fed2b59adf 100644 --- a/internal/log/mock/retry_test.go +++ b/internal/log/mock/retry_test.go @@ -23,11 +23,11 @@ import ( func TestRetry_Out(t *testing.T) { type args struct { - fn func(vals ...interface{}) error - vals []interface{} + fn func(vals ...any) error + vals []any } type fields struct { - OutFunc func(fn func(vals ...interface{}) error, vals ...interface{}) + OutFunc func(fn func(vals ...any) error, vals ...any) } type want struct{} type test struct { @@ -45,10 +45,10 @@ func TestRetry_Out(t *testing.T) { tests := []test{ func() test { var ( - wantFn = func(vals ...interface{}) error { + wantFn = func(vals ...any) error { return nil } - wantVals = []interface{}{ + wantVals = []any{ "Vald", } cnt int @@ -62,7 +62,7 @@ func TestRetry_Out(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - OutFunc: func(fn func(vals ...interface{}) error, vals ...interface{}) { + OutFunc: func(fn func(vals ...any) error, vals ...any) { if !reflect.DeepEqual(vals, wantVals) { t.Errorf("vals got = %v, want = %v", vals, wantVals) } @@ -112,12 +112,12 @@ func TestRetry_Out(t *testing.T) { func TestRetry_Outf(t *testing.T) { type args struct { - fn func(format string, vals ...interface{}) error + fn func(format string, vals ...any) error format string - vals []interface{} + vals []any } type fields struct { - OutfFunc func(fn func(format string, vals ...interface{}) error, format string, vals ...interface{}) + OutfFunc func(fn func(format string, vals ...any) error, format string, vals ...any) } type want struct{} type test struct { @@ -135,10 +135,10 @@ func TestRetry_Outf(t *testing.T) { tests := []test{ func() test { var ( - wantFn = func(format string, vals ...interface{}) error { + wantFn = func(format string, vals ...any) error { return nil } - wantVals = []interface{}{ + wantVals = []any{ "Vald", } wantFormat = "json" @@ -154,7 +154,7 @@ func TestRetry_Outf(t *testing.T) { fieldsFunc: func(t *testing.T) fields { t.Helper() return fields{ - OutfFunc: func(fn func(format string, vals ...interface{}) error, format string, vals ...interface{}) { + OutfFunc: func(fn func(format string, vals ...any) error, format string, vals ...any) { if !reflect.DeepEqual(vals, wantVals) { t.Errorf("vals got = %v, want = %v", vals, wantVals) } diff --git a/internal/log/nop/nop.go b/internal/log/nop/nop.go index d84600504c..c9fa659ca3 100644 --- a/internal/log/nop/nop.go +++ b/internal/log/nop/nop.go @@ -13,9 +13,7 @@ // limitations under the License. package nop -import ( - "github.com/vdaas/vald/internal/log/logger" -) +import "github.com/vdaas/vald/internal/log/logger" type nopLogger struct{} @@ -25,49 +23,49 @@ func New() logger.Logger { } // Debug logs the vals at Debug level. -func (*nopLogger) Debug(...interface{}) {} +func (*nopLogger) Debug(...any) {} // Debugf logs the formatted message at Debug level. -func (*nopLogger) Debugf(string, ...interface{}) {} +func (*nopLogger) Debugf(string, ...any) {} // Debugd logs the message with details at Debug level. -func (*nopLogger) Debugd(string, ...interface{}) {} +func (*nopLogger) Debugd(string, ...any) {} // Info logs the vals at Info level. -func (*nopLogger) Info(...interface{}) {} +func (*nopLogger) Info(...any) {} // Infof logs the formatted message at Info level. -func (*nopLogger) Infof(string, ...interface{}) {} +func (*nopLogger) Infof(string, ...any) {} // Infod logs the message with details at Info level. -func (*nopLogger) Infod(string, ...interface{}) {} +func (*nopLogger) Infod(string, ...any) {} // Warn logs the vals at Warn level. -func (*nopLogger) Warn(...interface{}) {} +func (*nopLogger) Warn(...any) {} // Warnf logs the formatted message at Warn level. -func (*nopLogger) Warnf(string, ...interface{}) {} +func (*nopLogger) Warnf(string, ...any) {} // Warnd logs the message with details at Warn level. -func (*nopLogger) Warnd(string, ...interface{}) {} +func (*nopLogger) Warnd(string, ...any) {} // Error logs the vals at Error level. -func (*nopLogger) Error(...interface{}) {} +func (*nopLogger) Error(...any) {} // Errorf logs the formatted message at Error level. -func (*nopLogger) Errorf(string, ...interface{}) {} +func (*nopLogger) Errorf(string, ...any) {} // Errord logs the message with details at Error level. -func (*nopLogger) Errord(string, ...interface{}) {} +func (*nopLogger) Errord(string, ...any) {} // Fatal logs the vals at Fatal level, then calls os.Exit(1). -func (*nopLogger) Fatal(...interface{}) {} +func (*nopLogger) Fatal(...any) {} // Fatalf logs the formatted message at Fatal level, then calls os.Exit(1). -func (*nopLogger) Fatalf(string, ...interface{}) {} +func (*nopLogger) Fatalf(string, ...any) {} // Fatald logs the message with details at Fatal level, then calls os.Exit(1). -func (*nopLogger) Fatald(string, ...interface{}) {} +func (*nopLogger) Fatald(string, ...any) {} // Close calls finalizer of logger implementations. func (*nopLogger) Close() error { diff --git a/internal/log/nop/nop_test.go b/internal/log/nop/nop_test.go index 89a723d037..e731e8ea09 100644 --- a/internal/log/nop/nop_test.go +++ b/internal/log/nop/nop_test.go @@ -76,7 +76,7 @@ func TestNew(t *testing.T) { func Test_nopLogger_Debug(t *testing.T) { t.Parallel() type args struct { - vals []interface{} + vals []any } type want struct{} type test struct { @@ -126,7 +126,7 @@ func Test_nopLogger_Debugf(t *testing.T) { t.Parallel() type args struct { format string - vals []interface{} + vals []any } type want struct{} type test struct { @@ -176,7 +176,7 @@ func Test_nopLogger_Debugd(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type want struct{} type test struct { @@ -225,7 +225,7 @@ func Test_nopLogger_Debugd(t *testing.T) { func Test_nopLogger_Info(t *testing.T) { t.Parallel() type args struct { - vals []interface{} + vals []any } type want struct{} type test struct { @@ -275,7 +275,7 @@ func Test_nopLogger_Infof(t *testing.T) { t.Parallel() type args struct { format string - vals []interface{} + vals []any } type want struct{} type test struct { @@ -325,7 +325,7 @@ func Test_nopLogger_Infod(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type want struct{} type test struct { @@ -374,7 +374,7 @@ func Test_nopLogger_Infod(t *testing.T) { func Test_nopLogger_Warn(t *testing.T) { t.Parallel() type args struct { - vals []interface{} + vals []any } type want struct{} type test struct { @@ -424,7 +424,7 @@ func Test_nopLogger_Warnf(t *testing.T) { t.Parallel() type args struct { format string - vals []interface{} + vals []any } type want struct{} type test struct { @@ -474,7 +474,7 @@ func Test_nopLogger_Warnd(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type want struct{} type test struct { @@ -523,7 +523,7 @@ func Test_nopLogger_Warnd(t *testing.T) { func Test_nopLogger_Error(t *testing.T) { t.Parallel() type args struct { - vals []interface{} + vals []any } type want struct{} type test struct { @@ -573,7 +573,7 @@ func Test_nopLogger_Errorf(t *testing.T) { t.Parallel() type args struct { format string - vals []interface{} + vals []any } type want struct{} type test struct { @@ -623,7 +623,7 @@ func Test_nopLogger_Errord(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type want struct{} type test struct { @@ -672,7 +672,7 @@ func Test_nopLogger_Errord(t *testing.T) { func Test_nopLogger_Fatal(t *testing.T) { t.Parallel() type args struct { - vals []interface{} + vals []any } type want struct{} type test struct { @@ -722,7 +722,7 @@ func Test_nopLogger_Fatalf(t *testing.T) { t.Parallel() type args struct { format string - vals []interface{} + vals []any } type want struct{} type test struct { @@ -772,7 +772,7 @@ func Test_nopLogger_Fatald(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type want struct{} type test struct { diff --git a/internal/log/retry/option.go b/internal/log/retry/option.go index b627b00b9c..d90d2c7018 100644 --- a/internal/log/retry/option.go +++ b/internal/log/retry/option.go @@ -21,10 +21,10 @@ var ( WithWarn(nopFunc), } - nopFunc = func(vals ...interface{}) {} + nopFunc = func(vals ...any) {} ) -func WithError(fn func(vals ...interface{})) Option { +func WithError(fn func(vals ...any)) Option { return func(r *retry) { if fn == nil { return @@ -33,7 +33,7 @@ func WithError(fn func(vals ...interface{})) Option { } } -func WithWarn(fn func(vals ...interface{})) Option { +func WithWarn(fn func(vals ...any)) Option { return func(r *retry) { if fn == nil { return diff --git a/internal/log/retry/option_test.go b/internal/log/retry/option_test.go index 702df02427..004e860442 100644 --- a/internal/log/retry/option_test.go +++ b/internal/log/retry/option_test.go @@ -24,7 +24,7 @@ import ( func TestWithError(t *testing.T) { type T = retry type args struct { - fn func(vals ...interface{}) + fn func(vals ...any) } type want struct { obj *T @@ -47,7 +47,7 @@ func TestWithError(t *testing.T) { tests := []test{ func() test { - fn := func(vals ...interface{}) {} + fn := func(vals ...any) {} return test{ name: "set success when fn is not nil", args: args{ @@ -98,7 +98,7 @@ func TestWithError(t *testing.T) { func TestWithWarn(t *testing.T) { type T = retry type args struct { - fn func(vals ...interface{}) + fn func(vals ...any) } type want struct { obj *T @@ -121,7 +121,7 @@ func TestWithWarn(t *testing.T) { tests := []test{ func() test { - fn := func(vals ...interface{}) {} + fn := func(vals ...any) {} return test{ name: "set success when fn is not nil", args: args{ diff --git a/internal/log/retry/retry.go b/internal/log/retry/retry.go index f64ad0fb1d..fdc0db9698 100644 --- a/internal/log/retry/retry.go +++ b/internal/log/retry/retry.go @@ -21,18 +21,18 @@ import ( type Retry interface { Out( - fn func(vals ...interface{}) error, - vals ...interface{}, + fn func(vals ...any) error, + vals ...any, ) Outf( - fn func(format string, vals ...interface{}) error, - format string, vals ...interface{}, + fn func(format string, vals ...any) error, + format string, vals ...any, ) } type retry struct { - warnFn func(vals ...interface{}) - errorFn func(vals ...interface{}) + warnFn func(vals ...any) + errorFn func(vals ...any) } func New(opts ...Option) Retry { @@ -43,10 +43,7 @@ func New(opts ...Option) Retry { return r } -func (r *retry) Out( - fn func(vals ...interface{}) error, - vals ...interface{}, -) { +func (r *retry) Out(fn func(vals ...any) error, vals ...any) { if fn != nil { if err := fn(vals...); err != nil { rv := reflect.ValueOf(fn) @@ -63,10 +60,7 @@ func (r *retry) Out( } } -func (r *retry) Outf( - fn func(format string, vals ...interface{}) error, - format string, vals ...interface{}, -) { +func (r *retry) Outf(fn func(format string, vals ...any) error, format string, vals ...any) { if fn != nil { if err := fn(format, vals...); err != nil { rv := reflect.ValueOf(fn) diff --git a/internal/log/retry/retry_test.go b/internal/log/retry/retry_test.go index 12e564d05d..d8c9d8432d 100644 --- a/internal/log/retry/retry_test.go +++ b/internal/log/retry/retry_test.go @@ -61,7 +61,7 @@ func TestNew(t *testing.T) { }, func() test { - fn := func(...interface{}) {} + fn := func(...any) {} return test{ name: "returns l when opts is not nil", args: args{ @@ -104,12 +104,12 @@ func TestNew(t *testing.T) { func Test_retry_Out(t *testing.T) { type args struct { - fn func(vals ...interface{}) error - vals []interface{} + fn func(vals ...any) error + vals []any } type fields struct { - warnFn func(vals ...interface{}) - errorFn func(vals ...interface{}) + warnFn func(vals ...any) + errorFn func(vals ...any) } type test struct { name string @@ -129,7 +129,7 @@ func Test_retry_Out(t *testing.T) { gotCnt = 0 ) - fn := func(vals ...interface{}) error { + fn := func(vals ...any) error { gotCnt++ return nil } @@ -150,7 +150,7 @@ func Test_retry_Out(t *testing.T) { func() test { err := errors.New("error") - fn := func(vals ...interface{}) error { + fn := func(vals ...any) error { return err } @@ -159,13 +159,13 @@ func Test_retry_Out(t *testing.T) { gotErrorFnErr error ) - warnFn := func(vals ...interface{}) { + warnFn := func(vals ...any) { if len(vals) == 1 { gotWarnFnErr = vals[0].(error) } } - errorFn := func(vals ...interface{}) { + errorFn := func(vals ...any) { if len(vals) == 1 { gotErrorFnErr = vals[0].(error) } @@ -230,13 +230,13 @@ func Test_retry_Out(t *testing.T) { func Test_retry_Outf(t *testing.T) { type args struct { - fn func(format string, vals ...interface{}) error + fn func(format string, vals ...any) error format string - vals []interface{} + vals []any } type fields struct { - warnFn func(vals ...interface{}) - errorFn func(vals ...interface{}) + warnFn func(vals ...any) + errorFn func(vals ...any) } type test struct { name string @@ -254,7 +254,7 @@ func Test_retry_Outf(t *testing.T) { var ( wantCnt = 1 wantFormat = "foramt" - wantVals = []interface{}{ + wantVals = []any{ "vald", } ) @@ -262,10 +262,10 @@ func Test_retry_Outf(t *testing.T) { var ( gotCnt int gotFormat string - gotVals []interface{} + gotVals []any ) - fn := func(format string, vals ...interface{}) error { + fn := func(format string, vals ...any) error { gotCnt++ gotFormat = format gotVals = vals @@ -299,7 +299,7 @@ func Test_retry_Outf(t *testing.T) { func() test { err := errors.New("error") - fn := func(format string, vals ...interface{}) error { + fn := func(format string, vals ...any) error { return err } @@ -308,13 +308,13 @@ func Test_retry_Outf(t *testing.T) { gotErrorFnErr error ) - warnFn := func(vals ...interface{}) { + warnFn := func(vals ...any) { if len(vals) == 1 { gotWarnFnErr = vals[0].(error) } } - errorFn := func(vals ...interface{}) { + errorFn := func(vals ...any) { if len(vals) == 1 { gotErrorFnErr = vals[0].(error) } diff --git a/internal/log/zap/zap.go b/internal/log/zap/zap.go index 796bb67014..615499b869 100644 --- a/internal/log/zap/zap.go +++ b/internal/log/zap/zap.go @@ -134,15 +134,15 @@ func toZapEncoder(fmt format.Format) zapcore.Encoder { } } -func (l *logger) Debug(vals ...interface{}) { +func (l *logger) Debug(vals ...any) { l.sugar.Debug(vals...) } -func (l *logger) Debugf(format string, vals ...interface{}) { +func (l *logger) Debugf(format string, vals ...any) { l.sugar.Debugf(format, vals...) } -func (l *logger) Debugd(msg string, details ...interface{}) { +func (l *logger) Debugd(msg string, details ...any) { if len(details) == 1 { l.logger.Debug(msg, zap.Any(detailsKey, details[0])) return @@ -151,15 +151,15 @@ func (l *logger) Debugd(msg string, details ...interface{}) { l.logger.Debug(msg, zap.Any(detailsKey, details)) } -func (l *logger) Info(vals ...interface{}) { +func (l *logger) Info(vals ...any) { l.sugar.Info(vals...) } -func (l *logger) Infof(format string, vals ...interface{}) { +func (l *logger) Infof(format string, vals ...any) { l.sugar.Infof(format, vals...) } -func (l *logger) Infod(msg string, details ...interface{}) { +func (l *logger) Infod(msg string, details ...any) { if len(details) == 1 { l.logger.Info(msg, zap.Any(detailsKey, details[0])) return @@ -168,15 +168,15 @@ func (l *logger) Infod(msg string, details ...interface{}) { l.logger.Info(msg, zap.Any(detailsKey, details)) } -func (l *logger) Warn(vals ...interface{}) { +func (l *logger) Warn(vals ...any) { l.sugar.Warn(vals...) } -func (l *logger) Warnf(format string, vals ...interface{}) { +func (l *logger) Warnf(format string, vals ...any) { l.sugar.Warnf(format, vals...) } -func (l *logger) Warnd(msg string, details ...interface{}) { +func (l *logger) Warnd(msg string, details ...any) { if len(details) == 1 { l.logger.Warn(msg, zap.Any(detailsKey, details[0])) return @@ -185,15 +185,15 @@ func (l *logger) Warnd(msg string, details ...interface{}) { l.logger.Warn(msg, zap.Any(detailsKey, details)) } -func (l *logger) Error(vals ...interface{}) { +func (l *logger) Error(vals ...any) { l.sugar.Error(vals...) } -func (l *logger) Errorf(format string, vals ...interface{}) { +func (l *logger) Errorf(format string, vals ...any) { l.sugar.Errorf(format, vals...) } -func (l *logger) Errord(msg string, details ...interface{}) { +func (l *logger) Errord(msg string, details ...any) { if len(details) == 1 { l.logger.Error(msg, zap.Any(detailsKey, details[0])) return @@ -202,15 +202,15 @@ func (l *logger) Errord(msg string, details ...interface{}) { l.logger.Error(msg, zap.Any(detailsKey, details)) } -func (l *logger) Fatal(vals ...interface{}) { +func (l *logger) Fatal(vals ...any) { l.sugar.Fatal(vals...) } -func (l *logger) Fatalf(format string, vals ...interface{}) { +func (l *logger) Fatalf(format string, vals ...any) { l.sugar.Fatalf(format, vals...) } -func (l *logger) Fatald(msg string, details ...interface{}) { +func (l *logger) Fatald(msg string, details ...any) { if len(details) == 1 { l.logger.Fatal(msg, zap.Any(detailsKey, details[0])) return diff --git a/internal/log/zap/zap_test.go b/internal/log/zap/zap_test.go index c073d75b8b..35e2fbb67c 100644 --- a/internal/log/zap/zap_test.go +++ b/internal/log/zap/zap_test.go @@ -469,7 +469,7 @@ func Test_toZapEncoder(t *testing.T) { func Test_logger_Debug(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { format format.Format @@ -495,7 +495,7 @@ func Test_logger_Debug(t *testing.T) { { name: "just call Debug", args: args{ - vals: []interface{}{"value"}, + vals: []any{"value"}, }, fields: fields{ format: format.RAW, @@ -542,7 +542,7 @@ func Test_logger_Debug(t *testing.T) { func Test_logger_Debugf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { format format.Format @@ -569,7 +569,7 @@ func Test_logger_Debugf(t *testing.T) { name: "just call Debugf", args: args{ format: "%s", - vals: []interface{}{"value"}, + vals: []any{"value"}, }, fields: fields{ format: format.RAW, @@ -615,7 +615,7 @@ func Test_logger_Debugf(t *testing.T) { func Test_logger_Info(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { format format.Format @@ -641,7 +641,7 @@ func Test_logger_Info(t *testing.T) { { name: "just call Info", args: args{ - vals: []interface{}{"value"}, + vals: []any{"value"}, }, fields: fields{ format: format.RAW, @@ -688,7 +688,7 @@ func Test_logger_Info(t *testing.T) { func Test_logger_Infof(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { format format.Format @@ -715,7 +715,7 @@ func Test_logger_Infof(t *testing.T) { name: "just call Infof", args: args{ format: "%s", - vals: []interface{}{"value"}, + vals: []any{"value"}, }, fields: fields{ format: format.RAW, @@ -761,7 +761,7 @@ func Test_logger_Infof(t *testing.T) { func Test_logger_Warn(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { format format.Format @@ -787,7 +787,7 @@ func Test_logger_Warn(t *testing.T) { { name: "just call Warn", args: args{ - vals: []interface{}{"value"}, + vals: []any{"value"}, }, fields: fields{ format: format.RAW, @@ -834,7 +834,7 @@ func Test_logger_Warn(t *testing.T) { func Test_logger_Warnf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { format format.Format @@ -861,7 +861,7 @@ func Test_logger_Warnf(t *testing.T) { name: "just call Warnf", args: args{ format: "%s", - vals: []interface{}{"value"}, + vals: []any{"value"}, }, fields: fields{ format: format.RAW, @@ -907,7 +907,7 @@ func Test_logger_Warnf(t *testing.T) { func Test_logger_Error(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { format format.Format @@ -933,7 +933,7 @@ func Test_logger_Error(t *testing.T) { { name: "just call Error", args: args{ - vals: []interface{}{"value"}, + vals: []any{"value"}, }, fields: fields{ format: format.RAW, @@ -980,7 +980,7 @@ func Test_logger_Error(t *testing.T) { func Test_logger_Errorf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { format format.Format @@ -1007,7 +1007,7 @@ func Test_logger_Errorf(t *testing.T) { name: "just call Errorf", args: args{ format: "%s", - vals: []interface{}{"value"}, + vals: []any{"value"}, }, fields: fields{ format: format.RAW, @@ -1053,7 +1053,7 @@ func Test_logger_Errorf(t *testing.T) { func Test_logger_Fatal(t *testing.T) { type args struct { - vals []interface{} + vals []any } type fields struct { format format.Format @@ -1079,7 +1079,7 @@ func Test_logger_Fatal(t *testing.T) { // { // name: "just call Fatal", // args: args{ - // vals: []interface{}{"value"}, + // vals: []any{"value"}, // }, // fields: fields{ // format: format.RAW, @@ -1128,7 +1128,7 @@ func Test_logger_Fatal(t *testing.T) { func Test_logger_Fatalf(t *testing.T) { type args struct { format string - vals []interface{} + vals []any } type fields struct { format format.Format @@ -1155,7 +1155,7 @@ func Test_logger_Fatalf(t *testing.T) { // name: "just call Fatalf", // args: args{ // format: "%s", - // vals: []interface{}{"value"}, + // vals: []any{"value"}, // }, // fields: fields{ // format: format.RAW, @@ -1205,7 +1205,7 @@ func Test_logger_Debugd(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type fields struct { format format.Format @@ -1232,7 +1232,7 @@ func Test_logger_Debugd(t *testing.T) { name: "just call Debugd", args: args{ msg: "message", - details: []interface{}{"detail"}, + details: []any{"detail"}, }, fields: fields{ format: format.RAW, @@ -1248,7 +1248,7 @@ func Test_logger_Debugd(t *testing.T) { name: "call Debugd with two details", args: args{ msg: "message", - details: []interface{}{ + details: []any{ "detail1", "detail2", }, @@ -1300,7 +1300,7 @@ func Test_logger_Infod(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type fields struct { format format.Format @@ -1327,7 +1327,7 @@ func Test_logger_Infod(t *testing.T) { name: "just call Infod", args: args{ msg: "message", - details: []interface{}{"detail"}, + details: []any{"detail"}, }, fields: fields{ format: format.RAW, @@ -1343,7 +1343,7 @@ func Test_logger_Infod(t *testing.T) { name: "call Infod with two details", args: args{ msg: "message", - details: []interface{}{ + details: []any{ "detail1", "detail2", }, @@ -1395,7 +1395,7 @@ func Test_logger_Warnd(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type fields struct { format format.Format @@ -1422,7 +1422,7 @@ func Test_logger_Warnd(t *testing.T) { name: "just call Warnd", args: args{ msg: "message", - details: []interface{}{"detail"}, + details: []any{"detail"}, }, fields: fields{ format: format.RAW, @@ -1438,7 +1438,7 @@ func Test_logger_Warnd(t *testing.T) { name: "call Warnd with two details", args: args{ msg: "message", - details: []interface{}{ + details: []any{ "detail1", "detail2", }, @@ -1490,7 +1490,7 @@ func Test_logger_Errord(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type fields struct { format format.Format @@ -1517,7 +1517,7 @@ func Test_logger_Errord(t *testing.T) { name: "just call Errord", args: args{ msg: "message", - details: []interface{}{"detail"}, + details: []any{"detail"}, }, fields: fields{ format: format.RAW, @@ -1533,7 +1533,7 @@ func Test_logger_Errord(t *testing.T) { name: "call Errord with two details", args: args{ msg: "message", - details: []interface{}{ + details: []any{ "detail1", "detail2", }, @@ -1585,7 +1585,7 @@ func Test_logger_Fatald(t *testing.T) { t.Parallel() type args struct { msg string - details []interface{} + details []any } type fields struct { format format.Format @@ -1612,7 +1612,7 @@ func Test_logger_Fatald(t *testing.T) { // name: "just call Fatald", // args: args{ // msg: "message", - // details: []interface{}{"detail"}, + // details: []any{"detail"}, // }, // fields: fields{ // format: format.RAW, @@ -1628,7 +1628,7 @@ func Test_logger_Fatald(t *testing.T) { // name: "call Fatald with two details", // args: args{ // msg: "message", - // details: []interface{}{ + // details: []any{ // "detail1", // "detail2", // }, @@ -1780,7 +1780,6 @@ func Test_logger_Fatald(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/control/control_unix.go b/internal/net/control/control_unix.go index 28ab6f2843..f49cf4ef21 100644 --- a/internal/net/control/control_unix.go +++ b/internal/net/control/control_unix.go @@ -19,9 +19,7 @@ // Package control provides network socket option package control -import ( - "golang.org/x/sys/unix" -) +import "golang.org/x/sys/unix" var SetsockoptInt = unix.SetsockoptInt diff --git a/internal/net/control/control_windows.go b/internal/net/control/control_windows.go index 33a7818059..bc0d9a23c2 100644 --- a/internal/net/control/control_windows.go +++ b/internal/net/control/control_windows.go @@ -19,9 +19,7 @@ // Package control provides network socket option package control -import ( - "golang.org/x/sys/windows" -) +import "golang.org/x/sys/windows" var SetsockoptInt = func(fd, level, opt int, value int) (err error) { if level == windows.SOL_SOCKET && opt == windows.SO_REUSEADDR { diff --git a/internal/net/dialer.go b/internal/net/dialer.go index ff6571043a..8eda81e568 100644 --- a/internal/net/dialer.go +++ b/internal/net/dialer.go @@ -336,7 +336,9 @@ func (d *dialer) dial(ctx context.Context, network, addr string) (conn Conn, err return conn, nil } -func (d *dialer) tlsHandshake(ctx context.Context, conn Conn, network, addr string) (tconn *tls.Conn, err error) { +func (d *dialer) tlsHandshake( + ctx context.Context, conn Conn, network, addr string, +) (tconn *tls.Conn, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Dialer.tlsHandshake") defer func() { if span != nil { diff --git a/internal/net/dialer_test.go b/internal/net/dialer_test.go index 8700d73bac..3e366b1f22 100644 --- a/internal/net/dialer_test.go +++ b/internal/net/dialer_test.go @@ -1985,7 +1985,6 @@ func Test_dialer_tlsHandshake(t *testing.T) { // if err := checkFunc(test.want, gotIps, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/admin/admin.go b/internal/net/grpc/admin/admin.go index 66e320bc1b..1380b08479 100644 --- a/internal/net/grpc/admin/admin.go +++ b/internal/net/grpc/admin/admin.go @@ -17,8 +17,6 @@ // Package admin provides grpc admin metrics registration API for providing grpc metrics endpoints package admin -import ( - "google.golang.org/grpc/admin" -) +import "google.golang.org/grpc/admin" var Register = admin.Register diff --git a/internal/net/grpc/client.go b/internal/net/grpc/client.go index 291a8c0c83..b6a4f3eceb 100644 --- a/internal/net/grpc/client.go +++ b/internal/net/grpc/client.go @@ -80,10 +80,10 @@ type Client interface { Do(ctx context.Context, addr string, f func(ctx context.Context, conn *ClientConn, - copts ...CallOption) (interface{}, error)) (interface{}, error) + copts ...CallOption) (any, error)) (any, error) RoundRobin(ctx context.Context, f func(ctx context.Context, conn *ClientConn, - copts ...CallOption) (interface{}, error)) (interface{}, error) + copts ...CallOption) (any, error)) (any, error) GetDialOption() []DialOption GetCallOption() []CallOption GetBackoff() backoff.Backoff @@ -342,7 +342,7 @@ func (g *gRPCClient) StartConnectionMonitor(ctx context.Context) (<-chan error, var p pool.Conn if enabled && g.bo != nil { - _, err = g.bo.Do(clctx, func(ictx context.Context) (r interface{}, ret bool, err error) { + _, err = g.bo.Do(clctx, func(ictx context.Context) (r any, ret bool, err error) { p, err = g.Connect(ictx, addr) return nil, err != nil, err }) @@ -399,7 +399,8 @@ func (g *gRPCClient) StartConnectionMonitor(ctx context.Context) (<-chan error, return ech, nil } -func (g *gRPCClient) Range(ctx context.Context, +func (g *gRPCClient) Range( + ctx context.Context, f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error, ) (err error) { sctx, span := trace.StartSpan(ctx, apiName+"/Client.Range") @@ -423,7 +424,7 @@ func (g *gRPCClient) Range(ctx context.Context, return false default: _, err := g.connectWithBackoff(ssctx, p, addr, true, func(ictx context.Context, conn *ClientConn, copts ...CallOption, - ) (interface{}, error) { + ) (any, error) { return nil, f(ictx, addr, conn, copts...) }) if err != nil { @@ -455,8 +456,10 @@ func (g *gRPCClient) Range(ctx context.Context, return nil } -func (g *gRPCClient) RangeConcurrent(ctx context.Context, - concurrency int, f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error, +func (g *gRPCClient) RangeConcurrent( + ctx context.Context, + concurrency int, + f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error, ) (err error) { sctx, span := trace.StartSpan(ctx, apiName+"/Client.RangeConcurrent") defer func() { @@ -491,7 +494,7 @@ func (g *gRPCClient) RangeConcurrent(ctx context.Context, default: _, err = g.connectWithBackoff(ssctx, p, addr, true, func(ictx context.Context, conn *ClientConn, copts ...CallOption, - ) (interface{}, error) { + ) (any, error) { err := f(ictx, addr, conn, copts...) return nil, err }) @@ -534,8 +537,10 @@ func (g *gRPCClient) RangeConcurrent(ctx context.Context, return nil } -func (g *gRPCClient) OrderedRange(ctx context.Context, - orders []string, f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error, +func (g *gRPCClient) OrderedRange( + ctx context.Context, + orders []string, + f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error, ) (err error) { sctx, span := trace.StartSpan(ctx, apiName+"/Client.OrderedRange") defer func() { @@ -571,7 +576,7 @@ func (g *gRPCClient) OrderedRange(ctx context.Context, }() _, ierr := g.connectWithBackoff(ssctx, p, addr, true, func(ictx context.Context, conn *ClientConn, copts ...CallOption, - ) (interface{}, error) { + ) (any, error) { return nil, f(ictx, addr, conn, copts...) }) if ierr != nil { @@ -598,8 +603,11 @@ func (g *gRPCClient) OrderedRange(ctx context.Context, return nil } -func (g *gRPCClient) OrderedRangeConcurrent(ctx context.Context, - orders []string, concurrency int, f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error, +func (g *gRPCClient) OrderedRangeConcurrent( + ctx context.Context, + orders []string, + concurrency int, + f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error, ) (err error) { sctx, span := trace.StartSpan(ctx, apiName+"/Client.OrderedRangeConcurrent") defer func() { @@ -640,7 +648,7 @@ func (g *gRPCClient) OrderedRangeConcurrent(ctx context.Context, default: _, err = g.connectWithBackoff(ssctx, p, addr, true, func(ictx context.Context, conn *ClientConn, copts ...CallOption, - ) (interface{}, error) { + ) (any, error) { return nil, f(ictx, addr, conn, copts...) }) if err != nil { @@ -669,9 +677,11 @@ func (g *gRPCClient) OrderedRangeConcurrent(ctx context.Context, return nil } -func (g *gRPCClient) RoundRobin(ctx context.Context, f func(ctx context.Context, - conn *ClientConn, copts ...CallOption) (interface{}, error), -) (data interface{}, err error) { +func (g *gRPCClient) RoundRobin( + ctx context.Context, + f func(ctx context.Context, + conn *ClientConn, copts ...CallOption) (any, error), +) (data any, err error) { sctx, span := trace.StartSpan(ctx, apiName+"/Client.RoundRobin") defer func() { if span != nil { @@ -687,7 +697,7 @@ func (g *gRPCClient) RoundRobin(ctx context.Context, f func(ctx context.Context, sctx = backoff.WithBackoffName(sctx, boName) } - do := func() (data interface{}, err error) { + do := func() (data any, err error) { cerr := g.rangeConns(func(addr string, p pool.Conn) bool { select { case <-ctx.Done(): @@ -707,7 +717,7 @@ func (g *gRPCClient) RoundRobin(ctx context.Context, f func(ctx context.Context, ctx = backoff.WithBackoffName(ctx, boName) } if g.cb != nil && len(boName) > 0 { - data, err = g.cb.Do(ctx, boName, func(ictx context.Context) (interface{}, error) { + data, err = g.cb.Do(ctx, boName, func(ictx context.Context) (any, error) { return g.connectWithBackoff(ictx, p, addr, false, f) }) if err != nil { @@ -748,7 +758,7 @@ func (g *gRPCClient) RoundRobin(ctx context.Context, f func(ctx context.Context, } if g.bo != nil { - return g.bo.Do(sctx, func(ictx context.Context) (r interface{}, ret bool, err error) { + return g.bo.Do(sctx, func(ictx context.Context) (r any, ret bool, err error) { r, err = do() if err != nil { if errors.Is(err, context.Canceled) || @@ -781,10 +791,12 @@ func (g *gRPCClient) RoundRobin(ctx context.Context, f func(ctx context.Context, return do() } -func (g *gRPCClient) Do(ctx context.Context, addr string, +func (g *gRPCClient) Do( + ctx context.Context, + addr string, f func(ctx context.Context, - conn *ClientConn, copts ...CallOption) (interface{}, error), -) (data interface{}, err error) { + conn *ClientConn, copts ...CallOption) (any, error), +) (data any, err error) { sctx, span := trace.StartSpan(ctx, apiName+"/Client.Do/"+addr) defer func() { if span != nil { @@ -815,10 +827,14 @@ func (g *gRPCClient) Do(ctx context.Context, addr string, return data, err } -func (g *gRPCClient) connectWithBackoff(ctx context.Context, p pool.Conn, addr string, enableBackoff bool, +func (g *gRPCClient) connectWithBackoff( + ctx context.Context, + p pool.Conn, + addr string, + enableBackoff bool, f func(ctx context.Context, - conn *ClientConn, copts ...CallOption) (interface{}, error), -) (data interface{}, err error) { + conn *ClientConn, copts ...CallOption) (any, error), +) (data any, err error) { if p == nil { g.crl.Store(addr, true) err = errors.ErrGRPCClientConnNotFound(addr) @@ -837,7 +853,7 @@ func (g *gRPCClient) connectWithBackoff(ctx context.Context, p pool.Conn, addr s if boName = FromGRPCMethod(sctx); boName != "" { sctx = backoff.WithBackoffName(sctx, boName) } - do := func(ctx context.Context) (r interface{}, ret bool, err error) { + do := func(ctx context.Context) (r any, ret bool, err error) { err = p.Do(ctx, func(conn *ClientConn) (err error) { if conn == nil { return errors.ErrGRPCClientConnNotFound(addr) @@ -873,9 +889,9 @@ func (g *gRPCClient) connectWithBackoff(ctx context.Context, p pool.Conn, addr s } return r, false, nil } - data, err = g.bo.Do(sctx, func(ictx context.Context) (r interface{}, ret bool, err error) { + data, err = g.bo.Do(sctx, func(ictx context.Context) (r any, ret bool, err error) { if g.cb != nil && len(boName) > 0 { - r, err = g.cb.Do(ictx, boName, func(ictx context.Context) (interface{}, error) { + r, err = g.cb.Do(ictx, boName, func(ictx context.Context) (any, error) { r, ret, err = do(ictx) if err != nil && !ret { return r, errors.NewErrCircuitBreakerIgnorable(err) @@ -930,7 +946,9 @@ func (g *gRPCClient) GetBackoff() backoff.Backoff { return g.bo } -func (g *gRPCClient) Connect(ctx context.Context, addr string, dopts ...DialOption) (conn pool.Conn, err error) { +func (g *gRPCClient) Connect( + ctx context.Context, addr string, dopts ...DialOption, +) (conn pool.Conn, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Client.Connect/"+addr) defer func() { if span != nil { diff --git a/internal/net/grpc/client_test.go b/internal/net/grpc/client_test.go index da238411a4..f28d50023b 100644 --- a/internal/net/grpc/client_test.go +++ b/internal/net/grpc/client_test.go @@ -100,7 +100,6 @@ package grpc // if err := checkFunc(test.want, gotC); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -287,7 +286,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -473,7 +471,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -662,7 +659,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -851,7 +847,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1043,7 +1038,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1051,7 +1045,7 @@ package grpc // func Test_gRPCClient_RoundRobin(t *testing.T) { // type args struct { // ctx context.Context -// f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (interface{}, error) +// f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (any, error) // } // type fields struct { // addrs map[string]struct{} @@ -1078,7 +1072,7 @@ package grpc // stopMonitor context.CancelFunc // } // type want struct { -// wantData interface{} +// wantData any // err error // } // type test struct { @@ -1086,11 +1080,11 @@ package grpc // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotData interface{}, err error) error { +// defaultCheckFunc := func(w want, gotData any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -1233,7 +1227,6 @@ package grpc // if err := checkFunc(test.want, gotData, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1242,7 +1235,7 @@ package grpc // type args struct { // ctx context.Context // addr string -// f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (interface{}, error) +// f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (any, error) // } // type fields struct { // addrs map[string]struct{} @@ -1269,7 +1262,7 @@ package grpc // stopMonitor context.CancelFunc // } // type want struct { -// wantData interface{} +// wantData any // err error // } // type test struct { @@ -1277,11 +1270,11 @@ package grpc // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotData interface{}, err error) error { +// defaultCheckFunc := func(w want, gotData any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -1426,7 +1419,6 @@ package grpc // if err := checkFunc(test.want, gotData, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1437,7 +1429,7 @@ package grpc // p pool.Conn // addr string // enableBackoff bool -// f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (interface{}, error) +// f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (any, error) // } // type fields struct { // addrs map[string]struct{} @@ -1464,7 +1456,7 @@ package grpc // stopMonitor context.CancelFunc // } // type want struct { -// wantData interface{} +// wantData any // err error // } // type test struct { @@ -1472,11 +1464,11 @@ package grpc // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotData interface{}, err error) error { +// defaultCheckFunc := func(w want, gotData any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -1625,7 +1617,6 @@ package grpc // if err := checkFunc(test.want, gotData, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1798,7 +1789,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1971,7 +1961,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2144,7 +2133,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2337,7 +2325,6 @@ package grpc // if err := checkFunc(test.want, gotConn, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2523,7 +2510,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2709,7 +2695,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2882,7 +2867,6 @@ package grpc // if err := checkFunc(test.want, gotAddrs); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3065,7 +3049,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3248,7 +3231,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/codec.go b/internal/net/grpc/codec.go index f19824197b..588bbb70e1 100644 --- a/internal/net/grpc/codec.go +++ b/internal/net/grpc/codec.go @@ -34,7 +34,7 @@ type vtprotoMessage interface { } // Marshal returns byte slice representing the proto message marshalling result. -func (Codec) Marshal(obj interface{}) (data []byte, err error) { +func (Codec) Marshal(obj any) (data []byte, err error) { switch v := obj.(type) { case vtprotoMessage: data, err = v.MarshalVT() @@ -50,7 +50,7 @@ func (Codec) Marshal(obj interface{}) (data []byte, err error) { } // Unmarshal parses the byte stream data into v. -func (Codec) Unmarshal(data []byte, obj interface{}) (err error) { +func (Codec) Unmarshal(data []byte, obj any) (err error) { switch v := obj.(type) { case vtprotoMessage: err = v.UnmarshalVT(data) diff --git a/internal/net/grpc/codec_test.go b/internal/net/grpc/codec_test.go index 6c9b941f70..4aa8c81c46 100644 --- a/internal/net/grpc/codec_test.go +++ b/internal/net/grpc/codec_test.go @@ -28,7 +28,7 @@ import ( func TestCodec_Marshal(t *testing.T) { t.Parallel() type args struct { - v interface{} + v any } type want struct { want []byte @@ -121,7 +121,7 @@ func TestCodec_Unmarshal(t *testing.T) { t.Parallel() type args struct { data []byte - v interface{} + v any } type want struct { err error diff --git a/internal/net/grpc/context_test.go b/internal/net/grpc/context_test.go index ab790f32db..003d7e305d 100644 --- a/internal/net/grpc/context_test.go +++ b/internal/net/grpc/context_test.go @@ -99,7 +99,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -188,7 +187,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -274,7 +272,6 @@ package grpc // 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 1b24f34fc6..ad84b6c0b2 100644 --- a/internal/net/grpc/errdetails/errdetails.go +++ b/internal/net/grpc/errdetails/errdetails.go @@ -79,7 +79,7 @@ type Detail struct { Message proto.Message `json:"message,omitempty" yaml:"message"` } -func decodeDetails(objs ...interface{}) (details []Detail) { +func decodeDetails(objs ...any) (details []Detail) { if objs == nil { return nil } @@ -93,9 +93,9 @@ func decodeDetails(objs ...interface{}) (details []Detail) { v = v.Elem() } if v.Kind() == reflect.Slice || v.Kind() == reflect.Array { - iobjs := make([]interface{}, 0, v.Len()) + iobjs := make([]any, 0, v.Len()) for i := 0; i < v.Len(); i++ { - var val interface{} + var val any if v.Index(i).Kind() == reflect.Ptr { val = v.Index(i).Elem().Interface() } else { @@ -209,7 +209,7 @@ func decodeDetails(objs ...interface{}) (details []Detail) { return details } -func Serialize(objs ...interface{}) string { +func Serialize(objs ...any) string { var ( b []byte err error @@ -326,9 +326,24 @@ func AnyToErrorDetail(a *types.Any) proto.Message { return a.ProtoReflect().Interface() } -func DebugInfoFromInfoDetail(v *info.Detail) *DebugInfo { - debug := &DebugInfo{ - Detail: strings.Join(append(append([]string{ +func DebugInfoFromInfoDetail(v *info.Detail) (debug *DebugInfo) { + debug = new(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(), + }, " ")) + } + v.StackTrace = nil + } + detail, err := json.Marshal(v) + if err != nil { + log.Warnf("failed to Marshal object %#v to JSON error: %v", v, err) + debug.Detail = strings.Join(append(append([]string{ "Version:", v.Version, ",", "Name:", v.ServerName, ",", "GitCommit:", v.GitCommit, ",", @@ -339,18 +354,9 @@ func DebugInfoFromInfoDetail(v *info.Detail) *DebugInfo { "GOOS:", v.GoOS, ",", "CGO_Enabled:", v.CGOEnabled, ",", "BuildCPUInfo: [", - }, v.BuildCPUInfoFlags...), "]"), " "), - } - if debug.GetStackEntries() == 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(), - }, " ")) + }, v.BuildCPUInfoFlags...), "]"), " ") + } else { + debug.Detail = string(detail) } return debug } diff --git a/internal/net/grpc/errdetails/errdetails_test.go b/internal/net/grpc/errdetails/errdetails_test.go index 0dd719afce..0a80077106 100644 --- a/internal/net/grpc/errdetails/errdetails_test.go +++ b/internal/net/grpc/errdetails/errdetails_test.go @@ -29,7 +29,7 @@ import ( func Test_decodeDetails(t *testing.T) { t.Parallel() type args struct { - objs []interface{} + objs []any } tests := []struct { name string @@ -50,7 +50,7 @@ func Test_decodeDetails(t *testing.T) { func TestSerialize(t *testing.T) { t.Parallel() type args struct { - objs []interface{} + objs []any } tests := []struct { name string diff --git a/internal/net/grpc/handler.go b/internal/net/grpc/handler.go index 916a248aed..cb6cb0b936 100644 --- a/internal/net/grpc/handler.go +++ b/internal/net/grpc/handler.go @@ -17,9 +17,7 @@ // Package grpc provides generic functionality for grpc package grpc -import ( - "google.golang.org/grpc" -) +import "google.golang.org/grpc" var ( StatsHandler = grpc.StatsHandler diff --git a/internal/net/grpc/interceptor.go b/internal/net/grpc/interceptor.go index ffe74f2c12..e6421b4268 100644 --- a/internal/net/grpc/interceptor.go +++ b/internal/net/grpc/interceptor.go @@ -17,9 +17,7 @@ // Package grpc provides generic functionality for grpc package grpc -import ( - "google.golang.org/grpc" -) +import "google.golang.org/grpc" type ( UnaryServerInterceptor = grpc.UnaryServerInterceptor diff --git a/internal/net/grpc/interceptor/client/metric/metric_test.go b/internal/net/grpc/interceptor/client/metric/metric_test.go new file mode 100644 index 0000000000..0090bc8e2e --- /dev/null +++ b/internal/net/grpc/interceptor/client/metric/metric_test.go @@ -0,0 +1,187 @@ +// 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 metric + +// NOT IMPLEMENTED BELOW +// +// func TestClientMetricInterceptors(t *testing.T) { +// type want struct { +// want grpc.UnaryClientInterceptor +// want1 grpc.StreamClientInterceptor +// err error +// } +// type test struct { +// name string +// want want +// checkFunc func(want, grpc.UnaryClientInterceptor, grpc.StreamClientInterceptor, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got grpc.UnaryClientInterceptor, got1 grpc.StreamClientInterceptor, 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) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// 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 +// } +// +// got, got1, err := ClientMetricInterceptors() +// if err := checkFunc(test.want, got, got1, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_attributesFromError(t *testing.T) { +// type args struct { +// method string +// err error +// } +// type want struct { +// want []attribute.KeyValue +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, []attribute.KeyValue) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got []attribute.KeyValue) 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 { +// method:"", +// err: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 { +// method:"", +// err: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 := attributesFromError(test.args.method, test.args.err) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/net/grpc/interceptor/client/trace/trace.go b/internal/net/grpc/interceptor/client/trace/trace.go index aee5a63edc..baa4f81b31 100644 --- a/internal/net/grpc/interceptor/client/trace/trace.go +++ b/internal/net/grpc/interceptor/client/trace/trace.go @@ -13,9 +13,7 @@ // limitations under the License. package trace -import ( - "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" -) +import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" var ( UnaryClientInterceptor = otelgrpc.UnaryClientInterceptor diff --git a/internal/net/grpc/interceptor/server/logging/accesslog.go b/internal/net/grpc/interceptor/server/logging/accesslog.go index 5da857a758..9de30d1aaa 100644 --- a/internal/net/grpc/interceptor/server/logging/accesslog.go +++ b/internal/net/grpc/interceptor/server/logging/accesslog.go @@ -52,10 +52,10 @@ type AccessLogGRPCEntity struct { func AccessLogInterceptor() grpc.UnaryServerInterceptor { return func( ctx context.Context, - req interface{}, + req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, - ) (resp interface{}, err error) { + ) (resp any, err error) { var traceID string span := trace.FromContext(ctx) @@ -99,7 +99,7 @@ func AccessLogInterceptor() grpc.UnaryServerInterceptor { func AccessLogStreamInterceptor() grpc.StreamServerInterceptor { return func( - srv interface{}, + srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler, diff --git a/internal/net/grpc/interceptor/server/logging/accesslog_test.go b/internal/net/grpc/interceptor/server/logging/accesslog_test.go index 9c3d154b1b..328f92880a 100644 --- a/internal/net/grpc/interceptor/server/logging/accesslog_test.go +++ b/internal/net/grpc/interceptor/server/logging/accesslog_test.go @@ -100,7 +100,6 @@ func TestMain(m *testing.M) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -176,7 +175,6 @@ func TestMain(m *testing.M) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -266,7 +264,6 @@ func TestMain(m *testing.M) { // if err := checkFunc(test.want, gotService, gotMethod); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/interceptor/server/metric/metric.go b/internal/net/grpc/interceptor/server/metric/metric.go index 15ced6c53e..574386d483 100644 --- a/internal/net/grpc/interceptor/server/metric/metric.go +++ b/internal/net/grpc/interceptor/server/metric/metric.go @@ -59,13 +59,13 @@ func MetricInterceptors() (grpc.UnaryServerInterceptor, grpc.StreamServerInterce latencyHistgram.Record(ctx, latency, metrics.WithAttributes(attrs...)) completedRPCCnt.Add(ctx, 1, metrics.WithAttributes(attrs...)) } - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { now := time.Now() resp, err = handler(ctx, req) elapsedTime := time.Since(now) record(ctx, info.FullMethod, err, float64(elapsedTime)/float64(time.Millisecond)) return resp, err - }, func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) { + }, func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) { now := time.Now() err = handler(srv, ss) elapsedTime := time.Since(now) diff --git a/internal/net/grpc/interceptor/server/metric/metric_test.go b/internal/net/grpc/interceptor/server/metric/metric_test.go index 02596d06fb..7de9baa1a8 100644 --- a/internal/net/grpc/interceptor/server/metric/metric_test.go +++ b/internal/net/grpc/interceptor/server/metric/metric_test.go @@ -198,7 +198,6 @@ func Test_attributesFromError(t *testing.T) { // if err := checkFunc(test.want, got, got1, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/interceptor/server/recover/recover.go b/internal/net/grpc/interceptor/server/recover/recover.go index 12a6a313d6..dfcfc0bd07 100644 --- a/internal/net/grpc/interceptor/server/recover/recover.go +++ b/internal/net/grpc/interceptor/server/recover/recover.go @@ -27,10 +27,10 @@ import ( func RecoverInterceptor() grpc.UnaryServerInterceptor { return func( ctx context.Context, - req interface{}, + req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, - ) (resp interface{}, err error) { + ) (resp any, err error) { err = safety.RecoverWithoutPanicFunc(func() (err error) { resp, err = handler(ctx, req) return err @@ -41,7 +41,7 @@ func RecoverInterceptor() grpc.UnaryServerInterceptor { func RecoverStreamInterceptor() grpc.StreamServerInterceptor { return func( - srv interface{}, + srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler, diff --git a/internal/net/grpc/interceptor/server/recover/recover_test.go b/internal/net/grpc/interceptor/server/recover/recover_test.go index 327cfc24d8..dab236839d 100644 --- a/internal/net/grpc/interceptor/server/recover/recover_test.go +++ b/internal/net/grpc/interceptor/server/recover/recover_test.go @@ -100,7 +100,6 @@ func TestMain(m *testing.M) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -176,7 +175,6 @@ func TestMain(m *testing.M) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/interceptor/server/trace/trace_test.go b/internal/net/grpc/interceptor/server/trace/trace_test.go index 311c274e29..023ee2e530 100644 --- a/internal/net/grpc/interceptor/server/trace/trace_test.go +++ b/internal/net/grpc/interceptor/server/trace/trace_test.go @@ -86,7 +86,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -162,7 +161,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/logger/logger.go b/internal/net/grpc/logger/logger.go index 4c18a7d3ab..064b544a54 100644 --- a/internal/net/grpc/logger/logger.go +++ b/internal/net/grpc/logger/logger.go @@ -44,64 +44,64 @@ func Init() { } // Info prints the debug log to the logger. -func (*logger) Info(args ...interface{}) { +func (*logger) Info(args ...any) { log.Debugd(tag, args...) } // Infoln prints the debug log to the logger. -func (*logger) Infoln(args ...interface{}) { +func (*logger) Infoln(args ...any) { log.Debugd(tag, args...) } // Infof prints the debug log to the logger. -func (*logger) Infof(format string, args ...interface{}) { +func (*logger) Infof(format string, args ...any) { log.Debugf(tag+"\t"+format, args...) } // Warning prints the warning log to the logger. -func (*logger) Warning(args ...interface{}) { +func (*logger) Warning(args ...any) { log.Warnd(tag, args...) } // Warningln prints the warning log to the logger. -func (*logger) Warningln(args ...interface{}) { +func (*logger) Warningln(args ...any) { log.Warnd(tag, args...) } // Warningf prints the warning log to the logger. -func (*logger) Warningf(format string, args ...interface{}) { +func (*logger) Warningf(format string, args ...any) { log.Warnf(tag+"\t"+format, args...) } // Error prints the error log to the logger. -func (*logger) Error(args ...interface{}) { +func (*logger) Error(args ...any) { log.Errord(tag, args...) } // Errorln prints the error log to the logger. -func (*logger) Errorln(args ...interface{}) { +func (*logger) Errorln(args ...any) { log.Errord(tag, args...) } // Errorf prints the error log to the logger. -func (*logger) Errorf(format string, args ...interface{}) { +func (*logger) Errorf(format string, args ...any) { log.Errorf(tag+"\t"+format, args...) } // Fatal prints the fatal log to the logger and exit the program. -func (*logger) Fatal(args ...interface{}) { +func (*logger) Fatal(args ...any) { // skipcq: RVV-A0003 log.Fatald(tag, args...) } // Fatalln prints the fatal log to the logger and exit the program. -func (*logger) Fatalln(args ...interface{}) { +func (*logger) Fatalln(args ...any) { // skipcq: RVV-A0003 log.Fatald(tag, args...) } // Fatalf prints the fatal log to the logger and exit the program. -func (*logger) Fatalf(format string, args ...interface{}) { +func (*logger) Fatalf(format string, args ...any) { // skipcq: RVV-A0003 log.Fatalf(tag+"\t"+format, args...) } diff --git a/internal/net/grpc/logger/logger_test.go b/internal/net/grpc/logger/logger_test.go index 7583e4c6d4..5d615d1e71 100644 --- a/internal/net/grpc/logger/logger_test.go +++ b/internal/net/grpc/logger/logger_test.go @@ -102,7 +102,7 @@ func TestInit(t *testing.T) { func Test_logger_Info(t *testing.T) { t.Parallel() type args struct { - args []interface{} + args []any } type fields struct { v int @@ -122,7 +122,7 @@ func Test_logger_Info(t *testing.T) { { name: "Info success to log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -158,7 +158,7 @@ func Test_logger_Info(t *testing.T) { func Test_logger_Infoln(t *testing.T) { t.Parallel() type args struct { - args []interface{} + args []any } type fields struct { v int @@ -178,7 +178,7 @@ func Test_logger_Infoln(t *testing.T) { { name: "Infoln success to log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -215,7 +215,7 @@ func Test_logger_Infof(t *testing.T) { t.Parallel() type args struct { format string - args []interface{} + args []any } type fields struct { v int @@ -235,7 +235,7 @@ func Test_logger_Infof(t *testing.T) { { name: "Infof success to log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -271,7 +271,7 @@ func Test_logger_Infof(t *testing.T) { func Test_logger_Warning(t *testing.T) { t.Parallel() type args struct { - args []interface{} + args []any } type fields struct { v int @@ -291,7 +291,7 @@ func Test_logger_Warning(t *testing.T) { { name: "Warning success to log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -327,7 +327,7 @@ func Test_logger_Warning(t *testing.T) { func Test_logger_Warningln(t *testing.T) { t.Parallel() type args struct { - args []interface{} + args []any } type fields struct { v int @@ -347,7 +347,7 @@ func Test_logger_Warningln(t *testing.T) { { name: "Warningln success to log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -384,7 +384,7 @@ func Test_logger_Warningf(t *testing.T) { t.Parallel() type args struct { format string - args []interface{} + args []any } type fields struct { v int @@ -404,7 +404,7 @@ func Test_logger_Warningf(t *testing.T) { { name: "Warningf success to log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -440,7 +440,7 @@ func Test_logger_Warningf(t *testing.T) { func Test_logger_Error(t *testing.T) { t.Parallel() type args struct { - args []interface{} + args []any } type fields struct { v int @@ -460,7 +460,7 @@ func Test_logger_Error(t *testing.T) { { name: "Error success to log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -496,7 +496,7 @@ func Test_logger_Error(t *testing.T) { func Test_logger_Errorln(t *testing.T) { t.Parallel() type args struct { - args []interface{} + args []any } type fields struct { v int @@ -516,7 +516,7 @@ func Test_logger_Errorln(t *testing.T) { { name: "Errorln success to log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -553,7 +553,7 @@ func Test_logger_Errorf(t *testing.T) { t.Parallel() type args struct { format string - args []interface{} + args []any } type fields struct { v int @@ -573,7 +573,7 @@ func Test_logger_Errorf(t *testing.T) { { name: "Errorf success to log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -618,7 +618,7 @@ func Test_logger_Fatal(t *testing.T) { } type args struct { - args []interface{} + args []any } type fields struct { v int @@ -638,7 +638,7 @@ func Test_logger_Fatal(t *testing.T) { { name: "Fatal log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -687,7 +687,7 @@ func Test_logger_Fatalln(t *testing.T) { } type args struct { - args []interface{} + args []any } type fields struct { v int @@ -707,7 +707,7 @@ func Test_logger_Fatalln(t *testing.T) { { name: "Fatalln log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, @@ -753,7 +753,7 @@ func Test_logger_Fatalf(t *testing.T) { type args struct { format string - args []interface{} + args []any } type fields struct { v int @@ -773,7 +773,7 @@ func Test_logger_Fatalf(t *testing.T) { { name: "Fatalf log the message", args: args{ - args: []interface{}{"log message"}, + args: []any{"log message"}, }, fields: fields{ v: 0, diff --git a/internal/net/grpc/metadata_test.go b/internal/net/grpc/metadata_test.go new file mode 100644 index 0000000000..193e2e3994 --- /dev/null +++ b/internal/net/grpc/metadata_test.go @@ -0,0 +1,193 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func TestNewOutgoingContext(t *testing.T) { +// type args struct { +// ctx context.Context +// md MD +// } +// type want struct { +// want context.Context +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, context.Context) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got context.Context) 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 { +// ctx:nil, +// md: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 { +// ctx:nil, +// md: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 := NewOutgoingContext(test.args.ctx, test.args.md) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestFromIncomingContext(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type want struct { +// want metadata.MD +// want1 bool +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, metadata.MD, bool) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got metadata.MD, got1 bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx: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 { +// ctx: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, got1 := FromIncomingContext(test.args.ctx) +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/net/grpc/option_test.go b/internal/net/grpc/option_test.go index 0ee01e2afa..a459b4b9f7 100644 --- a/internal/net/grpc/option_test.go +++ b/internal/net/grpc/option_test.go @@ -100,7 +100,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -702,7 +695,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -788,7 +780,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -874,7 +865,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -960,7 +950,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1046,7 +1035,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1132,7 +1120,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1218,7 +1205,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1304,7 +1290,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1390,7 +1375,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1476,7 +1460,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1562,7 +1545,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1648,7 +1630,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1734,7 +1715,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1820,7 +1800,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1906,7 +1885,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1992,7 +1970,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2078,7 +2055,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2164,7 +2140,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2250,7 +2225,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2342,7 +2316,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2428,7 +2401,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2514,7 +2486,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2600,7 +2571,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2686,7 +2656,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/pool/option_test.go b/internal/net/grpc/pool/option_test.go index 46e50f40e8..baf82c7869 100644 --- a/internal/net/grpc/pool/option_test.go +++ b/internal/net/grpc/pool/option_test.go @@ -100,7 +100,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -702,7 +695,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -788,7 +780,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -874,7 +865,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -960,7 +950,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1046,7 +1035,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/pool/pool.go b/internal/net/grpc/pool/pool.go index 9bb199ac2a..e0c3d34776 100644 --- a/internal/net/grpc/pool/pool.go +++ b/internal/net/grpc/pool/pool.go @@ -229,7 +229,9 @@ func (p *pool) store(idx int, pc *poolConn) { p.pmu.RUnlock() } -func (p *pool) loop(ctx context.Context, fn func(ctx context.Context, idx int, pc *poolConn) bool) (err error) { +func (p *pool) loop( + ctx context.Context, fn func(ctx context.Context, idx int, pc *poolConn) bool, +) (err error) { if p == nil || fn == nil { return nil } @@ -494,7 +496,7 @@ func (p *pool) dial(ctx context.Context, addr string) (conn *ClientConn, err err } if p.bo != nil { retry := 0 - _, err = p.bo.Do(ctx, func(ctx context.Context) (r interface{}, ret bool, err error) { + _, err = p.bo.Do(ctx, func(ctx context.Context) (r any, ret bool, err error) { log.Debugf("dialing to %s with backoff, retry: %d", addr, retry) conn, err = do() retry++ diff --git a/internal/net/grpc/pool/pool_test.go b/internal/net/grpc/pool/pool_test.go index c5d95b3b76..8335f58fad 100644 --- a/internal/net/grpc/pool/pool_test.go +++ b/internal/net/grpc/pool/pool_test.go @@ -103,7 +103,6 @@ package pool // if err := checkFunc(test.want, gotC, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -131,8 +130,7 @@ package pool // resolveDNS bool // reconnectHash atomic.Pointer[string] // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -289,8 +287,7 @@ package pool // resolveDNS bool // reconnectHash atomic.Pointer[string] // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -582,7 +579,6 @@ package pool // if err := checkFunc(test.want, gotPc); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -611,8 +607,7 @@ package pool // resolveDNS bool // reconnectHash atomic.Pointer[string] // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -909,7 +904,6 @@ package pool // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1062,7 +1056,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1215,7 +1208,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1240,8 +1232,7 @@ package pool // resolveDNS bool // reconnectHash atomic.Pointer[string] // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields @@ -1535,7 +1526,6 @@ package pool // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1702,7 +1692,175 @@ package pool // if err := checkFunc(test.want, gotC, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_pool_connect(t *testing.T) { +// type args struct { +// ctx context.Context +// ips []string +// } +// type fields struct { +// pool []atomic.Pointer[poolConn] +// startPort uint16 +// endPort uint16 +// host string +// port uint16 +// addr string +// size atomic.Uint64 +// current atomic.Uint64 +// bo backoff.Backoff +// eg errgroup.Group +// dopts []DialOption +// dialTimeout time.Duration +// roccd time.Duration +// closing atomic.Bool +// isIP bool +// resolveDNS bool +// reconnectHash atomic.Pointer[string] +// } +// type want struct { +// wantC Conn +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, Conn, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotC Conn, err error) error { +// if !errors.Is(err, w.err) { +// return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) +// } +// if !reflect.DeepEqual(gotC, w.wantC) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotC, w.wantC) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// ips:nil, +// }, +// fields: fields { +// pool:nil, +// startPort:0, +// endPort:0, +// host:"", +// port:0, +// addr:"", +// size:nil, +// current:nil, +// bo:nil, +// eg:nil, +// dopts:nil, +// dialTimeout:nil, +// roccd:nil, +// closing:nil, +// isIP:false, +// resolveDNS:false, +// reconnectHash: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 { +// ctx:nil, +// ips:nil, +// }, +// fields: fields { +// pool:nil, +// startPort:0, +// endPort:0, +// host:"", +// port:0, +// addr:"", +// size:nil, +// current:nil, +// bo:nil, +// eg:nil, +// dopts:nil, +// dialTimeout:nil, +// roccd:nil, +// closing:nil, +// isIP:false, +// resolveDNS:false, +// reconnectHash: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 +// } +// p := &pool{ +// pool: test.fields.pool, +// startPort: test.fields.startPort, +// endPort: test.fields.endPort, +// host: test.fields.host, +// port: test.fields.port, +// addr: test.fields.addr, +// size: test.fields.size, +// current: test.fields.current, +// bo: test.fields.bo, +// eg: test.fields.eg, +// dopts: test.fields.dopts, +// dialTimeout: test.fields.dialTimeout, +// roccd: test.fields.roccd, +// closing: test.fields.closing, +// isIP: test.fields.isIP, +// resolveDNS: test.fields.resolveDNS, +// reconnectHash: test.fields.reconnectHash, +// } // +// gotC, err := p.connect(test.args.ctx, test.args.ips...) +// if err := checkFunc(test.want, gotC, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -1872,7 +2030,6 @@ package pool // if err := checkFunc(test.want, gotC, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2039,7 +2196,6 @@ package pool // if err := checkFunc(test.want, gotC, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2192,7 +2348,6 @@ package pool // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2362,7 +2517,6 @@ package pool // if err := checkFunc(test.want, gotConn, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2525,7 +2679,6 @@ package pool // if err := checkFunc(test.want, gotHealthy); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2691,7 +2844,6 @@ package pool // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2858,7 +3010,6 @@ package pool // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3031,7 +3182,6 @@ package pool // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3184,7 +3334,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3337,7 +3486,6 @@ package pool // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3504,7 +3652,6 @@ package pool // if err := checkFunc(test.want, gotIps, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3671,7 +3818,6 @@ package pool // if err := checkFunc(test.want, gotPort, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3824,7 +3970,6 @@ package pool // if err := checkFunc(test.want, gotIsIP); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3977,7 +4122,6 @@ package pool // if err := checkFunc(test.want, gotStr); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -4083,13 +4227,13 @@ package pool // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func Test_isHealthy(t *testing.T) { // type args struct { +// ctx context.Context // conn *ClientConn // } // type want struct { @@ -4115,6 +4259,7 @@ package pool // { // name: "test_case_1", // args: args { +// ctx:nil, // conn:nil, // }, // want: want{}, @@ -4134,6 +4279,7 @@ package pool // return test { // name: "test_case_2", // args: args { +// ctx:nil, // conn:nil, // }, // want: want{}, @@ -4165,11 +4311,10 @@ package pool // checkFunc = defaultCheckFunc // } // -// got := isHealthy(test.args.conn) +// got := isHealthy(test.args.ctx, test.args.conn) // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/proto/proto_test.go b/internal/net/grpc/proto/proto_test.go index 388a49b8db..db02685458 100644 --- a/internal/net/grpc/proto/proto_test.go +++ b/internal/net/grpc/proto/proto_test.go @@ -421,7 +421,6 @@ func TestToMessageV1(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/status/status.go b/internal/net/grpc/status/status.go index bea96c2921..cfd0ff085f 100644 --- a/internal/net/grpc/status/status.go +++ b/internal/net/grpc/status/status.go @@ -41,76 +41,76 @@ func New(c codes.Code, msg string) *Status { return status.New(c, msg) } -func newStatus(code codes.Code, msg string, err error, details ...interface{}) (st *Status) { +func newStatus(code codes.Code, msg string, err error, details ...any) (st *Status) { st = New(code, msg) return withDetails(st, err, details...) } -func WrapWithCanceled(msg string, err error, details ...interface{}) error { +func WrapWithCanceled(msg string, err error, details ...any) error { return newStatus(codes.Canceled, msg, err, details...).Err() } -func WrapWithUnknown(msg string, err error, details ...interface{}) error { +func WrapWithUnknown(msg string, err error, details ...any) error { return newStatus(codes.Unknown, msg, err, details...).Err() } -func WrapWithInvalidArgument(msg string, err error, details ...interface{}) error { +func WrapWithInvalidArgument(msg string, err error, details ...any) error { return newStatus(codes.InvalidArgument, msg, err, details...).Err() } -func WrapWithDeadlineExceeded(msg string, err error, details ...interface{}) error { +func WrapWithDeadlineExceeded(msg string, err error, details ...any) error { return newStatus(codes.DeadlineExceeded, msg, err, details...).Err() } -func WrapWithNotFound(msg string, err error, details ...interface{}) error { +func WrapWithNotFound(msg string, err error, details ...any) error { return newStatus(codes.NotFound, msg, err, details...).Err() } -func WrapWithAlreadyExists(msg string, err error, details ...interface{}) error { +func WrapWithAlreadyExists(msg string, err error, details ...any) error { return newStatus(codes.AlreadyExists, msg, err, details...).Err() } -func WrapWithPermissionDenied(msg string, err error, details ...interface{}) error { +func WrapWithPermissionDenied(msg string, err error, details ...any) error { return newStatus(codes.PermissionDenied, msg, err, details...).Err() } -func WrapWithResourceExhausted(msg string, err error, details ...interface{}) error { +func WrapWithResourceExhausted(msg string, err error, details ...any) error { return newStatus(codes.ResourceExhausted, msg, err, details...).Err() } -func WrapWithFailedPrecondition(msg string, err error, details ...interface{}) error { +func WrapWithFailedPrecondition(msg string, err error, details ...any) error { return newStatus(codes.FailedPrecondition, msg, err, details...).Err() } -func WrapWithAborted(msg string, err error, details ...interface{}) error { +func WrapWithAborted(msg string, err error, details ...any) error { return newStatus(codes.Aborted, msg, err, details...).Err() } -func WrapWithOutOfRange(msg string, err error, details ...interface{}) error { +func WrapWithOutOfRange(msg string, err error, details ...any) error { return newStatus(codes.OutOfRange, msg, err, details...).Err() } -func WrapWithUnimplemented(msg string, err error, details ...interface{}) error { +func WrapWithUnimplemented(msg string, err error, details ...any) error { return newStatus(codes.Unimplemented, msg, err, details...).Err() } -func WrapWithInternal(msg string, err error, details ...interface{}) error { +func WrapWithInternal(msg string, err error, details ...any) error { return newStatus(codes.Internal, msg, err, details...).Err() } -func WrapWithUnavailable(msg string, err error, details ...interface{}) error { +func WrapWithUnavailable(msg string, err error, details ...any) error { return newStatus(codes.Unavailable, msg, err, details...).Err() } -func WrapWithDataLoss(msg string, err error, details ...interface{}) error { +func WrapWithDataLoss(msg string, err error, details ...any) error { return newStatus(codes.DataLoss, msg, err, details...).Err() } -func WrapWithUnauthenticated(msg string, err error, details ...interface{}) error { +func WrapWithUnauthenticated(msg string, err error, details ...any) error { return newStatus(codes.Unauthenticated, msg, err, details...).Err() } -func CreateWithNotFound(msg string, err error, details ...interface{}) *Status { +func CreateWithNotFound(msg string, err error, details ...any) *Status { return newStatus(codes.NotFound, msg, err, details...) } @@ -118,11 +118,13 @@ func Error(code codes.Code, msg string) error { return status.Error(code, msg) } -func Errorf(code codes.Code, format string, args ...interface{}) error { +func Errorf(code codes.Code, format string, args ...any) error { return status.Errorf(code, format, args...) } -func ParseError(err error, defaultCode codes.Code, defaultMsg string, details ...interface{}) (st *Status, msg string, rerr error) { +func ParseError( + err error, defaultCode codes.Code, defaultMsg string, details ...any, +) (st *Status, msg string, rerr error) { if err == nil { st = newStatus(codes.OK, "", nil, details...) msg = st.Message() @@ -234,7 +236,7 @@ func FromError(err error) (st *Status, ok bool) { } } -func withDetails(st *Status, err error, details ...interface{}) *Status { +func withDetails(st *Status, err error, details ...any) *Status { msgs := make([]proto.MessageV1, 0, 1+len(details)*2) if err != nil { msgs = append(msgs, &errdetails.ErrorInfo{ diff --git a/internal/net/grpc/status/status_test.go b/internal/net/grpc/status/status_test.go index 04d386bc64..5d9f6d818f 100644 --- a/internal/net/grpc/status/status_test.go +++ b/internal/net/grpc/status/status_test.go @@ -40,7 +40,7 @@ func TestParseError(t *testing.T) { err error defaultCode codes.Code defaultMsg string - details []interface{} + details []any } type want struct { wantSt codes.Code @@ -238,7 +238,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -248,7 +247,7 @@ func TestParseError(t *testing.T) { // code codes.Code // msg string // err error -// details []interface{} +// details []any // } // type want struct { // wantSt *Status @@ -333,7 +332,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, gotSt); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -342,7 +340,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -425,7 +423,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -434,7 +431,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -517,7 +514,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +522,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -609,7 +605,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -618,7 +613,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -701,7 +696,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -710,7 +704,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -793,7 +787,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -802,7 +795,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -885,7 +878,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -894,7 +886,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -977,7 +969,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -986,7 +977,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -1069,7 +1060,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1078,7 +1068,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -1161,7 +1151,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1170,7 +1159,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -1253,7 +1242,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1262,7 +1250,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -1345,7 +1333,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1354,7 +1341,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -1437,7 +1424,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1446,7 +1432,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -1529,7 +1515,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1538,7 +1523,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -1621,7 +1606,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1630,7 +1614,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -1713,7 +1697,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1722,7 +1705,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // err error @@ -1805,7 +1788,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1814,7 +1796,7 @@ func TestParseError(t *testing.T) { // type args struct { // msg string // err error -// details []interface{} +// details []any // } // type want struct { // want *Status @@ -1897,7 +1879,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1986,7 +1967,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1995,7 +1975,7 @@ func TestParseError(t *testing.T) { // type args struct { // code codes.Code // format string -// args []interface{} +// args []any // } // type want struct { // err error @@ -2078,7 +2058,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2168,7 +2147,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, gotSt, gotOk); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2177,7 +2155,7 @@ func TestParseError(t *testing.T) { // type args struct { // st *Status // err error -// details []interface{} +// details []any // } // type want struct { // want *Status @@ -2260,7 +2238,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2270,8 +2247,7 @@ func TestParseError(t *testing.T) { // code codes.Code // err error // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/internal/net/grpc/stream.go b/internal/net/grpc/stream.go index 492280a804..73927fcf9a 100644 --- a/internal/net/grpc/stream.go +++ b/internal/net/grpc/stream.go @@ -45,7 +45,9 @@ type ( // It receives messages from the stream, calls the function with the received message, and sends the returned message to the stream. // It limits the number of concurrent calls to the function with the concurrency integer. // It records errors and returns them as a single error. -func BidirectionalStream[Q any, R any](ctx context.Context, stream ServerStream, +func BidirectionalStream[Q any, R any]( + ctx context.Context, + stream ServerStream, concurrency int, f func(context.Context, *Q) (*R, error), ) (err error) { @@ -165,9 +167,8 @@ func BidirectionalStream[Q any, R any](ctx context.Context, stream ServerStream, } // BidirectionalStreamClient is gRPC client stream. -func BidirectionalStreamClient(stream ClientStream, - dataProvider, newData func() interface{}, - f func(interface{}, error), +func BidirectionalStreamClient( + stream ClientStream, dataProvider, newData func() any, f func(any, error), ) (err error) { if stream == nil { return errors.ErrGRPCClientStreamNotFound diff --git a/internal/net/grpc/stream_test.go b/internal/net/grpc/stream_test.go index dbe00b6130..858df7feb1 100644 --- a/internal/net/grpc/stream_test.go +++ b/internal/net/grpc/stream_test.go @@ -170,7 +170,7 @@ func TestBidirectionalStream(t *testing.T) { ContextFunc: func() context.Context { return ctx }, - RecvMsgFunc: func(i interface{}) error { + RecvMsgFunc: func(i any) error { if recvIdx >= len(insertReqs) { return io.EOF } @@ -184,7 +184,7 @@ func TestBidirectionalStream(t *testing.T) { return nil }, - SendMsgFunc: func(i interface{}) error { + SendMsgFunc: func(i any) error { rpcResp = append(rpcResp, i.(*payload.Object_StreamLocation)) return nil }, @@ -204,9 +204,9 @@ func TestBidirectionalStream(t *testing.T) { // func TestBidirectionalStreamClient(t *testing.T) { // type args struct { // stream ClientStream -// dataProvider func() interface{} -// newData func() interface{} -// f func(interface{}, error) +// dataProvider func() any +// newData func() any +// f func(any, error) // } // type want struct { // err error @@ -291,7 +291,6 @@ func TestBidirectionalStream(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/grpc/types/types.go b/internal/net/grpc/types/types.go index ad4332554b..9a523fa2f7 100644 --- a/internal/net/grpc/types/types.go +++ b/internal/net/grpc/types/types.go @@ -26,6 +26,6 @@ import ( type Any = anypb.Any // UnmarshalAny unmarshal protocol buffer message to any. -func UnmarshalAny(any *Any, m proto.Message) error { - return any.UnmarshalTo(m) +func UnmarshalAny(a *Any, m proto.Message) error { + return a.UnmarshalTo(m) } diff --git a/internal/net/http/dump/dump.go b/internal/net/http/dump/dump.go index 89d806e281..4e9734baad 100644 --- a/internal/net/http/dump/dump.go +++ b/internal/net/http/dump/dump.go @@ -23,22 +23,22 @@ import ( "github.com/vdaas/vald/internal/errors" ) -func Request(values, body map[string]interface{}, r *http.Request) (res interface{}, err error) { +func Request(values, body map[string]any, r *http.Request) (res any, err error) { if r == nil { return nil, errors.ErrInvalidRequest } return struct { - Host string `json:"host"` - URI string `json:"uri"` - URL string `json:"url"` - Method string `json:"method"` - Proto string `json:"proto"` - Header http.Header `json:"header"` - TransferEncoding []string `json:"transfer_encoding"` - RemoteAddr string `json:"remote_addr"` - ContentLength int64 `json:"content_length"` - Body map[string]interface{} `json:"body"` - Values map[string]interface{} `json:"values"` + Host string `json:"host"` + URI string `json:"uri"` + URL string `json:"url"` + Method string `json:"method"` + Proto string `json:"proto"` + Header http.Header `json:"header"` + TransferEncoding []string `json:"transfer_encoding"` + RemoteAddr string `json:"remote_addr"` + ContentLength int64 `json:"content_length"` + Body map[string]any `json:"body"` + Values map[string]any `json:"values"` }{ Host: r.Host, URI: r.RequestURI, diff --git a/internal/net/http/dump/dump_test.go b/internal/net/http/dump/dump_test.go index 40dd5539c2..4e535713e0 100644 --- a/internal/net/http/dump/dump_test.go +++ b/internal/net/http/dump/dump_test.go @@ -31,15 +31,15 @@ func TestMain(m *testing.M) { func TestRequest(t *testing.T) { t.Parallel() type args struct { - values map[string]interface{} - body map[string]interface{} + values map[string]any + body map[string]any r *http.Request } type test struct { name string args args - checkFunc func(res interface{}, err error) error + checkFunc func(res any, err error) error } tests := []test{ @@ -61,14 +61,14 @@ func TestRequest(t *testing.T) { RemoteAddr: "0.0.0.0", ContentLength: 1234, }, - body: map[string]interface{}{ + body: map[string]any{ "name": "vald", }, - values: map[string]interface{}{ + values: map[string]any{ "version": "1.0.0", }, }, - checkFunc: func(res interface{}, err error) error { + checkFunc: func(res any, err error) error { if err != nil { return errors.Errorf("err is not nil. err: %v", err) } @@ -88,7 +88,7 @@ func TestRequest(t *testing.T) { }, { name: "returns nil and error", - checkFunc: func(res interface{}, err error) error { + checkFunc: func(res any, err error) error { if got, want := err, errors.ErrInvalidRequest; !errors.Is(got, want) { return errors.Errorf("err not equals. want: %v, got: %v", want, got) } diff --git a/internal/net/http/json/json.go b/internal/net/http/json/json.go index aed11fa6cb..f93608be5e 100644 --- a/internal/net/http/json/json.go +++ b/internal/net/http/json/json.go @@ -32,18 +32,16 @@ import ( // RFC7807Error represents RFC 7807 error. type RFC7807Error struct { - Type string `json:"type"` - Title string `json:"title"` - Detail interface{} `json:"detail"` - Instance string `json:"instance"` - Status int `json:"status"` - Error string `json:"error"` + Type string `json:"type"` + Title string `json:"title"` + Detail any `json:"detail"` + Instance string `json:"instance"` + Status int `json:"status"` + Error string `json:"error"` } // EncodeResponse encodes http response body. -func EncodeResponse(w http.ResponseWriter, - data interface{}, status int, contentTypes ...string, -) error { +func EncodeResponse(w http.ResponseWriter, data any, status int, contentTypes ...string) error { for _, ct := range contentTypes { w.Header().Add(rest.ContentType, ct) } @@ -52,7 +50,7 @@ func EncodeResponse(w http.ResponseWriter, } // DecodeResponse decodes http response body. -func DecodeResponse(res *http.Response, data interface{}) (err error) { +func DecodeResponse(res *http.Response, data any) (err error) { if res != nil && res.Body != nil && data != nil && res.ContentLength != 0 { err = json.Decode(res.Body, data) if err != nil { @@ -73,9 +71,7 @@ func DecodeResponse(res *http.Response, data interface{}) (err error) { } // EncodeRequest encodes http request. -func EncodeRequest(req *http.Request, - data interface{}, contentTypes ...string, -) error { +func EncodeRequest(req *http.Request, data any, contentTypes ...string) error { for _, ct := range contentTypes { req.Header.Add(rest.ContentType, ct) } @@ -92,7 +88,7 @@ func EncodeRequest(req *http.Request, } // DecodeRequest decodes http request body. -func DecodeRequest(r *http.Request, data interface{}) (err error) { +func DecodeRequest(r *http.Request, data any) (err error) { if r != nil && r.Body != nil && r.ContentLength != 0 { err = json.Decode(r.Body, data) if err != nil { @@ -112,8 +108,8 @@ func DecodeRequest(r *http.Request, data interface{}) (err error) { } // Handler responds to an HTTP request to perform a logic function. -func Handler(w http.ResponseWriter, r *http.Request, - data interface{}, logic func() (interface{}, +func Handler( + w http.ResponseWriter, r *http.Request, data any, logic func() (any, error), ) (code int, err error) { err = DecodeRequest(r, &data) @@ -133,9 +129,7 @@ func Handler(w http.ResponseWriter, r *http.Request, } // ErrorHandler responds to an HTTP request to send RFC 7807 error. -func ErrorHandler(w http.ResponseWriter, r *http.Request, - msg string, code int, err error, -) error { +func ErrorHandler(w http.ResponseWriter, r *http.Request, msg string, code int, err error) error { data := RFC7807Error{ Type: r.RequestURI, Title: msg, @@ -146,7 +140,7 @@ func ErrorHandler(w http.ResponseWriter, r *http.Request, if err != nil { log.Error(err) } - body := make(map[string]interface{}) + body := make(map[string]any) err = json.Decode(r.Body, &body) if err != nil { log.Error(err) @@ -168,7 +162,7 @@ func ErrorHandler(w http.ResponseWriter, r *http.Request, } // Request sends http json request. -func Request(ctx context.Context, method, url string, payload, data interface{}) error { +func Request(ctx context.Context, method, url string, payload, data any) error { req, err := http.NewRequestWithContext(ctx, method, url, nil) if err != nil { return err diff --git a/internal/net/http/json/json_test.go b/internal/net/http/json/json_test.go index 221a7f64a6..a0f3dbef24 100644 --- a/internal/net/http/json/json_test.go +++ b/internal/net/http/json/json_test.go @@ -41,7 +41,7 @@ func TestEncodeResponse(t *testing.T) { t.Parallel() type args struct { w http.ResponseWriter - data interface{} + data any status int contentTypes []string } @@ -184,7 +184,7 @@ func TestHandler(t *testing.T) { w http.ResponseWriter r *http.Request data map[string]string - logic func() (interface{}, error) + logic func() (any, error) } type test struct { name string @@ -209,7 +209,7 @@ func TestHandler(t *testing.T) { r: r, w: w, data: data, - logic: func() (interface{}, error) { + logic: func() (any, error) { return "hello", nil }, }, @@ -267,7 +267,7 @@ func TestHandler(t *testing.T) { args: args{ r: r, data: make(map[string]string), - logic: func() (interface{}, error) { + logic: func() (any, error) { return nil, wantErr }, }, @@ -300,7 +300,7 @@ func TestHandler(t *testing.T) { }(), w: new(httptest.ResponseRecorder), data: make(map[string]string), - logic: func() (interface{}, error) { + logic: func() (any, error) { return func() {}, nil }, }, @@ -401,7 +401,7 @@ func TestDecodeResponse(t *testing.T) { t.Parallel() type args struct { res *http.Response - data interface{} + data any } type want struct { err error @@ -426,7 +426,7 @@ func TestDecodeResponse(t *testing.T) { name: "returns nil when response is nil", args: args{ res: nil, - data: new(interface{}), + data: new(any), }, want: want{ err: nil, @@ -440,7 +440,7 @@ func TestDecodeResponse(t *testing.T) { res: &http.Response{ Body: nil, }, - data: new(interface{}), + data: new(any), }, want: want{ err: nil, @@ -469,7 +469,7 @@ func TestDecodeResponse(t *testing.T) { Body: io.NopCloser(new(bytes.Buffer)), ContentLength: 0, }, - data: new(interface{}), + data: new(any), }, want: want{ err: nil, @@ -484,7 +484,7 @@ func TestDecodeResponse(t *testing.T) { Body: io.NopCloser(strings.NewReader("1+3i")), ContentLength: 2, }, - data: new(interface{}), + data: new(any), }, want: want{ err: &strconv.NumError{ @@ -551,7 +551,7 @@ func TestEncodeRequest(t *testing.T) { t.Parallel() type args struct { req *http.Request - data interface{} + data any contentTypes []string } type want struct { @@ -666,8 +666,8 @@ func TestRequest(t *testing.T) { ctx context.Context method string url string - payloyd interface{} - data interface{} + payloyd any + data any } type want struct { err error @@ -710,7 +710,7 @@ func TestRequest(t *testing.T) { method: "POST", url: "/", payloyd: 1 + 3i, - data: new(interface{}), + data: new(any), }, checkFunc: func(w want, err error) error { if w.err != nil && err != nil && !strings.HasPrefix(err.Error(), w.err.Error()) { @@ -731,7 +731,7 @@ func TestRequest(t *testing.T) { method: "POST", url: "/", payloyd: "1", - data: new(interface{}), + data: new(any), }, want: want{ err: &url.Error{ diff --git a/internal/net/http/metrics/pprof.go b/internal/net/http/metrics/pprof.go index d7d5c258ce..30a5dbe3d9 100644 --- a/internal/net/http/metrics/pprof.go +++ b/internal/net/http/metrics/pprof.go @@ -22,6 +22,7 @@ import ( "net/http/pprof" "github.com/felixge/fgprof" + pyprof "github.com/grafana/pyroscope-go/godeltaprof/http/pprof" "github.com/vdaas/vald/internal/net/http/rest" "github.com/vdaas/vald/internal/net/http/routing" ) @@ -116,6 +117,30 @@ func GetProfileRoutes() (r []routing.Route) { Pattern: "/debug/pprof/mutex", HandlerFunc: rest.HandlerToRestFunc(pprof.Handler("mutex").ServeHTTP), }, + { + Name: "Debug Heap delta profile", + Methods: []string{ + http.MethodGet, + }, + Pattern: "/debug/pprof/delta_heap", + HandlerFunc: rest.HandlerToRestFunc(pyprof.Heap), + }, + { + Name: "Debug mutex delta profile", + Methods: []string{ + http.MethodGet, + }, + Pattern: "/debug/pprof/delta_mutex", + HandlerFunc: rest.HandlerToRestFunc(pyprof.Mutex), + }, + { + Name: "Debug mutex profile", + Methods: []string{ + http.MethodGet, + }, + Pattern: "/debug/pprof/delta_block", + HandlerFunc: rest.HandlerToRestFunc(pyprof.Block), + }, { Name: "Debug fgprof profile", Methods: []string{ diff --git a/internal/net/http/metrics/pprof_test.go b/internal/net/http/metrics/pprof_test.go index 48a3657843..c0118ac8ed 100644 --- a/internal/net/http/metrics/pprof_test.go +++ b/internal/net/http/metrics/pprof_test.go @@ -40,3 +40,78 @@ func TestNewPProfHandler(t *testing.T) { } // NOT IMPLEMENTED BELOW +// +// func TestGetProfileRoutes(t *testing.T) { +// type want struct { +// wantR []routing.Route +// } +// type test struct { +// name string +// want want +// checkFunc func(want, []routing.Route) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, gotR []routing.Route) error { +// if !reflect.DeepEqual(gotR, w.wantR) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotR, w.wantR) +// } +// 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 +// } +// +// gotR := GetProfileRoutes() +// if err := checkFunc(test.want, gotR); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/net/http/rest/rest.go b/internal/net/http/rest/rest.go index 3508be7d0c..3ea905a2f4 100644 --- a/internal/net/http/rest/rest.go +++ b/internal/net/http/rest/rest.go @@ -17,9 +17,7 @@ // Package rest provides REST API common logic & variable package rest -import ( - "net/http" -) +import "net/http" type Func func(http.ResponseWriter, *http.Request) (code int, err error) diff --git a/internal/net/http/routing/router.go b/internal/net/http/routing/router.go index 4400571c76..b78109d901 100644 --- a/internal/net/http/routing/router.go +++ b/internal/net/http/routing/router.go @@ -60,9 +60,7 @@ func New(opts ...Option) http.Handler { // routing wraps the handler.Func and returns a new http.Handler. // routing helps to handle unsupported HTTP method, timeout, // and the error returned from the handler.Func. -func (*router) routing( - name, _ string, m []string, h rest.Func, -) http.Handler { +func (*router) routing(name, _ string, m []string, h rest.Func) http.Handler { return http.HandlerFunc( func(w http.ResponseWriter, r *http.Request) { var ( diff --git a/internal/net/http/routing/router_test.go b/internal/net/http/routing/router_test.go index 79dbb1b3d5..05595fe489 100644 --- a/internal/net/http/routing/router_test.go +++ b/internal/net/http/routing/router_test.go @@ -293,7 +293,6 @@ func TestRouting(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/net/http/transport/roundtrip.go b/internal/net/http/transport/roundtrip.go index 128c6231e6..9048bf9f76 100644 --- a/internal/net/http/transport/roundtrip.go +++ b/internal/net/http/transport/roundtrip.go @@ -54,7 +54,7 @@ func (e *ert) RoundTrip(req *http.Request) (res *http.Response, err error) { if e.bo == nil { return e.doRoundTrip(req) } - _, err = e.bo.Do(req.Context(), func(ctx context.Context) (interface{}, bool, error) { + _, err = e.bo.Do(req.Context(), func(ctx context.Context) (any, bool, error) { r, err := e.doRoundTrip(req) if err != nil { return nil, errors.Is(err, errors.ErrTransportRetryable), err diff --git a/internal/net/http/transport/roundtrip_mock.go b/internal/net/http/transport/roundtrip_mock.go index f3a0549efb..82b49bfe2b 100644 --- a/internal/net/http/transport/roundtrip_mock.go +++ b/internal/net/http/transport/roundtrip_mock.go @@ -27,11 +27,13 @@ func (rm *roundTripMock) RoundTrip(req *http.Request) (*http.Response, error) { } type backoffMock struct { - DoFunc func(context.Context, func(context.Context) (interface{}, bool, error)) (interface{}, error) + DoFunc func(context.Context, func(context.Context) (any, bool, error)) (any, error) CloseFunc func() } -func (bm *backoffMock) Do(ctx context.Context, fn func(context.Context) (interface{}, bool, error)) (interface{}, error) { +func (bm *backoffMock) Do( + ctx context.Context, fn func(context.Context) (any, bool, error), +) (any, error) { return bm.DoFunc(ctx, fn) } diff --git a/internal/net/http/transport/roundtrip_test.go b/internal/net/http/transport/roundtrip_test.go index f295d50f64..0af9f6a5f3 100644 --- a/internal/net/http/transport/roundtrip_test.go +++ b/internal/net/http/transport/roundtrip_test.go @@ -178,7 +178,7 @@ func Test_ert_RoundTrip(t *testing.T) { }, }, bo: &backoffMock{ - DoFunc: func(ctx context.Context, fn func(context.Context) (interface{}, bool, error)) (interface{}, error) { + DoFunc: func(ctx context.Context, fn func(context.Context) (any, bool, error)) (any, error) { val, _, err := fn(ctx) return val, err }, @@ -204,7 +204,7 @@ func Test_ert_RoundTrip(t *testing.T) { }, }, bo: &backoffMock{ - DoFunc: func(ctx context.Context, fn func(context.Context) (interface{}, bool, error)) (interface{}, error) { + DoFunc: func(ctx context.Context, fn func(context.Context) (any, bool, error)) (any, error) { val, _, err := fn(ctx) return val, err }, @@ -230,7 +230,7 @@ func Test_ert_RoundTrip(t *testing.T) { }, }, bo: &backoffMock{ - DoFunc: func(ctx context.Context, fn func(context.Context) (interface{}, bool, error)) (interface{}, error) { + DoFunc: func(ctx context.Context, fn func(context.Context) (any, bool, error)) (any, error) { val, _, err := fn(ctx) return val, err }, @@ -249,7 +249,7 @@ func Test_ert_RoundTrip(t *testing.T) { }, fields: fields{ bo: &backoffMock{ - DoFunc: func(ctx context.Context, fn func(context.Context) (interface{}, bool, error)) (interface{}, error) { + DoFunc: func(ctx context.Context, fn func(context.Context) (any, bool, error)) (any, error) { return nil, errors.New("error") }, }, @@ -270,7 +270,7 @@ func Test_ert_RoundTrip(t *testing.T) { }, }, bo: &backoffMock{ - DoFunc: func(ctx context.Context, fn func(context.Context) (interface{}, bool, error)) (interface{}, error) { + DoFunc: func(ctx context.Context, fn func(context.Context) (any, bool, error)) (any, error) { val, _, err := fn(ctx) return val, err }, @@ -292,7 +292,7 @@ func Test_ert_RoundTrip(t *testing.T) { }, }, bo: &backoffMock{ - DoFunc: func(ctx context.Context, fn func(context.Context) (interface{}, bool, error)) (interface{}, error) { + DoFunc: func(ctx context.Context, fn func(context.Context) (any, bool, error)) (any, error) { val, _, err := fn(ctx) return val, err }, diff --git a/internal/net/option_test.go b/internal/net/option_test.go index 56e42afd5c..dceb8e08aa 100644 --- a/internal/net/option_test.go +++ b/internal/net/option_test.go @@ -816,7 +816,6 @@ func TestWithDisableDialerDualStack(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -902,7 +901,6 @@ func TestWithDisableDialerDualStack(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/attribute/attribute_test.go b/internal/observability/attribute/attribute_test.go index 36c1d860f6..7fed490af4 100644 --- a/internal/observability/attribute/attribute_test.go +++ b/internal/observability/attribute/attribute_test.go @@ -99,7 +99,6 @@ package attribute // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -188,7 +187,6 @@ package attribute // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -277,7 +275,6 @@ package attribute // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -366,7 +363,6 @@ package attribute // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/exporter/otlp/option_test.go b/internal/observability/exporter/otlp/option_test.go index 0d88b869f1..34f8a0f77d 100644 --- a/internal/observability/exporter/otlp/option_test.go +++ b/internal/observability/exporter/otlp/option_test.go @@ -96,7 +96,6 @@ package otlp // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package otlp // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package otlp // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package otlp // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -440,7 +436,6 @@ package otlp // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +521,6 @@ package otlp // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -612,7 +606,6 @@ package otlp // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -698,7 +691,6 @@ package otlp // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/exporter/otlp/otlp_test.go b/internal/observability/exporter/otlp/otlp_test.go index 1f82c9db51..49ff3276b9 100644 --- a/internal/observability/exporter/otlp/otlp_test.go +++ b/internal/observability/exporter/otlp/otlp_test.go @@ -100,7 +100,6 @@ package otlp // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -251,7 +250,6 @@ package otlp // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -402,7 +400,6 @@ package otlp // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -553,7 +550,6 @@ package otlp // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -704,7 +700,6 @@ package otlp // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/agent/core/faiss/faiss_test.go b/internal/observability/metrics/agent/core/faiss/faiss_test.go new file mode 100644 index 0000000000..49d4dc8fb7 --- /dev/null +++ b/internal/observability/metrics/agent/core/faiss/faiss_test.go @@ -0,0 +1,291 @@ +// 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 faiss + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// f service.Faiss +// } +// type want struct { +// want metrics.Metric +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, metrics.Metric) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got metrics.Metric) 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 { +// f: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 { +// f: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 := New(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faissMetrics_View(t *testing.T) { +// type fields struct { +// faiss service.Faiss +// } +// type want struct { +// want []metrics.View +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, []metrics.View, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got []metrics.View, 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 { +// faiss: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 { +// faiss: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 +// } +// f := &faissMetrics{ +// faiss: test.fields.faiss, +// } +// +// got, err := f.View() +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faissMetrics_Register(t *testing.T) { +// type args struct { +// m metrics.Meter +// } +// type fields struct { +// faiss service.Faiss +// } +// 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 { +// m:nil, +// }, +// fields: fields { +// faiss: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 { +// m:nil, +// }, +// fields: fields { +// faiss: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 +// } +// f := &faissMetrics{ +// faiss: test.fields.faiss, +// } +// +// err := f.Register(test.args.m) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/observability/metrics/agent/core/ngt/ngt.go b/internal/observability/metrics/agent/core/ngt/ngt.go index 1d3e5153a9..dd6c8f328f 100644 --- a/internal/observability/metrics/agent/core/ngt/ngt.go +++ b/internal/observability/metrics/agent/core/ngt/ngt.go @@ -16,6 +16,7 @@ package ngt import ( "context" + "github.com/vdaas/vald/internal/observability/attribute" "github.com/vdaas/vald/internal/observability/metrics" "github.com/vdaas/vald/pkg/agent/core/ngt/service" api "go.opentelemetry.io/otel/metric" @@ -49,6 +50,102 @@ const ( brokenIndexStoreCountMetricsName = "agent_core_ngt_broken_index_store_count" brokenIndexStoreCountMetricsDescription = "How many broken index generations have been stored" + + medianIndegreeMetricsName = "agent_core_ngt_median_indegree" + medianIndegreeMetricsDescription = "Median indegree of nodes" + + medianOutdegreeMetricsName = "agent_core_ngt_median_outdegree" + medianOutdegreeMetricsDescription = "Median outdegree of nodes" + + maxNumberOfIndegreeMetricsName = "agent_core_ngt_max_number_of_indegree" + maxNumberOfIndegreeMetricsDescription = "Maximum number of indegree" + + maxNumberOfOutdegreeMetricsName = "agent_core_ngt_max_number_of_outdegree" + maxNumberOfOutdegreeMetricsDescription = "Maximum number of outdegree" + + minNumberOfIndegreeMetricsName = "agent_core_ngt_min_number_of_indegree" + minNumberOfIndegreeMetricsDescription = "Minimum number of indegree" + + minNumberOfOutdegreeMetricsName = "agent_core_ngt_min_number_of_outdegree" + minNumberOfOutdegreeMetricsDescription = "Minimum number of outdegree" + + modeIndegreeMetricsName = "agent_core_ngt_mode_indegree" + modeIndegreeMetricsDescription = "Mode of indegree" + + modeOutdegreeMetricsName = "agent_core_ngt_mode_outdegree" + modeOutdegreeMetricsDescription = "Mode of outdegree" + + nodesSkippedFor10EdgesMetricsName = "agent_core_ngt_nodes_skipped_for_10_edges" + nodesSkippedFor10EdgesMetricsDescription = "Nodes skipped for 10 edges" + + nodesSkippedForIndegreeDistanceMetricsName = "agent_core_ngt_nodes_skipped_for_indegree_distance" + nodesSkippedForIndegreeDistanceMetricsDescription = "Nodes skipped for indegree distance" + + numberOfEdgesMetricsName = "agent_core_ngt_number_of_edges" + numberOfEdgesMetricsDescription = "Number of edges" + + numberOfIndexedObjectsMetricsName = "agent_core_ngt_number_of_indexed_objects" + numberOfIndexedObjectsMetricsDescription = "Number of indexed objects" + + numberOfNodesMetricsName = "agent_core_ngt_number_of_nodes" + numberOfNodesMetricsDescription = "Number of nodes" + + numberOfNodesWithoutEdgesMetricsName = "agent_core_ngt_number_of_nodes_without_edges" + numberOfNodesWithoutEdgesMetricsDescription = "Number of nodes without edges" + + numberOfNodesWithoutIndegreeMetricsName = "agent_core_ngt_number_of_nodes_without_indegree" + numberOfNodesWithoutIndegreeMetricsDescription = "Number of nodes without indegree" + + numberOfObjectsMetricsName = "agent_core_ngt_number_of_objects" + numberOfObjectsMetricsDescription = "Number of objects" + + numberOfRemovedObjectsMetricsName = "agent_core_ngt_number_of_removed_objects" + numberOfRemovedObjectsMetricsDescription = "Number of removed objects" + + sizeOfObjectRepositoryMetricsName = "agent_core_ngt_size_of_object_repository" + sizeOfObjectRepositoryMetricsDescription = "Size of object repository" + + sizeOfRefinementObjectRepositoryMetricsName = "agent_core_ngt_size_of_refinement_object_repository" + sizeOfRefinementObjectRepositoryMetricsDescription = "Size of refinement object repository" + + varianceOfIndegreeMetricsName = "agent_core_ngt_variance_of_indegree" + varianceOfIndegreeMetricsDescription = "Variance of indegree" + + varianceOfOutdegreeMetricsName = "agent_core_ngt_variance_of_outdegree" + varianceOfOutdegreeMetricsDescription = "Variance of outdegree" + + meanEdgeLengthMetricsName = "agent_core_ngt_mean_edge_length" + meanEdgeLengthMetricsDescription = "Mean edge length" + + meanEdgeLengthFor10EdgesMetricsName = "agent_core_ngt_mean_edge_length_for_10_edges" + meanEdgeLengthFor10EdgesMetricsDescription = "Mean edge length for 10 edges" + + meanIndegreeDistanceFor10EdgesMetricsName = "agent_core_ngt_mean_indegree_distance_for_10_edges" + meanIndegreeDistanceFor10EdgesMetricsDescription = "Mean indegree distance for 10 edges" + + meanNumberOfEdgesPerNodeMetricsName = "agent_core_ngt_mean_number_of_edges_per_node" + meanNumberOfEdgesPerNodeMetricsDescription = "Mean number of edges per node" + + c1IndegreeMetricsName = "agent_core_ngt_c1_indegree" + c1IndegreeMetricsDescription = "C1 indegree" + + c5IndegreeMetricsName = "agent_core_ngt_c5_indegree" + c5IndegreeMetricsDescription = "C5 indegree" + + c95OutdegreeMetricsName = "agent_core_ngt_c95_outdegree" + c95OutdegreeMetricsDescription = "C95 outdegree" + + c99OutdegreeMetricsName = "agent_core_ngt_c99_outdegree" + c99OutdegreeMetricsDescription = "C99 outdegree" + + indegreeCountMetricsName = "agent_core_ngt_indegree_count" + indegreeCountMetricsDescription = "Indegree count" + + outdegreeHistogramMetricsName = "agent_core_ngt_outdegree_histogram" + outdegreeHistogramMetricsDescription = "Outdegree histogram" + + indegreeHistogramMetricsName = "agent_core_ngt_indegree_histogram" + indegreeHistogramMetricsDescription = "Indegree histogram" ) type ngtMetrics struct { @@ -61,8 +158,8 @@ func New(n service.NGT) metrics.Metric { } } -func (n *ngtMetrics) View() ([]metrics.View, error) { - return []metrics.View{ +func (n *ngtMetrics) View() (mv []metrics.View, err error) { + mv = []metrics.View{ view.NewView( view.Instrument{ Name: indexCountMetricsName, @@ -144,11 +241,314 @@ func (n *ngtMetrics) View() ([]metrics.View, error) { Aggregation: view.AggregationLastValue{}, }, ), - }, nil + } + + if n.ngt.IsStatisticsEnabled() { + mv = append(mv, + view.NewView( + view.Instrument{ + Name: medianIndegreeMetricsName, + Description: medianIndegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: medianOutdegreeMetricsName, + Description: medianOutdegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: maxNumberOfIndegreeMetricsName, + Description: maxNumberOfIndegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: maxNumberOfOutdegreeMetricsName, + Description: maxNumberOfOutdegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: minNumberOfIndegreeMetricsName, + Description: minNumberOfIndegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: minNumberOfOutdegreeMetricsName, + Description: minNumberOfOutdegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: modeIndegreeMetricsName, + Description: modeIndegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: modeOutdegreeMetricsName, + Description: modeOutdegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: nodesSkippedFor10EdgesMetricsName, + Description: nodesSkippedFor10EdgesMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: nodesSkippedForIndegreeDistanceMetricsName, + Description: nodesSkippedForIndegreeDistanceMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: numberOfEdgesMetricsName, + Description: numberOfEdgesMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: numberOfIndexedObjectsMetricsName, + Description: numberOfIndexedObjectsMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: numberOfNodesMetricsName, + Description: numberOfNodesMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: numberOfNodesWithoutEdgesMetricsName, + Description: numberOfNodesWithoutEdgesMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: numberOfNodesWithoutIndegreeMetricsName, + Description: numberOfNodesWithoutIndegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: numberOfObjectsMetricsName, + Description: numberOfObjectsMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: numberOfRemovedObjectsMetricsName, + Description: numberOfRemovedObjectsMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: sizeOfObjectRepositoryMetricsName, + Description: sizeOfObjectRepositoryMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: sizeOfRefinementObjectRepositoryMetricsName, + Description: sizeOfRefinementObjectRepositoryMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: varianceOfIndegreeMetricsName, + Description: varianceOfIndegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: varianceOfOutdegreeMetricsName, + Description: varianceOfOutdegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: meanEdgeLengthMetricsName, + Description: meanEdgeLengthMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: meanEdgeLengthFor10EdgesMetricsName, + Description: meanEdgeLengthFor10EdgesMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: meanIndegreeDistanceFor10EdgesMetricsName, + Description: meanIndegreeDistanceFor10EdgesMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: meanNumberOfEdgesPerNodeMetricsName, + Description: meanNumberOfEdgesPerNodeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: c1IndegreeMetricsName, + Description: c1IndegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: c5IndegreeMetricsName, + Description: c5IndegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: c95OutdegreeMetricsName, + Description: c95OutdegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: c99OutdegreeMetricsName, + Description: c99OutdegreeMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: indegreeCountMetricsName, + Description: indegreeCountMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: outdegreeHistogramMetricsName, + Description: outdegreeHistogramMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: indegreeHistogramMetricsName, + Description: indegreeHistogramMetricsDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + )) + } + return mv, nil } -func (n *ngtMetrics) Register(m metrics.Meter) error { - indexCount, err := m.Int64ObservableGauge( +func (n *ngtMetrics) Register(m metrics.Meter) (err error) { + var indexCount, + uncommittedIndexCount, + insertVQueueCount, + deleteVQueueCount, + completedCreateIndexTotal, + executedProactiveGCTotal, + isIndexing, + isSaving, + brokenIndexCount metrics.Int64ObservableGauge + + indexCount, err = m.Int64ObservableGauge( indexCountMetricsName, metrics.WithDescription(indexCountMetricsDescription), metrics.WithUnit(metrics.Dimensionless), @@ -157,7 +557,7 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { return err } - uncommittedIndexCount, err := m.Int64ObservableGauge( + uncommittedIndexCount, err = m.Int64ObservableGauge( uncommittedIndexCountMetricsName, metrics.WithDescription(uncommittedIndexCountMetricsDescription), metrics.WithUnit(metrics.Dimensionless), @@ -166,7 +566,7 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { return err } - insertVQueueCount, err := m.Int64ObservableGauge( + insertVQueueCount, err = m.Int64ObservableGauge( insertVQueueCountMetricsName, metrics.WithDescription(insertVQueueCountMetricsDescription), metrics.WithUnit(metrics.Dimensionless), @@ -175,7 +575,7 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { return err } - deleteVQueueCount, err := m.Int64ObservableGauge( + deleteVQueueCount, err = m.Int64ObservableGauge( deleteVQueueCountMetricsName, metrics.WithDescription(deleteVQueueCountMetricsDescription), metrics.WithUnit(metrics.Dimensionless), @@ -184,7 +584,7 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { return err } - completedCreateIndexTotal, err := m.Int64ObservableGauge( + completedCreateIndexTotal, err = m.Int64ObservableGauge( completedCreateIndexTotalMetricsName, metrics.WithDescription(completedCreateIndexTotalMetricsDescription), metrics.WithUnit(metrics.Dimensionless), @@ -193,7 +593,7 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { return err } - executedProactiveGCTotal, err := m.Int64ObservableGauge( + executedProactiveGCTotal, err = m.Int64ObservableGauge( executedProactiveGCTotalMetricsName, metrics.WithDescription(executedProactiveGCTotalMetricsDescription), metrics.WithUnit(metrics.Dimensionless), @@ -202,7 +602,7 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { return err } - isIndexing, err := m.Int64ObservableGauge( + isIndexing, err = m.Int64ObservableGauge( isIndexingMetricsName, metrics.WithDescription(isIndexingMetricsDescription), metrics.WithUnit(metrics.Dimensionless), @@ -211,7 +611,7 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { return err } - isSaving, err := m.Int64ObservableGauge( + isSaving, err = m.Int64ObservableGauge( isSavingMetricsName, metrics.WithDescription(isSavingMetricsDescription), metrics.WithUnit(metrics.Dimensionless), @@ -220,7 +620,7 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { return err } - brokenIndexCount, err := m.Int64ObservableGauge( + brokenIndexCount, err = m.Int64ObservableGauge( brokenIndexStoreCountMetricsName, metrics.WithDescription(brokenIndexStoreCountMetricsDescription), metrics.WithUnit(metrics.Dimensionless), @@ -229,6 +629,378 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { return err } + instruments := []api.Observable{ + indexCount, + uncommittedIndexCount, + insertVQueueCount, + deleteVQueueCount, + completedCreateIndexTotal, + executedProactiveGCTotal, + isIndexing, + isSaving, + brokenIndexCount, + } + var ( + medianIndegree, + medianOutdegree, + maxNumberOfIndegree, + maxNumberOfOutdegree, + minNumberOfIndegree, + minNumberOfOutdegree, + modeIndegree, + modeOutdegree, + nodesSkippedFor10Edges, + nodesSkippedForIndegreeDistance, + numberOfEdges, + numberOfIndexedObjects, + numberOfNodes, + numberOfNodesWithoutEdges, + numberOfNodesWithoutIndegree, + numberOfObjects, + numberOfRemovedObjects, + sizeOfObjectRepository, + sizeOfRefinementObjectRepository metrics.Int64ObservableGauge + + varianceOfIndegree, + varianceOfOutdegree, + meanEdgeLength, + meanEdgeLengthFor10Edges, + meanIndegreeDistanceFor10Edges, + meanNumberOfEdgesPerNode, + c1Indegree, + c5Indegree, + c95Outdegree, + c99Outdegree, + indegreeCount, + outdegreeHistogram, + indegreeHistogram metrics.Float64ObservableGauge + ) + + if n.ngt.IsStatisticsEnabled() { + medianIndegree, err = m.Int64ObservableGauge( + medianIndegreeMetricsName, + metrics.WithDescription(medianIndegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + medianOutdegree, err = m.Int64ObservableGauge( + medianOutdegreeMetricsName, + metrics.WithDescription(medianOutdegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + maxNumberOfIndegree, err = m.Int64ObservableGauge( + maxNumberOfIndegreeMetricsName, + metrics.WithDescription(maxNumberOfIndegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + maxNumberOfOutdegree, err = m.Int64ObservableGauge( + maxNumberOfOutdegreeMetricsName, + metrics.WithDescription(maxNumberOfOutdegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + minNumberOfIndegree, err = m.Int64ObservableGauge( + minNumberOfIndegreeMetricsName, + metrics.WithDescription(minNumberOfIndegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + minNumberOfOutdegree, err = m.Int64ObservableGauge( + minNumberOfOutdegreeMetricsName, + metrics.WithDescription(minNumberOfOutdegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + modeIndegree, err = m.Int64ObservableGauge( + modeIndegreeMetricsName, + metrics.WithDescription(modeIndegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + modeOutdegree, err = m.Int64ObservableGauge( + modeOutdegreeMetricsName, + metrics.WithDescription(modeOutdegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + nodesSkippedFor10Edges, err = m.Int64ObservableGauge( + nodesSkippedFor10EdgesMetricsName, + metrics.WithDescription(nodesSkippedFor10EdgesMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + nodesSkippedForIndegreeDistance, err = m.Int64ObservableGauge( + nodesSkippedForIndegreeDistanceMetricsName, + metrics.WithDescription(nodesSkippedForIndegreeDistanceMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + numberOfEdges, err = m.Int64ObservableGauge( + numberOfEdgesMetricsName, + metrics.WithDescription(numberOfEdgesMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + numberOfIndexedObjects, err = m.Int64ObservableGauge( + numberOfIndexedObjectsMetricsName, + metrics.WithDescription(numberOfIndexedObjectsMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + numberOfNodes, err = m.Int64ObservableGauge( + numberOfNodesMetricsName, + metrics.WithDescription(numberOfNodesMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + numberOfNodesWithoutEdges, err = m.Int64ObservableGauge( + numberOfNodesWithoutEdgesMetricsName, + metrics.WithDescription(numberOfNodesWithoutEdgesMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + numberOfNodesWithoutIndegree, err = m.Int64ObservableGauge( + numberOfNodesWithoutIndegreeMetricsName, + metrics.WithDescription(numberOfNodesWithoutIndegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + numberOfObjects, err = m.Int64ObservableGauge( + numberOfObjectsMetricsName, + metrics.WithDescription(numberOfObjectsMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + numberOfRemovedObjects, err = m.Int64ObservableGauge( + numberOfRemovedObjectsMetricsName, + metrics.WithDescription(numberOfRemovedObjectsMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + sizeOfObjectRepository, err = m.Int64ObservableGauge( + sizeOfObjectRepositoryMetricsName, + metrics.WithDescription(sizeOfObjectRepositoryMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + sizeOfRefinementObjectRepository, err = m.Int64ObservableGauge( + sizeOfRefinementObjectRepositoryMetricsName, + metrics.WithDescription(sizeOfRefinementObjectRepositoryMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + varianceOfIndegree, err = m.Float64ObservableGauge( + varianceOfIndegreeMetricsName, + metrics.WithDescription(varianceOfIndegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + varianceOfOutdegree, err = m.Float64ObservableGauge( + varianceOfOutdegreeMetricsName, + metrics.WithDescription(varianceOfOutdegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + meanEdgeLength, err = m.Float64ObservableGauge( + meanEdgeLengthMetricsName, + metrics.WithDescription(meanEdgeLengthMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + meanEdgeLengthFor10Edges, err = m.Float64ObservableGauge( + meanEdgeLengthFor10EdgesMetricsName, + metrics.WithDescription(meanEdgeLengthFor10EdgesMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + meanIndegreeDistanceFor10Edges, err = m.Float64ObservableGauge( + meanIndegreeDistanceFor10EdgesMetricsName, + metrics.WithDescription(meanIndegreeDistanceFor10EdgesMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + meanNumberOfEdgesPerNode, err = m.Float64ObservableGauge( + meanNumberOfEdgesPerNodeMetricsName, + metrics.WithDescription(meanNumberOfEdgesPerNodeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + c1Indegree, err = m.Float64ObservableGauge( + c1IndegreeMetricsName, + metrics.WithDescription(c1IndegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + c5Indegree, err = m.Float64ObservableGauge( + c5IndegreeMetricsName, + metrics.WithDescription(c5IndegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + c95Outdegree, err = m.Float64ObservableGauge( + c95OutdegreeMetricsName, + metrics.WithDescription(c95OutdegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + c99Outdegree, err = m.Float64ObservableGauge( + c99OutdegreeMetricsName, + metrics.WithDescription(c99OutdegreeMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + indegreeCount, err = m.Float64ObservableGauge( + indegreeCountMetricsName, + metrics.WithDescription(indegreeCountMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + outdegreeHistogram, err = m.Float64ObservableGauge( + outdegreeHistogramMetricsName, + metrics.WithDescription(outdegreeHistogramMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + indegreeHistogram, err = m.Float64ObservableGauge( + indegreeHistogramMetricsName, + metrics.WithDescription(indegreeHistogramMetricsDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + + instruments = append(instruments, + medianIndegree, + medianOutdegree, + maxNumberOfIndegree, + maxNumberOfOutdegree, + minNumberOfIndegree, + minNumberOfOutdegree, + modeIndegree, + modeOutdegree, + nodesSkippedFor10Edges, + nodesSkippedForIndegreeDistance, + numberOfEdges, + numberOfIndexedObjects, + numberOfNodes, + numberOfNodesWithoutEdges, + numberOfNodesWithoutIndegree, + numberOfObjects, + numberOfRemovedObjects, + sizeOfObjectRepository, + sizeOfRefinementObjectRepository, + varianceOfIndegree, + varianceOfOutdegree, + meanEdgeLength, + meanEdgeLengthFor10Edges, + meanIndegreeDistanceFor10Edges, + meanNumberOfEdgesPerNode, + c1Indegree, + c5Indegree, + c95Outdegree, + c99Outdegree, + indegreeCount, + outdegreeHistogram, + indegreeHistogram, + ) + } + _, err = m.RegisterCallback( func(_ context.Context, o api.Observer) error { var indexing int64 @@ -248,17 +1020,66 @@ func (n *ngtMetrics) Register(m metrics.Meter) error { o.ObserveInt64(isIndexing, int64(indexing)) o.ObserveInt64(isSaving, int64(saving)) o.ObserveInt64(brokenIndexCount, int64(n.ngt.BrokenIndexCount())) + + if n.ngt.IsStatisticsEnabled() { + stats, err := n.ngt.IndexStatistics() + if err == nil { + o.ObserveInt64(medianIndegree, int64(stats.GetMedianIndegree())) + o.ObserveInt64(medianOutdegree, int64(stats.GetMedianOutdegree())) + o.ObserveInt64(maxNumberOfIndegree, int64(stats.GetMaxNumberOfIndegree())) + o.ObserveInt64(maxNumberOfOutdegree, int64(stats.GetMaxNumberOfOutdegree())) + o.ObserveInt64(minNumberOfIndegree, int64(stats.GetMinNumberOfIndegree())) + o.ObserveInt64(minNumberOfOutdegree, int64(stats.GetMinNumberOfOutdegree())) + o.ObserveInt64(modeIndegree, int64(stats.GetModeIndegree())) + o.ObserveInt64(modeOutdegree, int64(stats.GetModeOutdegree())) + o.ObserveInt64(nodesSkippedFor10Edges, int64(stats.GetNodesSkippedFor10Edges())) + o.ObserveInt64(nodesSkippedForIndegreeDistance, int64(stats.GetNodesSkippedForIndegreeDistance())) + o.ObserveInt64(numberOfEdges, int64(stats.GetNumberOfEdges())) + o.ObserveInt64(numberOfIndexedObjects, int64(stats.GetNumberOfIndexedObjects())) + o.ObserveInt64(numberOfNodes, int64(stats.GetNumberOfNodes())) + o.ObserveInt64(numberOfNodesWithoutEdges, int64(stats.GetNumberOfNodesWithoutEdges())) + o.ObserveInt64(numberOfNodesWithoutIndegree, int64(stats.GetNumberOfNodesWithoutIndegree())) + o.ObserveInt64(numberOfObjects, int64(stats.GetNumberOfObjects())) + o.ObserveInt64(numberOfRemovedObjects, int64(stats.GetNumberOfRemovedObjects())) + o.ObserveInt64(sizeOfObjectRepository, int64(stats.GetSizeOfObjectRepository())) + o.ObserveInt64(sizeOfRefinementObjectRepository, int64(stats.GetSizeOfRefinementObjectRepository())) + o.ObserveFloat64(varianceOfIndegree, stats.GetVarianceOfIndegree()) + o.ObserveFloat64(varianceOfOutdegree, stats.GetVarianceOfOutdegree()) + o.ObserveFloat64(meanEdgeLength, stats.GetMeanEdgeLength()) + o.ObserveFloat64(meanEdgeLengthFor10Edges, stats.GetMeanEdgeLengthFor10Edges()) + o.ObserveFloat64(meanIndegreeDistanceFor10Edges, stats.GetMeanIndegreeDistanceFor10Edges()) + o.ObserveFloat64(meanNumberOfEdgesPerNode, stats.GetMeanNumberOfEdgesPerNode()) + o.ObserveFloat64(c1Indegree, stats.GetC1Indegree()) + o.ObserveFloat64(c5Indegree, stats.GetC5Indegree()) + o.ObserveFloat64(c95Outdegree, stats.GetC95Outdegree()) + o.ObserveFloat64(c99Outdegree, stats.GetC99Outdegree()) + // Calculate and observe the average of indegree count + indegreeCounts := stats.GetIndegreeCount() + if len(indegreeCounts) > 0 { + totalIndegreeCount := int64(0) + for _, count := range indegreeCounts { + totalIndegreeCount += count + } + avgIndegreeCount := float64(totalIndegreeCount) / float64(len(indegreeCounts)) + o.ObserveFloat64(indegreeCount, avgIndegreeCount) + } + + // Calculate and observe outdegree histogram + outdegreeHist := stats.GetOutdegreeHistogram() + for i, count := range outdegreeHist { + o.ObserveFloat64(outdegreeHistogram, float64(count), api.WithAttributes(attribute.Int64("outdegree", int64(i)))) + } + + // Calculate and observe indegree histogram + indegreeHist := stats.GetIndegreeHistogram() + for i, count := range indegreeHist { + o.ObserveFloat64(indegreeHistogram, float64(count), api.WithAttributes(attribute.Int64("indegree", int64(i)))) + } + } + } return nil }, - indexCount, - uncommittedIndexCount, - insertVQueueCount, - deleteVQueueCount, - completedCreateIndexTotal, - executedProactiveGCTotal, - isIndexing, - isSaving, - brokenIndexCount, + instruments..., ) return err } diff --git a/internal/observability/metrics/agent/core/ngt/ngt_test.go b/internal/observability/metrics/agent/core/ngt/ngt_test.go index 63eafa8f2d..ccf117e40e 100644 --- a/internal/observability/metrics/agent/core/ngt/ngt_test.go +++ b/internal/observability/metrics/agent/core/ngt/ngt_test.go @@ -96,7 +96,6 @@ package ngt // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -106,23 +105,23 @@ package ngt // ngt service.NGT // } // type want struct { -// want []*metrics.View -// err error +// wantMv []metrics.View +// err error // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, gotMv []metrics.View, 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) +// if !reflect.DeepEqual(gotMv, w.wantMv) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotMv, w.wantMv) // } // return nil // } @@ -185,11 +184,10 @@ package ngt // ngt: test.fields.ngt, // } // -// got, err := n.View() -// if err := checkFunc(test.want, got, err); err != nil { +// gotMv, err := n.View() +// if err := checkFunc(test.want, gotMv, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -288,7 +286,6 @@ package ngt // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/agent/sidecar/sidecar.go b/internal/observability/metrics/agent/sidecar/sidecar.go index d87f2f98c9..5185980eef 100644 --- a/internal/observability/metrics/agent/sidecar/sidecar.go +++ b/internal/observability/metrics/agent/sidecar/sidecar.go @@ -148,7 +148,9 @@ func (sm *sidecarMetrics) Register(m metrics.Meter) error { return err } -func (*sidecarMetrics) BeforeProcess(ctx context.Context, _ *observer.BackupInfo) (context.Context, error) { +func (*sidecarMetrics) BeforeProcess( + ctx context.Context, _ *observer.BackupInfo, +) (context.Context, error) { return ctx, nil } diff --git a/internal/observability/metrics/agent/sidecar/sidecar_test.go b/internal/observability/metrics/agent/sidecar/sidecar_test.go index eda8de0508..b68611efda 100644 --- a/internal/observability/metrics/agent/sidecar/sidecar_test.go +++ b/internal/observability/metrics/agent/sidecar/sidecar_test.go @@ -86,7 +86,6 @@ package sidecar // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -99,18 +98,18 @@ package sidecar // info *observer.BackupInfo // } // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -191,7 +190,6 @@ package sidecar // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -302,7 +300,6 @@ package sidecar // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -420,7 +417,6 @@ package sidecar // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -534,7 +530,6 @@ package sidecar // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/backoff/backoff_test.go b/internal/observability/metrics/backoff/backoff_test.go index ea452678ed..11242b222f 100644 --- a/internal/observability/metrics/backoff/backoff_test.go +++ b/internal/observability/metrics/backoff/backoff_test.go @@ -86,7 +86,6 @@ package backoff // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -96,18 +95,18 @@ package backoff // backoffNameKey string // } // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -179,7 +178,6 @@ package backoff // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -278,7 +276,6 @@ package backoff // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/circuitbreaker/circuitbreaker_test.go b/internal/observability/metrics/circuitbreaker/circuitbreaker_test.go index cc9b4322d4..37efe97660 100644 --- a/internal/observability/metrics/circuitbreaker/circuitbreaker_test.go +++ b/internal/observability/metrics/circuitbreaker/circuitbreaker_test.go @@ -86,7 +86,6 @@ package circuitbreaker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -97,18 +96,18 @@ package circuitbreaker // stateKey string // } // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -183,7 +182,6 @@ package circuitbreaker // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -286,7 +284,6 @@ package circuitbreaker // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/gateway/mirror/mirror_test.go b/internal/observability/metrics/gateway/mirror/mirror_test.go new file mode 100644 index 0000000000..085094f7e7 --- /dev/null +++ b/internal/observability/metrics/gateway/mirror/mirror_test.go @@ -0,0 +1,291 @@ +// 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 mirror + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// m service.Mirror +// } +// type want struct { +// want metrics.Metric +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, metrics.Metric) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got metrics.Metric) 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 { +// m: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 { +// m: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 := New(test.args.m) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_mirrorMetrics_View(t *testing.T) { +// type fields struct { +// m service.Mirror +// } +// type want struct { +// want []metrics.View +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, []metrics.View, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got []metrics.View, 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 { +// m: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 { +// m: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 +// } +// m := &mirrorMetrics{ +// m: test.fields.m, +// } +// +// got, err := m.View() +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_mirrorMetrics_Register(t *testing.T) { +// type args struct { +// m metrics.Meter +// } +// type fields struct { +// m service.Mirror +// } +// 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 { +// m:nil, +// }, +// fields: fields { +// m: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 { +// m:nil, +// }, +// fields: fields { +// m: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 +// } +// mm := &mirrorMetrics{ +// m: test.fields.m, +// } +// +// err := mm.Register(test.args.m) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/observability/metrics/grpc/grpc_test.go b/internal/observability/metrics/grpc/grpc_test.go index 41bb681be6..10247a6830 100644 --- a/internal/observability/metrics/grpc/grpc_test.go +++ b/internal/observability/metrics/grpc/grpc_test.go @@ -86,25 +86,24 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func Test_grpcServerMetrics_View(t *testing.T) { // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // g *grpcServerMetrics // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -168,7 +167,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -256,7 +254,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/index/job/correction/correction_test.go b/internal/observability/metrics/index/job/correction/correction_test.go index e37b690fd1..7133ba6c38 100644 --- a/internal/observability/metrics/index/job/correction/correction_test.go +++ b/internal/observability/metrics/index/job/correction/correction_test.go @@ -96,7 +96,6 @@ package correction // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -106,18 +105,18 @@ package correction // correction service.Corrector // } // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -189,7 +188,6 @@ package correction // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -288,7 +286,6 @@ package correction // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/info/info.go b/internal/observability/metrics/info/info.go index 3892992c92..1fba9ead3c 100644 --- a/internal/observability/metrics/info/info.go +++ b/internal/observability/metrics/info/info.go @@ -32,7 +32,7 @@ type info struct { } // New creates new general info metric according to the provided struct. -func New(name, description string, i interface{}) metrics.Metric { +func New(name, description string, i any) metrics.Metric { return &info{ name: name, description: description, @@ -40,7 +40,7 @@ func New(name, description string, i interface{}) metrics.Metric { } } -func labelKVs(i interface{}) map[string]string { +func labelKVs(i any) map[string]string { rt, rv := reflect.TypeOf(i), reflect.ValueOf(i) kvs := make(map[string]string, rt.NumField()) for k := 0; k < rt.NumField(); k++ { diff --git a/internal/observability/metrics/info/info_test.go b/internal/observability/metrics/info/info_test.go index 590b9c07f9..dbcbcaf04e 100644 --- a/internal/observability/metrics/info/info_test.go +++ b/internal/observability/metrics/info/info_test.go @@ -19,7 +19,7 @@ package info // type args struct { // name string // description string -// i interface{} +// i any // } // type want struct { // want metrics.Metric @@ -102,14 +102,13 @@ package info // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func Test_labelKVs(t *testing.T) { // type args struct { -// i interface{} +// i any // } // type want struct { // want map[string]string @@ -188,7 +187,6 @@ package info // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -200,18 +198,18 @@ package info // kvs map[string]string // } // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -289,7 +287,6 @@ package info // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -396,7 +393,6 @@ package info // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/manager/index/index_test.go b/internal/observability/metrics/manager/index/index_test.go index b8022e6fe9..027ca9a171 100644 --- a/internal/observability/metrics/manager/index/index_test.go +++ b/internal/observability/metrics/manager/index/index_test.go @@ -96,7 +96,6 @@ package index // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -106,18 +105,18 @@ package index // indexer service.Indexer // } // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -189,7 +188,6 @@ package index // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -288,7 +286,6 @@ package index // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/mem/index/index_test.go b/internal/observability/metrics/mem/index/index_test.go new file mode 100644 index 0000000000..f5b3485345 --- /dev/null +++ b/internal/observability/metrics/mem/index/index_test.go @@ -0,0 +1,259 @@ +// 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 index + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type want struct { +// want metrics.Metric +// } +// type test struct { +// name string +// want want +// checkFunc func(want, metrics.Metric) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got metrics.Metric) 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", +// 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 +// } +// +// got := New() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_memoryMetrics_View(t *testing.T) { +// type want struct { +// want []metrics.View +// err error +// } +// type test struct { +// name string +// m *memoryMetrics +// want want +// checkFunc func(want, []metrics.View, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got []metrics.View, 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", +// 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 +// } +// m := &memoryMetrics{} +// +// got, err := m.View() +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_memoryMetrics_Register(t *testing.T) { +// type args struct { +// m metrics.Meter +// } +// type want struct { +// err error +// } +// type test struct { +// name string +// args args +// m *memoryMetrics +// 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 { +// m: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 { +// m: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 +// } +// m := &memoryMetrics{} +// +// err := m.Register(test.args.m) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/observability/metrics/mem/mem_test.go b/internal/observability/metrics/mem/mem_test.go new file mode 100644 index 0000000000..5ec15fefca --- /dev/null +++ b/internal/observability/metrics/mem/mem_test.go @@ -0,0 +1,445 @@ +// 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 mem + +// NOT IMPLEMENTED BELOW +// +// func Test_getMemstatsMetrics(t *testing.T) { +// type want struct { +// want []*metricsInfo +// } +// type test struct { +// name string +// want want +// checkFunc func(want, []*metricsInfo) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got []*metricsInfo) 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", +// 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 +// } +// +// got := getMemstatsMetrics() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_getProcStatusMetrics(t *testing.T) { +// type args struct { +// pid int +// } +// type want struct { +// want []*metricsInfo +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, []*metricsInfo, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got []*metricsInfo, 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 { +// pid: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 { +// pid: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, err := getProcStatusMetrics(test.args.pid) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestNew(t *testing.T) { +// type want struct { +// want metrics.Metric +// } +// type test struct { +// name string +// want want +// checkFunc func(want, metrics.Metric) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got metrics.Metric) 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", +// 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 +// } +// +// got := New() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_memMetrics_View(t *testing.T) { +// type fields struct { +// pid int +// } +// type want struct { +// want []metrics.View +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, []metrics.View, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got []metrics.View, 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 { +// pid:0, +// }, +// 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 { +// pid:0, +// }, +// 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 +// } +// mm := &memMetrics{ +// pid: test.fields.pid, +// } +// +// got, err := mm.View() +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_memMetrics_Register(t *testing.T) { +// type args struct { +// m metrics.Meter +// } +// type fields struct { +// pid int +// } +// 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 { +// m:nil, +// }, +// fields: fields { +// pid: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 { +// m:nil, +// }, +// fields: fields { +// pid: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 +// } +// mm := &memMetrics{ +// pid: test.fields.pid, +// } +// +// err := mm.Register(test.args.m) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/observability/metrics/metrics.go b/internal/observability/metrics/metrics.go index 14fb7ff728..9806ef7b86 100644 --- a/internal/observability/metrics/metrics.go +++ b/internal/observability/metrics/metrics.go @@ -29,6 +29,9 @@ type ( View() ([]View, error) Register(Meter) error } + + Int64ObservableGauge = metric.Int64ObservableGauge + Float64ObservableGauge = metric.Float64ObservableGauge ) const ( diff --git a/internal/observability/metrics/metrics_test.go b/internal/observability/metrics/metrics_test.go index b5ceac3d07..0709d3d2f2 100644 --- a/internal/observability/metrics/metrics_test.go +++ b/internal/observability/metrics/metrics_test.go @@ -86,179 +86,6 @@ package metrics // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// -// }) -// } -// } -// -// func TestWithUnit(t *testing.T) { -// type args struct { -// u Unit -// } -// type want struct { -// want instrument.Option -// } -// type test struct { -// name string -// args args -// want want -// checkFunc func(want, instrument.Option) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) -// } -// defaultCheckFunc := func(w want, got instrument.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 { -// u: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 { -// u: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 := WithUnit(test.args.u) -// if err := checkFunc(test.want, got); err != nil { -// tt.Errorf("error = %v", err) -// } -// -// }) -// } -// } -// -// func TestWithDescription(t *testing.T) { -// type args struct { -// desc string -// } -// type want struct { -// want instrument.Option -// } -// type test struct { -// name string -// args args -// want want -// checkFunc func(want, instrument.Option) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) -// } -// defaultCheckFunc := func(w want, got instrument.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 { -// desc:"", -// }, -// 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 { -// desc:"", -// }, -// 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 := WithDescription(test.args.desc) -// if err := checkFunc(test.want, got); err != nil { -// tt.Errorf("error = %v", err) -// } -// // }) // } // } diff --git a/internal/observability/metrics/runtime/cgo/cgo_test.go b/internal/observability/metrics/runtime/cgo/cgo_test.go index c76091add5..868ad32f0a 100644 --- a/internal/observability/metrics/runtime/cgo/cgo_test.go +++ b/internal/observability/metrics/runtime/cgo/cgo_test.go @@ -86,25 +86,24 @@ package cgo // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func Test_cgo_View(t *testing.T) { // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // c *cgo // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -168,7 +167,6 @@ package cgo // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -256,7 +254,6 @@ package cgo // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/runtime/goroutine/goroutine_test.go b/internal/observability/metrics/runtime/goroutine/goroutine_test.go index e88358b3d1..3f227f83f4 100644 --- a/internal/observability/metrics/runtime/goroutine/goroutine_test.go +++ b/internal/observability/metrics/runtime/goroutine/goroutine_test.go @@ -86,25 +86,24 @@ package goroutine // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func Test_goroutine_View(t *testing.T) { // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // g *goroutine // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -168,7 +167,6 @@ package goroutine // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -256,7 +254,6 @@ package goroutine // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/metrics/tools/benchmark/benchmark.go b/internal/observability/metrics/tools/benchmark/benchmark.go index 370e07cbff..426083996c 100644 --- a/internal/observability/metrics/tools/benchmark/benchmark.go +++ b/internal/observability/metrics/tools/benchmark/benchmark.go @@ -43,13 +43,13 @@ const ( completeBenchmarkJobCountDescription = "Benchmark Operator complete benchmark job count" // appliedJobCount = "benchmark_operator_applied_job" - // appliedJobCountDescription = "Benchmark Operator applied job count" + // appliedJobCountDescription = "Benchmark Operator applied job count". // runningJobCount = "benchmark_operator_running_job" - // runningJobCountDescription = "Benchmark Operator running job count" + // runningJobCountDescription = "Benchmark Operator running job count". // completeJobCount = "benchmark_operator_complete_job" - // completeJobCountDescription = "Benchmark Operator complete job count" + // completeJobCountDescription = "Benchmark Operator complete job count". ) const ( @@ -68,7 +68,7 @@ func New(om service.Operator) metrics.Metric { } } -// TODO: implement here +// TODO: implement here. func (om *operatorMetrics) View() ([]metrics.View, error) { return []metrics.View{ view.NewView( @@ -128,7 +128,7 @@ func (om *operatorMetrics) View() ([]metrics.View, error) { }, nil } -// TODO: implement here +// TODO: implement here. func (om *operatorMetrics) Register(m metrics.Meter) error { appliedScenarioCount, err := m.Int64ObservableCounter( appliedScenarioCount, diff --git a/internal/observability/metrics/tools/benchmark/benchmark_test.go b/internal/observability/metrics/tools/benchmark/benchmark_test.go index b444083232..153773600d 100644 --- a/internal/observability/metrics/tools/benchmark/benchmark_test.go +++ b/internal/observability/metrics/tools/benchmark/benchmark_test.go @@ -297,3 +297,5 @@ func Test_operatorMetrics_Register(t *testing.T) { }) } } + +// NOT IMPLEMENTED BELOW diff --git a/internal/observability/metrics/version/version_test.go b/internal/observability/metrics/version/version_test.go index ad38708327..1fee6c9487 100644 --- a/internal/observability/metrics/version/version_test.go +++ b/internal/observability/metrics/version/version_test.go @@ -96,7 +96,6 @@ package version // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package version // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -192,18 +190,18 @@ package version // kvs map[string]string // } // type want struct { -// want []*metrics.View +// want []metrics.View // err error // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, []*metrics.View, error) error +// checkFunc func(want, []metrics.View, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []*metrics.View, err error) error { +// defaultCheckFunc := func(w want, got []metrics.View, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -275,7 +273,6 @@ package version // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -374,7 +371,6 @@ package version // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/observability_test.go b/internal/observability/observability_test.go index 8b2ca792fa..a894fb5c9a 100644 --- a/internal/observability/observability_test.go +++ b/internal/observability/observability_test.go @@ -103,7 +103,6 @@ package observability // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -193,7 +192,6 @@ package observability // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -304,7 +302,6 @@ package observability // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -415,7 +412,6 @@ package observability // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +522,6 @@ package observability // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/option_test.go b/internal/observability/option_test.go index b194966986..5f49e83ffa 100644 --- a/internal/observability/option_test.go +++ b/internal/observability/option_test.go @@ -96,7 +96,6 @@ package observability // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package observability // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package observability // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package observability // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/trace/status.go b/internal/observability/trace/status.go index 48a9adfd83..dc7390c61d 100644 --- a/internal/observability/trace/status.go +++ b/internal/observability/trace/status.go @@ -19,7 +19,7 @@ package trace import ( "github.com/vdaas/vald/internal/net/grpc/codes" - "go.opentelemetry.io/otel/attribute" + "github.com/vdaas/vald/internal/observability/attribute" ocodes "go.opentelemetry.io/otel/codes" semconv "go.opentelemetry.io/otel/semconv/v1.24.0" ) diff --git a/internal/observability/trace/status_test.go b/internal/observability/trace/status_test.go index 4226e5890d..e4c8b4cf83 100644 --- a/internal/observability/trace/status_test.go +++ b/internal/observability/trace/status_test.go @@ -103,7 +103,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -189,7 +188,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -275,7 +273,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -361,7 +358,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -447,7 +443,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -533,7 +528,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -619,7 +613,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -705,7 +698,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -791,7 +783,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -877,7 +868,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -963,7 +953,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1049,7 +1038,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1135,7 +1123,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1221,7 +1208,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1307,7 +1293,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1393,7 +1378,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1479,7 +1463,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1565,7 +1548,6 @@ package trace // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/observability/trace/trace.go b/internal/observability/trace/trace.go index cc3f42fa5b..71845ab276 100644 --- a/internal/observability/trace/trace.go +++ b/internal/observability/trace/trace.go @@ -46,7 +46,9 @@ type Tracer interface { type tracer struct{} -func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, Span) { +func StartSpan( + ctx context.Context, name string, opts ...trace.SpanStartOption, +) (context.Context, Span) { if !enabled { return ctx, nil } diff --git a/internal/observability/trace/trace_test.go b/internal/observability/trace/trace_test.go index bad9a0b3c9..a9325cc72c 100644 --- a/internal/observability/trace/trace_test.go +++ b/internal/observability/trace/trace_test.go @@ -110,7 +110,6 @@ package trace // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -200,7 +199,6 @@ package trace // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -288,7 +286,6 @@ package trace // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/rand/rand.go b/internal/rand/rand.go index c0db32be03..56cd0c8912 100644 --- a/internal/rand/rand.go +++ b/internal/rand/rand.go @@ -29,7 +29,7 @@ type rand struct { } var pool = sync.Pool{ - New: func() interface{} { + New: func() any { return (&rand{ x: new(uint32), }).init() diff --git a/internal/rand/rand_test.go b/internal/rand/rand_test.go index 8d9f762e50..7dcd7a3356 100644 --- a/internal/rand/rand_test.go +++ b/internal/rand/rand_test.go @@ -25,7 +25,7 @@ import ( func clearPool() { pool = sync.Pool{ - New: func() interface{} { + New: func() any { return new(rand).init() }, } diff --git a/internal/runner/option.go b/internal/runner/option.go index 603e146e01..17c5dfec6f 100644 --- a/internal/runner/option.go +++ b/internal/runner/option.go @@ -45,7 +45,7 @@ func WithVersion(ver, max, min string) Option { } } -func WithConfigLoader(f func(string) (interface{}, *config.GlobalConfig, error)) Option { +func WithConfigLoader(f func(string) (any, *config.GlobalConfig, error)) Option { return func(r *runner) { if f != nil { r.loadConfig = f @@ -53,7 +53,7 @@ func WithConfigLoader(f func(string) (interface{}, *config.GlobalConfig, error)) } } -func WithDaemonInitializer(f func(interface{}) (Runner, error)) Option { +func WithDaemonInitializer(f func(any) (Runner, error)) Option { return func(r *runner) { if f != nil { r.initializeDaemon = f diff --git a/internal/runner/option_test.go b/internal/runner/option_test.go index b97ba4b8a2..0ede371a3e 100644 --- a/internal/runner/option_test.go +++ b/internal/runner/option_test.go @@ -222,7 +222,7 @@ func TestWithVersion(t *testing.T) { func TestWithConfigLoader(t *testing.T) { type T = runner type args struct { - f func(string) (interface{}, *config.GlobalConfig, error) + f func(string) (any, *config.GlobalConfig, error) } type want struct { obj *T @@ -245,7 +245,7 @@ func TestWithConfigLoader(t *testing.T) { tests := []test{ func() test { - f := func(string) (interface{}, *config.GlobalConfig, error) { + f := func(string) (any, *config.GlobalConfig, error) { return nil, nil, nil } return test{ @@ -297,7 +297,7 @@ func TestWithConfigLoader(t *testing.T) { func TestWithDaemonInitializer(t *testing.T) { type T = runner type args struct { - f func(interface{}) (Runner, error) + f func(any) (Runner, error) } type want struct { obj *T @@ -320,7 +320,7 @@ func TestWithDaemonInitializer(t *testing.T) { tests := []test{ func() test { - f := func(interface{}) (Runner, error) { + f := func(any) (Runner, error) { return nil, nil } return test{ diff --git a/internal/runner/runner.go b/internal/runner/runner.go index ebd322a536..9caf79535f 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -52,8 +52,8 @@ type runner struct { maxVersion string minVersion string name string - loadConfig func(string) (interface{}, *config.GlobalConfig, error) - initializeDaemon func(interface{}) (Runner, error) + loadConfig func(string) (any, *config.GlobalConfig, error) + initializeDaemon func(any) (Runner, error) } func Do(ctx context.Context, opts ...Option) error { diff --git a/internal/runner/runner_race_test.go b/internal/runner/runner_race_test.go index 801bc914bc..22dd211a4f 100644 --- a/internal/runner/runner_race_test.go +++ b/internal/runner/runner_race_test.go @@ -93,7 +93,7 @@ func TestDo_for_race(t *testing.T) { args: args{ ctx: context.Background(), opts: []Option{ - WithConfigLoader(func(string) (interface{}, *config.GlobalConfig, error) { + WithConfigLoader(func(string) (any, *config.GlobalConfig, error) { return nil, nil, errors.New("err") }), }, @@ -115,7 +115,7 @@ func TestDo_for_race(t *testing.T) { ctx: context.Background(), opts: []Option{ WithVersion("v1.1.7", "v1.1.5", "v1.1.0"), - WithConfigLoader(func(string) (interface{}, *config.GlobalConfig, error) { + WithConfigLoader(func(string) (any, *config.GlobalConfig, error) { return nil, &config.GlobalConfig{ Logging: &config.Logging{ Logger: "glg", @@ -144,7 +144,7 @@ func TestDo_for_race(t *testing.T) { ctx: context.Background(), opts: []Option{ WithVersion("v1.1.2", "v1.1.5", "v1.1.0"), - WithConfigLoader(func(string) (interface{}, *config.GlobalConfig, error) { + WithConfigLoader(func(string) (any, *config.GlobalConfig, error) { return nil, &config.GlobalConfig{ Logging: &config.Logging{ Logger: "glg", @@ -154,7 +154,7 @@ func TestDo_for_race(t *testing.T) { Version: "v1.1.2", }, nil }), - WithDaemonInitializer(func(interface{}) (Runner, error) { + WithDaemonInitializer(func(any) (Runner, error) { return nil, errors.New("err") }), }, @@ -176,7 +176,7 @@ func TestDo_for_race(t *testing.T) { ctx: context.Background(), opts: []Option{ WithVersion("v1.1.2", "v1.1.5", "v1.1.0"), - WithConfigLoader(func(string) (interface{}, *config.GlobalConfig, error) { + WithConfigLoader(func(string) (any, *config.GlobalConfig, error) { return nil, &config.GlobalConfig{ Logging: &config.Logging{ Logger: "glg", @@ -186,7 +186,7 @@ func TestDo_for_race(t *testing.T) { Version: "v1.1.2", }, nil }), - WithDaemonInitializer(func(interface{}) (Runner, error) { + WithDaemonInitializer(func(any) (Runner, error) { return &runnerMock{ PreStartFunc: func(ctx context.Context) error { return nil diff --git a/internal/runner/runner_test.go b/internal/runner/runner_test.go index ebec1c94ec..81b6c396ef 100644 --- a/internal/runner/runner_test.go +++ b/internal/runner/runner_test.go @@ -372,7 +372,6 @@ func TestRun(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/safety/safety_test.go b/internal/safety/safety_test.go index 49dc59651f..22c9f87ba8 100644 --- a/internal/safety/safety_test.go +++ b/internal/safety/safety_test.go @@ -246,7 +246,6 @@ func TestRecoverFunc(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -335,7 +334,6 @@ func TestRecoverFunc(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/servers/server/option_test.go b/internal/servers/server/option_test.go index 1b6477a5f5..9e7aeda2bf 100644 --- a/internal/servers/server/option_test.go +++ b/internal/servers/server/option_test.go @@ -2567,7 +2567,6 @@ func TestDefaultHealthServerOption(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2653,7 +2652,6 @@ func TestDefaultHealthServerOption(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2739,7 +2737,6 @@ func TestDefaultHealthServerOption(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2825,7 +2822,6 @@ func TestDefaultHealthServerOption(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2911,7 +2907,6 @@ func TestDefaultHealthServerOption(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2997,7 +2992,6 @@ func TestDefaultHealthServerOption(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/servers/servers_mock.go b/internal/servers/servers_mock.go index cada14bd20..f37a08ce9d 100644 --- a/internal/servers/servers_mock.go +++ b/internal/servers/servers_mock.go @@ -13,9 +13,7 @@ // limitations under the License. package servers -import ( - "context" -) +import "context" type mockServer struct { NameFunc func() string diff --git a/internal/servers/starter/starter_test.go b/internal/servers/starter/starter_test.go index 304958b4c9..b5becde27b 100644 --- a/internal/servers/starter/starter_test.go +++ b/internal/servers/starter/starter_test.go @@ -581,7 +581,6 @@ func TestSetupMetrics(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -704,7 +703,6 @@ func TestSetupMetrics(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -827,7 +825,6 @@ func TestSetupMetrics(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/strings/strings.go b/internal/strings/strings.go index 69b970e093..7eeafe2f7e 100644 --- a/internal/strings/strings.go +++ b/internal/strings/strings.go @@ -81,7 +81,7 @@ var ( NewReplacer = strings.NewReplacer bufferPool = sync.Pool{ - New: func() interface{} { + New: func() any { return bytes.NewBuffer(make([]byte, 0, syscall.Getpagesize())) }, } diff --git a/internal/sync/errgroup/group_test.go b/internal/sync/errgroup/group_test.go index 5dd72b7e5a..9a608f4cfc 100644 --- a/internal/sync/errgroup/group_test.go +++ b/internal/sync/errgroup/group_test.go @@ -854,7 +854,6 @@ func Test_group_Wait(t *testing.T) { // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -940,7 +939,6 @@ func Test_group_Wait(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1055,7 +1053,6 @@ func Test_group_Wait(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1071,8 +1068,7 @@ func Test_group_Wait(t *testing.T) { // emap map[string]struct{} // errs []error // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1181,8 +1177,7 @@ func Test_group_Wait(t *testing.T) { // emap map[string]struct{} // errs []error // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1288,8 +1283,7 @@ func Test_group_Wait(t *testing.T) { // emap map[string]struct{} // errs []error // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields diff --git a/internal/sync/semaphore/semaphore_test.go b/internal/sync/semaphore/semaphore_test.go index 56b5881fcf..5a1e304ac8 100644 --- a/internal/sync/semaphore/semaphore_test.go +++ b/internal/sync/semaphore/semaphore_test.go @@ -309,7 +309,6 @@ func TestAllocCancelDoesntStarve(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -419,7 +418,6 @@ func TestAllocCancelDoesntStarve(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +524,6 @@ func TestAllocCancelDoesntStarve(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -540,8 +537,7 @@ func TestAllocCancelDoesntStarve(t *testing.T) { // size int64 // cur int64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -642,8 +638,7 @@ func TestAllocCancelDoesntStarve(t *testing.T) { // size int64 // cur int64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -741,8 +736,7 @@ func TestAllocCancelDoesntStarve(t *testing.T) { // size int64 // cur int64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // fields fields diff --git a/internal/sync/singleflight/singleflight.go b/internal/sync/singleflight/singleflight.go index 13d2ada450..d3305fab9f 100644 --- a/internal/sync/singleflight/singleflight.go +++ b/internal/sync/singleflight/singleflight.go @@ -112,7 +112,9 @@ func New[V any]() Group[V] { // time. If a duplicate comes in, the duplicate caller waits for the // original to complete and receives the same results. // The return value shared indicates whether v was given to multiple callers. -func (g *group[V]) Do(ctx context.Context, key string, fn func(context.Context) (V, error)) (v V, shared bool, err error) { +func (g *group[V]) Do( + ctx context.Context, key string, fn func(context.Context) (V, error), +) (v V, shared bool, err error) { g.mu.Lock() if g.m == nil { g.m = make(map[string]*call[V]) @@ -142,7 +144,9 @@ func (g *group[V]) Do(ctx context.Context, key string, fn func(context.Context) // results when they are ready. // // The returned channel will not be closed. -func (g *group[V]) DoChan(ctx context.Context, key string, fn func(context.Context) (V, error)) <-chan Result[V] { +func (g *group[V]) DoChan( + ctx context.Context, key string, fn func(context.Context) (V, error), +) <-chan Result[V] { ch := make(chan Result[V]) g.mu.Lock() if g.m == nil { @@ -165,7 +169,9 @@ func (g *group[V]) DoChan(ctx context.Context, key string, fn func(context.Conte } // doCall handles the single call for a key. -func (g *group[V]) doCall(ctx context.Context, c *call[V], key string, fn func(ctx context.Context) (V, error)) { +func (g *group[V]) doCall( + ctx context.Context, c *call[V], key string, fn func(ctx context.Context) (V, error), +) { normalReturn := false recovered := false diff --git a/internal/sync/singleflight/singleflight_test.go b/internal/sync/singleflight/singleflight_test.go index 021933f2b8..b6921c9e55 100644 --- a/internal/sync/singleflight/singleflight_test.go +++ b/internal/sync/singleflight/singleflight_test.go @@ -472,7 +472,7 @@ func TestPanicDo(t *testing.T) { func TestGoexitDo(t *testing.T) { g := New[any]() - fn := func(context.Context) (interface{}, error) { + fn := func(context.Context) (any, error) { runtime.Goexit() return nil, nil } @@ -527,7 +527,7 @@ func TestPanicDoChan(t *testing.T) { }() g := New[any]() - ch := g.DoChan(context.Background(), "", func(context.Context) (interface{}, error) { + ch := g.DoChan(context.Background(), "", func(context.Context) (any, error) { panic("Panicking in DoChan") }) <-ch @@ -568,7 +568,7 @@ func TestPanicDoSharedByDoChan(t *testing.T) { defer func() { recover() }() - g.Do(context.Background(), "", func(context.Context) (interface{}, error) { + g.Do(context.Background(), "", func(context.Context) (any, error) { close(blocked) <-unblock panic("Panicking in Do") @@ -576,7 +576,7 @@ func TestPanicDoSharedByDoChan(t *testing.T) { }() <-blocked - ch := g.DoChan(context.Background(), "", func(context.Context) (interface{}, error) { + ch := g.DoChan(context.Background(), "", func(context.Context) (any, error) { panic("DoChan unexpectedly executed callback") }) close(unblock) diff --git a/internal/test/data/hdf5/hdf5_test.go b/internal/test/data/hdf5/hdf5_test.go index d43a09c693..b516095627 100644 --- a/internal/test/data/hdf5/hdf5_test.go +++ b/internal/test/data/hdf5/hdf5_test.go @@ -1426,3 +1426,81 @@ func TestReadDatasetI32(t *testing.T) { }) } } + +// NOT IMPLEMENTED BELOW +// +// func TestHdf5Key_String(t *testing.T) { +// type want struct { +// want string +// } +// type test struct { +// name string +// key Hdf5Key +// 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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// 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 +// } +// +// got := test.key.String() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/test/data/hdf5/option.go b/internal/test/data/hdf5/option.go index ac2f9a3a24..e847b09805 100644 --- a/internal/test/data/hdf5/option.go +++ b/internal/test/data/hdf5/option.go @@ -17,9 +17,7 @@ // Package hdf5 is load hdf5 file package hdf5 -import ( - "github.com/vdaas/vald/internal/errors" -) +import "github.com/vdaas/vald/internal/errors" type Option func(d *data) error diff --git a/internal/test/data/hdf5/option_test.go b/internal/test/data/hdf5/option_test.go index 5453a71665..ea805cae8e 100644 --- a/internal/test/data/hdf5/option_test.go +++ b/internal/test/data/hdf5/option_test.go @@ -128,7 +128,7 @@ func TestWithNameByString(t *testing.T) { func TestWithName(t *testing.T) { // Change interface type to the type of object you are testing - type T = interface{} + type T = any type args struct { dn DatasetName } @@ -258,7 +258,7 @@ func TestWithName(t *testing.T) { func TestWithFilePath(t *testing.T) { // Change interface type to the type of object you are testing - type T = interface{} + type T = any type args struct { f string } @@ -385,3 +385,5 @@ func TestWithFilePath(t *testing.T) { }) } } + +// NOT IMPLEMENTED BELOW diff --git a/internal/test/data/request/insert.go b/internal/test/data/request/insert.go index bb5f0cd0e0..6d6b4f142c 100644 --- a/internal/test/data/request/insert.go +++ b/internal/test/data/request/insert.go @@ -27,7 +27,9 @@ const ( Float ) -func GenMultiInsertReq(t ObjectType, dist vector.Distribution, num int, dim int, cfg *payload.Insert_Config) (*payload.Insert_MultiRequest, error) { +func GenMultiInsertReq( + t ObjectType, dist vector.Distribution, num int, dim int, cfg *payload.Insert_Config, +) (*payload.Insert_MultiRequest, error) { var vecs [][]float32 var err error switch t { @@ -57,7 +59,9 @@ func GenMultiInsertReq(t ObjectType, dist vector.Distribution, num int, dim int, } // GenSameVecMultiInsertReq generates Insert_MultiRequest with the same vector. -func GenSameVecMultiInsertReq(num int, vec []float32, cfg *payload.Insert_Config) *payload.Insert_MultiRequest { +func GenSameVecMultiInsertReq( + num int, vec []float32, cfg *payload.Insert_Config, +) *payload.Insert_MultiRequest { req := &payload.Insert_MultiRequest{ Requests: make([]*payload.Insert_Request, num), } diff --git a/internal/test/data/vector/gen_test.go b/internal/test/data/vector/gen_test.go index eedd052efa..24f1c11bee 100644 --- a/internal/test/data/vector/gen_test.go +++ b/internal/test/data/vector/gen_test.go @@ -795,7 +795,6 @@ func TestConvertVectorsUint8ToFloat32(t *testing.T) { // if err := checkFunc(test.want, gotRet); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -884,7 +883,6 @@ func TestConvertVectorsUint8ToFloat32(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -973,7 +971,6 @@ func TestConvertVectorsUint8ToFloat32(t *testing.T) { // if err := checkFunc(test.want, gotVecs); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1062,7 +1059,6 @@ func TestConvertVectorsUint8ToFloat32(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1154,7 +1150,6 @@ func TestConvertVectorsUint8ToFloat32(t *testing.T) { // if err := checkFunc(test.want, gotRet); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1243,7 +1238,6 @@ func TestConvertVectorsUint8ToFloat32(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1332,7 +1326,6 @@ func TestConvertVectorsUint8ToFloat32(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/test/goleak/goleak_test.go b/internal/test/goleak/goleak_test.go index af86301d0f..a4e0112205 100644 --- a/internal/test/goleak/goleak_test.go +++ b/internal/test/goleak/goleak_test.go @@ -20,8 +20,7 @@ package goleak // t TestingT // options []Option // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -104,8 +103,7 @@ package goleak // m TestingM // options []Option // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/internal/test/mock/client/mirror_client_mock.go b/internal/test/mock/client/mirror_client_mock.go index 96baff34be..ec0e075298 100644 --- a/internal/test/mock/client/mirror_client_mock.go +++ b/internal/test/mock/client/mirror_client_mock.go @@ -33,22 +33,32 @@ type MirrorClientMock struct { RemoveByTimestampFunc func(ctx context.Context, in *payload.Remove_TimestampRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) } -func (mc *MirrorClientMock) Insert(ctx context.Context, in *payload.Insert_Request, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (mc *MirrorClientMock) Insert( + ctx context.Context, in *payload.Insert_Request, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { return mc.InsertFunc(ctx, in, opts...) } -func (mc *MirrorClientMock) Update(ctx context.Context, in *payload.Update_Request, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (mc *MirrorClientMock) Update( + ctx context.Context, in *payload.Update_Request, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { return mc.UpdateFunc(ctx, in, opts...) } -func (mc *MirrorClientMock) Upsert(ctx context.Context, in *payload.Upsert_Request, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (mc *MirrorClientMock) Upsert( + ctx context.Context, in *payload.Upsert_Request, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { return mc.UpsertFunc(ctx, in, opts...) } -func (mc *MirrorClientMock) Remove(ctx context.Context, in *payload.Remove_Request, opts ...grpc.CallOption) (*payload.Object_Location, error) { +func (mc *MirrorClientMock) Remove( + ctx context.Context, in *payload.Remove_Request, opts ...grpc.CallOption, +) (*payload.Object_Location, error) { return mc.RemoveFunc(ctx, in, opts...) } -func (mc *MirrorClientMock) RemoveByTimestamp(ctx context.Context, in *payload.Remove_TimestampRequest, opts ...grpc.CallOption) (*payload.Object_Locations, error) { +func (mc *MirrorClientMock) RemoveByTimestamp( + ctx context.Context, in *payload.Remove_TimestampRequest, opts ...grpc.CallOption, +) (*payload.Object_Locations, error) { return mc.RemoveByTimestampFunc(ctx, in, opts...) } diff --git a/internal/test/mock/controller_runtime.go b/internal/test/mock/controller_runtime.go index b8bd60fd1c..7ec38894a4 100644 --- a/internal/test/mock/controller_runtime.go +++ b/internal/test/mock/controller_runtime.go @@ -24,7 +24,9 @@ type MockSubResourceWriter struct { client.SubResourceWriter } -func (*MockSubResourceWriter) Update(context.Context, client.Object, ...client.SubResourceUpdateOption) error { +func (*MockSubResourceWriter) Update( + context.Context, client.Object, ...client.SubResourceUpdateOption, +) error { return nil } @@ -39,7 +41,9 @@ func (*MockClient) Status() client.SubResourceWriter { return s.SubResourceWriter } -func (*MockClient) Get(context.Context, client.ObjectKey, client.Object, ...client.GetOption) error { +func (*MockClient) Get( + context.Context, client.ObjectKey, client.Object, ...client.GetOption, +) error { return nil } diff --git a/internal/test/mock/grpc/grpc_client_mock.go b/internal/test/mock/grpc/grpc_client_mock.go index 8d83768dac..e29fc50c5d 100644 --- a/internal/test/mock/grpc/grpc_client_mock.go +++ b/internal/test/mock/grpc/grpc_client_mock.go @@ -37,7 +37,8 @@ type GRPCClientMock struct { } // OrderedRangeConcurrent calls the OrderedRangeConcurrentFunc object. -func (gc *GRPCClientMock) OrderedRangeConcurrent(ctx context.Context, +func (gc *GRPCClientMock) OrderedRangeConcurrent( + ctx context.Context, order []string, concurrency int, f func(ctx context.Context, @@ -54,7 +55,9 @@ func (gc *GRPCClientMock) ConnectedAddrs() []string { } // Connect calls the ConnectFunc object. -func (gc *GRPCClientMock) Connect(ctx context.Context, addr string, dopts ...grpc.DialOption) (pool.Conn, error) { +func (gc *GRPCClientMock) Connect( + ctx context.Context, addr string, dopts ...grpc.DialOption, +) (pool.Conn, error) { return gc.ConnectFunc(ctx, addr, dopts...) } diff --git a/internal/test/mock/grpc_testify_mock.go b/internal/test/mock/grpc_testify_mock.go index 858a5819a4..c853f27d4e 100644 --- a/internal/test/mock/grpc_testify_mock.go +++ b/internal/test/mock/grpc_testify_mock.go @@ -31,7 +31,7 @@ type ServerStreamTestifyMock struct { mock.Mock } -func (*ServerStreamTestifyMock) SendMsg(_ interface{}) error { +func (*ServerStreamTestifyMock) SendMsg(_ any) error { return nil } @@ -50,11 +50,11 @@ func (*ServerStreamTestifyMock) Context() context.Context { return context.Background() } -func (*ServerStreamTestifyMock) SendMsgWithContext(_ context.Context, _ interface{}) error { +func (*ServerStreamTestifyMock) SendMsgWithContext(_ context.Context, _ any) error { return nil } -func (*ServerStreamTestifyMock) RecvMsg(_ interface{}) error { +func (*ServerStreamTestifyMock) RecvMsg(_ any) error { return nil } @@ -83,7 +83,9 @@ func (c *ClientInternal) StartConnectionMonitor(ctx context.Context) (<-chan err return args.Get(0).(<-chan error), args.Error(1) } -func (c *ClientInternal) Connect(ctx context.Context, addr string, dopts ...DialOption) (pool.Conn, error) { +func (c *ClientInternal) Connect( + ctx context.Context, addr string, dopts ...DialOption, +) (pool.Conn, error) { args := c.Called(ctx, addr, dopts) return args.Get(0).(pool.Conn), args.Error(1) } @@ -98,7 +100,8 @@ func (c *ClientInternal) Disconnect(ctx context.Context, addr string) error { return args.Error(0) } -func (c *ClientInternal) Range(ctx context.Context, +func (c *ClientInternal) Range( + ctx context.Context, f func(ctx context.Context, addr string, conn *ClientConn, @@ -108,7 +111,8 @@ func (c *ClientInternal) Range(ctx context.Context, return args.Error(0) } -func (c *ClientInternal) RangeConcurrent(ctx context.Context, +func (c *ClientInternal) RangeConcurrent( + ctx context.Context, concurrency int, f func(ctx context.Context, addr string, @@ -119,7 +123,8 @@ func (c *ClientInternal) RangeConcurrent(ctx context.Context, return args.Error(0) } -func (c *ClientInternal) OrderedRange(ctx context.Context, +func (c *ClientInternal) OrderedRange( + ctx context.Context, order []string, f func(ctx context.Context, addr string, @@ -130,7 +135,8 @@ func (c *ClientInternal) OrderedRange(ctx context.Context, return args.Error(0) } -func (c *ClientInternal) OrderedRangeConcurrent(ctx context.Context, +func (c *ClientInternal) OrderedRangeConcurrent( + ctx context.Context, order []string, concurrency int, f func(ctx context.Context, @@ -142,19 +148,23 @@ func (c *ClientInternal) OrderedRangeConcurrent(ctx context.Context, return args.Error(0) } -func (c *ClientInternal) Do(ctx context.Context, addr string, +func (c *ClientInternal) Do( + ctx context.Context, + addr string, f func(ctx context.Context, conn *ClientConn, - copts ...CallOption) (interface{}, error), -) (interface{}, error) { + copts ...CallOption) (any, error), +) (any, error) { args := c.Called(ctx, addr, f) return args.Get(0), args.Error(1) } -func (c *ClientInternal) RoundRobin(ctx context.Context, f func(ctx context.Context, - conn *ClientConn, - copts ...CallOption) (interface{}, error), -) (interface{}, error) { +func (c *ClientInternal) RoundRobin( + ctx context.Context, + f func(ctx context.Context, + conn *ClientConn, + copts ...CallOption) (any, error), +) (any, error) { args := c.Called(ctx, f) return args.Get(0), args.Error(1) } diff --git a/internal/test/mock/k8s/client.go b/internal/test/mock/k8s/client.go index 9a3c628ccb..dfce1c16b9 100644 --- a/internal/test/mock/k8s/client.go +++ b/internal/test/mock/k8s/client.go @@ -31,37 +31,51 @@ type ValdK8sClientMock struct { var _ client.Client = (*ValdK8sClientMock)(nil) -func (m *ValdK8sClientMock) Get(ctx context.Context, name, namespace string, obj k8s.Object, opts ...crclient.GetOption) error { +func (m *ValdK8sClientMock) Get( + ctx context.Context, name, namespace string, obj k8s.Object, opts ...crclient.GetOption, +) error { args := m.Called(ctx, name, namespace, obj, opts) return args.Error(0) } -func (m *ValdK8sClientMock) List(ctx context.Context, list crclient.ObjectList, opts ...k8s.ListOption) error { +func (m *ValdK8sClientMock) List( + ctx context.Context, list crclient.ObjectList, opts ...k8s.ListOption, +) error { args := m.Called(ctx, list, opts) return args.Error(0) } -func (m *ValdK8sClientMock) Create(ctx context.Context, obj k8s.Object, opts ...k8s.CreateOption) error { +func (m *ValdK8sClientMock) Create( + ctx context.Context, obj k8s.Object, opts ...k8s.CreateOption, +) error { args := m.Called(ctx, obj, opts) return args.Error(0) } -func (m *ValdK8sClientMock) Delete(ctx context.Context, obj k8s.Object, opts ...crclient.DeleteOption) error { +func (m *ValdK8sClientMock) Delete( + ctx context.Context, obj k8s.Object, opts ...crclient.DeleteOption, +) error { args := m.Called(ctx, obj, opts) return args.Error(0) } -func (m *ValdK8sClientMock) Update(ctx context.Context, obj k8s.Object, opts ...crclient.UpdateOption) error { +func (m *ValdK8sClientMock) Update( + ctx context.Context, obj k8s.Object, opts ...crclient.UpdateOption, +) error { args := m.Called(ctx, obj, opts) return args.Error(0) } -func (m *ValdK8sClientMock) Patch(ctx context.Context, obj k8s.Object, patch crclient.Patch, opts ...crclient.PatchOption) error { +func (m *ValdK8sClientMock) Patch( + ctx context.Context, obj k8s.Object, patch crclient.Patch, opts ...crclient.PatchOption, +) error { args := m.Called(ctx, obj, patch, opts) return args.Error(0) } -func (m *ValdK8sClientMock) Watch(ctx context.Context, obj crclient.ObjectList, opts ...k8s.ListOption) (watch.Interface, error) { +func (m *ValdK8sClientMock) Watch( + ctx context.Context, obj crclient.ObjectList, opts ...k8s.ListOption, +) (watch.Interface, error) { args := m.Called(ctx, obj, opts) return args.Get(0).(watch.Interface), args.Error(1) } @@ -71,7 +85,9 @@ func (m *ValdK8sClientMock) MatchingLabels(labels map[string]string) k8s.Matchin return args.Get(0).(k8s.MatchingLabels) } -func (m *ValdK8sClientMock) LabelSelector(key string, op selection.Operator, vals []string) (labels.Selector, error) { +func (m *ValdK8sClientMock) LabelSelector( + key string, op selection.Operator, vals []string, +) (labels.Selector, error) { args := m.Called(key, op, vals) return args.Get(0).(labels.Selector), args.Error(1) } @@ -82,7 +98,9 @@ type PatcherMock struct { var _ client.Patcher = (*PatcherMock)(nil) -func (m *PatcherMock) ApplyPodAnnotations(ctx context.Context, name, namespace string, entries map[string]string) error { +func (m *PatcherMock) ApplyPodAnnotations( + ctx context.Context, name, namespace string, entries map[string]string, +) error { args := m.Called(ctx, name, namespace, entries) return args.Error(0) } diff --git a/internal/test/mock/k8s/controller_runtime.go b/internal/test/mock/k8s/controller_runtime.go index c08fec5414..039f1945ad 100644 --- a/internal/test/mock/k8s/controller_runtime.go +++ b/internal/test/mock/k8s/controller_runtime.go @@ -26,7 +26,9 @@ type SubResourceWriterMock struct { UpdateFunc func(context.Context, client.Object, ...client.SubResourceUpdateOption) error } -func (sm *SubResourceWriterMock) Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error { +func (sm *SubResourceWriterMock) Update( + ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption, +) error { return sm.UpdateFunc(ctx, obj, opts...) } @@ -44,19 +46,27 @@ func (cm *ClientMock) Status() client.SubResourceWriter { return cm.StatusFunc() } -func (cm *ClientMock) Get(ctx context.Context, objKey client.ObjectKey, obj client.Object, opts ...client.GetOption) error { +func (cm *ClientMock) Get( + ctx context.Context, objKey client.ObjectKey, obj client.Object, opts ...client.GetOption, +) error { return cm.GetFunc(ctx, objKey, obj, opts...) } -func (cm *ClientMock) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error { +func (cm *ClientMock) Create( + ctx context.Context, obj client.Object, opts ...client.CreateOption, +) error { return cm.CreateFunc(ctx, obj, opts...) } -func (cm *ClientMock) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error { +func (cm *ClientMock) Delete( + ctx context.Context, obj client.Object, opts ...client.DeleteOption, +) error { return cm.DeleteFunc(ctx, obj, opts...) } -func (cm *ClientMock) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error { +func (cm *ClientMock) DeleteAllOf( + ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption, +) error { return cm.DeleteAllOfFunc(ctx, obj, opts...) } diff --git a/internal/test/mock/server_stream.go b/internal/test/mock/server_stream.go index b9051179d9..2e4c2abcc8 100644 --- a/internal/test/mock/server_stream.go +++ b/internal/test/mock/server_stream.go @@ -41,8 +41,8 @@ type ServerStreamMock struct { SendHeaderFunc func(metadata.MD) error SetTrailerFunc func(metadata.MD) ContextFunc func() context.Context - SendMsgFunc func(interface{}) error - RecvMsgFunc func(interface{}) error + SendMsgFunc func(any) error + RecvMsgFunc func(any) error } func (m *ServerStreamMock) SetHeader(md metadata.MD) error { @@ -61,10 +61,10 @@ func (m *ServerStreamMock) Context() context.Context { return m.ContextFunc() } -func (m *ServerStreamMock) SendMsg(msg interface{}) error { +func (m *ServerStreamMock) SendMsg(msg any) error { return m.SendMsgFunc(msg) } -func (m *ServerStreamMock) RecvMsg(msg interface{}) error { +func (m *ServerStreamMock) RecvMsg(msg any) error { return m.RecvMsgFunc(msg) } diff --git a/internal/test/testify/testify.go b/internal/test/testify/testify.go index 4b85ddaa71..5c6c5896ce 100644 --- a/internal/test/testify/testify.go +++ b/internal/test/testify/testify.go @@ -13,9 +13,7 @@ // limitations under the License. package testify -import ( - "github.com/stretchr/testify/mock" -) +import "github.com/stretchr/testify/mock" type ( Arguments = mock.Arguments diff --git a/internal/timeutil/location/loc.go b/internal/timeutil/location/loc.go index ea22a48300..4b79670e46 100644 --- a/internal/timeutil/location/loc.go +++ b/internal/timeutil/location/loc.go @@ -13,9 +13,7 @@ // limitations under the License. package location -import ( - "time" -) +import "time" const ( locationTokyo = "Asia/Tokyo" diff --git a/internal/timeutil/location/loc_bench_test.go b/internal/timeutil/location/loc_bench_test.go index 2754ef2bc4..756fce782e 100644 --- a/internal/timeutil/location/loc_bench_test.go +++ b/internal/timeutil/location/loc_bench_test.go @@ -13,9 +13,7 @@ // limitations under the License. package location -import ( - "testing" -) +import "testing" func BenchmarkGMT(b *testing.B) { b.ReportAllocs() diff --git a/internal/timeutil/rate/rate_test.go b/internal/timeutil/rate/rate_test.go new file mode 100644 index 0000000000..be8062d434 --- /dev/null +++ b/internal/timeutil/rate/rate_test.go @@ -0,0 +1,207 @@ +// 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 rate + +// NOT IMPLEMENTED BELOW +// +// func TestNewLimiter(t *testing.T) { +// type args struct { +// cnt int +// } +// type want struct { +// want Limiter +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Limiter) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Limiter) 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 { +// cnt: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 { +// cnt: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 := NewLimiter(test.args.cnt) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_limiter_Wait(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// isStd bool +// uber ratelimit.Limiter +// std *rate.Limiter +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// isStd:false, +// uber:nil, +// std: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 { +// ctx:nil, +// }, +// fields: fields { +// isStd:false, +// uber:nil, +// std: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 +// } +// l := &limiter{ +// isStd: test.fields.isStd, +// uber: test.fields.uber, +// std: test.fields.std, +// } +// +// err := l.Wait(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/tls/tls.go b/internal/tls/tls.go index d33f32f1d3..64811db689 100644 --- a/internal/tls/tls.go +++ b/internal/tls/tls.go @@ -110,14 +110,14 @@ func NewX509CertPool(path string) (pool *x509.CertPool, err error) { if err != nil || c == nil { return nil, err } - if err == nil && c != nil { - pool, err = x509.SystemCertPool() - if err != nil || pool == nil { - pool = x509.NewCertPool() - } - if !pool.AppendCertsFromPEM(c) { - err = errors.ErrCertificationFailed - } + + pool, err = x509.SystemCertPool() + if err != nil || pool == nil { + pool = x509.NewCertPool() + } + + if !pool.AppendCertsFromPEM(c) { + err = errors.ErrCertificationFailed } return pool, err } diff --git a/internal/tls/tls_test.go b/internal/tls/tls_test.go index a78136c3d3..6331e57f8d 100644 --- a/internal/tls/tls_test.go +++ b/internal/tls/tls_test.go @@ -518,7 +518,6 @@ func TestNewX509CertPool(t *testing.T) { // if err := checkFunc(test.want, gotC, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/internal/worker/worker_option.go b/internal/worker/worker_option.go index 872e75dc0e..4c203a9f6e 100644 --- a/internal/worker/worker_option.go +++ b/internal/worker/worker_option.go @@ -17,9 +17,7 @@ // Package worker provides worker processes package worker -import ( - "github.com/vdaas/vald/internal/sync/errgroup" -) +import "github.com/vdaas/vald/internal/sync/errgroup" type WorkerOption func(w *worker) error diff --git a/internal/worker/worker_option_test.go b/internal/worker/worker_option_test.go index 90246fe0f7..c158d89ac2 100644 --- a/internal/worker/worker_option_test.go +++ b/internal/worker/worker_option_test.go @@ -100,7 +100,6 @@ package worker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package worker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package worker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package worker // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/k8s/agent/ngt/configmap.yaml b/k8s/agent/ngt/configmap.yaml index e5f207c05d..feab29ca49 100644 --- a/k8s/agent/ngt/configmap.yaml +++ b/k8s/agent/ngt/configmap.yaml @@ -219,6 +219,7 @@ data: enable_export_index_info_to_k8s: false enable_in_memory_mode: true enable_proactive_gc: false + enable_statistics: false error_buffer_limit: 10 export_index_info_duration: 1m index_path: "" diff --git a/k8s/operator/helm/crds/valdrelease.yaml b/k8s/operator/helm/crds/valdrelease.yaml index dff6669d2e..88657d76e0 100644 --- a/k8s/operator/helm/crds/valdrelease.yaml +++ b/k8s/operator/helm/crds/valdrelease.yaml @@ -147,6 +147,63 @@ spec: x-kubernetes-preserve-unknown-fields: true externalTrafficPolicy: type: string + faiss: + type: object + properties: + auto_index_check_duration: + type: string + auto_index_duration_limit: + type: string + auto_index_length: + type: integer + auto_save_index_duration: + type: string + dimension: + type: integer + minimum: 1 + enable_copy_on_write: + type: boolean + enable_in_memory_mode: + type: boolean + enable_proactive_gc: + type: boolean + index_path: + type: string + initial_delay_max_duration: + type: string + kvsdb: + type: object + properties: + concurrency: + type: integer + load_index_timeout_factor: + type: string + m: + type: integer + max_load_index_timeout: + type: string + metric_type: + type: string + enum: + - innerproduct + - l2 + min_load_index_timeout: + type: string + namespace: + type: string + nbits_per_idx: + type: integer + nlist: + type: integer + pod_name: + type: string + vqueue: + type: object + properties: + delete_buffer_pool_size: + type: integer + insert_buffer_pool_size: + type: integer hpa: type: object properties: @@ -275,6 +332,8 @@ spec: type: boolean enable_proactive_gc: type: boolean + enable_statistics: + type: boolean error_buffer_limit: type: integer minimum: 1 diff --git a/k8s/operator/helm/operator.yaml b/k8s/operator/helm/operator.yaml index a3447788f0..6742640aea 100644 --- a/k8s/operator/helm/operator.yaml +++ b/k8s/operator/helm/operator.yaml @@ -45,8 +45,6 @@ spec: image: "vdaas/vald-helm-operator:v1.7.12" imagePullPolicy: Always args: - - "run" - - "--watches-file=./watches.yaml" - "--leader-elect" - "--leader-election-id=vald-helm-operator" - "--leader-election-namespace=default" diff --git a/pkg/agent/core/faiss/config/config_test.go b/pkg/agent/core/faiss/config/config_test.go new file mode 100644 index 0000000000..aed7f2d165 --- /dev/null +++ b/pkg/agent/core/faiss/config/config_test.go @@ -0,0 +1,105 @@ +// 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 config + +// NOT IMPLEMENTED BELOW +// +// func TestNewConfig(t *testing.T) { +// type args struct { +// path string +// } +// type want struct { +// wantCfg *Data +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, *Data, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCfg *Data, 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(gotCfg, w.wantCfg) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCfg, w.wantCfg) +// } +// 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 +// } +// +// gotCfg, err := NewConfig(test.args.path) +// if err := checkFunc(test.want, gotCfg, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/flush.go b/pkg/agent/core/faiss/handler/grpc/flush.go index dbaef33c9c..1298565351 100644 --- a/pkg/agent/core/faiss/handler/grpc/flush.go +++ b/pkg/agent/core/faiss/handler/grpc/flush.go @@ -19,7 +19,9 @@ import ( "github.com/vdaas/vald/apis/grpc/v1/payload" ) -// TODO: implement Flush Handler -func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (*payload.Info_Index_Count, error) { +// TODO: implement Flush Handler. +func (s *server) Flush( + ctx context.Context, req *payload.Flush_Request, +) (*payload.Info_Index_Count, error) { return s.UnimplementedValdServer.UnimplementedFlushServer.Flush(ctx, req) } diff --git a/pkg/agent/core/faiss/handler/grpc/flush_test.go b/pkg/agent/core/faiss/handler/grpc/flush_test.go new file mode 100644 index 0000000000..37f0e73094 --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/flush_test.go @@ -0,0 +1,145 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_Flush(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Flush_Request +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// want *payload.Info_Index_Count +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Count, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got *payload.Info_Index_Count, 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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// got, err := s.Flush(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/handler_test.go b/pkg/agent/core/faiss/handler/grpc/handler_test.go new file mode 100644 index 0000000000..70cc4d4173 --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/handler_test.go @@ -0,0 +1,349 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Server +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Server, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Server, 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 Test_server_newLocations(t *testing.T) { +// type args struct { +// uuids []string +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantLocs *payload.Object_Locations +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations) error { +// if !reflect.DeepEqual(gotLocs, w.wantLocs) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// uuids:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// uuids:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotLocs := s.newLocations(test.args.uuids...) +// if err := checkFunc(test.want, gotLocs); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_newLocation(t *testing.T) { +// type args struct { +// uuid string +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// want *payload.Object_Location +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got *payload.Object_Location) 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 { +// uuid:"", +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// uuid:"", +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// got := s.newLocation(test.args.uuid) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/index.go b/pkg/agent/core/faiss/handler/grpc/index.go index 03d5eb2813..b12c0ed3c8 100644 --- a/pkg/agent/core/faiss/handler/grpc/index.go +++ b/pkg/agent/core/faiss/handler/grpc/index.go @@ -29,7 +29,9 @@ import ( "github.com/vdaas/vald/internal/observability/trace" ) -func (s *server) CreateIndex(ctx context.Context, c *payload.Control_CreateIndexRequest) (res *payload.Empty, err error) { +func (s *server) CreateIndex( + ctx context.Context, c *payload.Control_CreateIndexRequest, +) (res *payload.Empty, err error) { ctx, span := trace.StartSpan(ctx, apiName+".CreateIndex") defer func() { if span != nil { @@ -110,7 +112,9 @@ func (s *server) SaveIndex(ctx context.Context, _ *payload.Empty) (res *payload. return res, nil } -func (s *server) CreateAndSaveIndex(ctx context.Context, c *payload.Control_CreateIndexRequest) (res *payload.Empty, err error) { +func (s *server) CreateAndSaveIndex( + ctx context.Context, c *payload.Control_CreateIndexRequest, +) (res *payload.Empty, err error) { ctx, span := trace.StartSpan(ctx, apiName+".CreateAndSaveIndex") defer func() { if span != nil { @@ -163,7 +167,9 @@ func (s *server) CreateAndSaveIndex(ctx context.Context, c *payload.Control_Crea return res, nil } -func (s *server) IndexInfo(ctx context.Context, c *payload.Empty) (res *payload.Info_Index_Count, err error) { +func (s *server) IndexInfo( + ctx context.Context, c *payload.Empty, +) (res *payload.Info_Index_Count, err error) { _, span := trace.StartSpan(ctx, apiName+".IndexInfo") defer func() { if span != nil { diff --git a/pkg/agent/core/faiss/handler/grpc/index_test.go b/pkg/agent/core/faiss/handler/grpc/index_test.go new file mode 100644 index 0000000000..4b74453663 --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/index_test.go @@ -0,0 +1,532 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_CreateIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// c *payload.Control_CreateIndexRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Empty +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Empty, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Empty, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// c:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// c:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.CreateIndex(test.args.ctx, test.args.c) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_SaveIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 *payload.Empty +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Empty +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Empty, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Empty, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.SaveIndex(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_CreateAndSaveIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// c *payload.Control_CreateIndexRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Empty +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Empty, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Empty, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// c:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// c:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.CreateAndSaveIndex(test.args.ctx, test.args.c) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_IndexInfo(t *testing.T) { +// type args struct { +// ctx context.Context +// c *payload.Empty +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Info_Index_Count +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Count, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Count, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// c:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// c:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.IndexInfo(test.args.ctx, test.args.c) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/insert.go b/pkg/agent/core/faiss/handler/grpc/insert.go index 356afc0632..f975178d6d 100644 --- a/pkg/agent/core/faiss/handler/grpc/insert.go +++ b/pkg/agent/core/faiss/handler/grpc/insert.go @@ -28,11 +28,13 @@ import ( "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "github.com/vdaas/vald/internal/observability/trace" - "go.opentelemetry.io/otel/attribute" ) -func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (res *payload.Object_Location, err error) { +func (s *server) Insert( + ctx context.Context, req *payload.Insert_Request, +) (res *payload.Object_Location, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.InsertRPCName) defer func() { if span != nil { @@ -136,6 +138,8 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) return s.UnimplementedValdServer.UnimplementedInsertServer.StreamInsert(stream) } -func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequest) (res *payload.Object_Locations, err error) { +func (s *server) MultiInsert( + ctx context.Context, reqs *payload.Insert_MultiRequest, +) (res *payload.Object_Locations, err error) { return s.UnimplementedValdServer.UnimplementedInsertServer.MultiInsert(ctx, reqs) } diff --git a/pkg/agent/core/faiss/handler/grpc/insert_test.go b/pkg/agent/core/faiss/handler/grpc/insert_test.go new file mode 100644 index 0000000000..7f40ec0635 --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/insert_test.go @@ -0,0 +1,396 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_Insert(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Insert_Request +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Object_Location +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Location, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.Insert(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamInsert(t *testing.T) { +// type args struct { +// stream vald.Insert_StreamInsertServer +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamInsert(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiInsert(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Insert_MultiRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Object_Locations +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.MultiInsert(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/linear_search.go b/pkg/agent/core/faiss/handler/grpc/linear_search.go index b871582f28..b48573b775 100644 --- a/pkg/agent/core/faiss/handler/grpc/linear_search.go +++ b/pkg/agent/core/faiss/handler/grpc/linear_search.go @@ -23,11 +23,15 @@ import ( "github.com/vdaas/vald/apis/grpc/v1/vald" ) -func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) LinearSearch( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { return s.UnimplementedValdServer.UnimplementedSearchServer.LinearSearch(ctx, req) } -func (s *server) LinearSearchByID(ctx context.Context, req *payload.Search_IDRequest) (res *payload.Search_Response, err error) { +func (s *server) LinearSearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { return s.UnimplementedValdServer.UnimplementedSearchServer.LinearSearchByID(ctx, req) } @@ -35,14 +39,20 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) return s.UnimplementedValdServer.UnimplementedSearchServer.StreamLinearSearch(stream) } -func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByIDServer) (err error) { +func (s *server) StreamLinearSearchByID( + stream vald.Search_StreamLinearSearchByIDServer, +) (err error) { return s.UnimplementedValdServer.UnimplementedSearchServer.StreamLinearSearchByID(stream) } -func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_MultiRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiLinearSearch( + ctx context.Context, reqs *payload.Search_MultiRequest, +) (res *payload.Search_Responses, errs error) { return s.UnimplementedValdServer.UnimplementedSearchServer.MultiLinearSearch(ctx, reqs) } -func (s *server) MultiLinearSearchByID(ctx context.Context, reqs *payload.Search_MultiIDRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiLinearSearchByID( + ctx context.Context, reqs *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, errs error) { return s.UnimplementedValdServer.UnimplementedSearchServer.MultiLinearSearchByID(ctx, reqs) } diff --git a/pkg/agent/core/faiss/handler/grpc/linear_search_test.go b/pkg/agent/core/faiss/handler/grpc/linear_search_test.go new file mode 100644 index 0000000000..e8fcddf8ec --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/linear_search_test.go @@ -0,0 +1,776 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_LinearSearch(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Search_Request +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.LinearSearch(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_LinearSearchByID(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Search_IDRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.LinearSearchByID(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamLinearSearch(t *testing.T) { +// type args struct { +// stream vald.Search_StreamLinearSearchServer +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamLinearSearch(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamLinearSearchByID(t *testing.T) { +// type args struct { +// stream vald.Search_StreamLinearSearchByIDServer +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamLinearSearchByID(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiLinearSearch(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Search_MultiRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Search_Responses +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Search_Responses, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.MultiLinearSearch(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiLinearSearchByID(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Search_MultiIDRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Search_Responses +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Search_Responses, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.MultiLinearSearchByID(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/object.go b/pkg/agent/core/faiss/handler/grpc/object.go index ff5d43596f..a8cb4529c0 100644 --- a/pkg/agent/core/faiss/handler/grpc/object.go +++ b/pkg/agent/core/faiss/handler/grpc/object.go @@ -29,7 +29,9 @@ import ( "github.com/vdaas/vald/internal/observability/trace" ) -func (s *server) Exists(ctx context.Context, uid *payload.Object_ID) (res *payload.Object_ID, err error) { +func (s *server) Exists( + ctx context.Context, uid *payload.Object_ID, +) (res *payload.Object_ID, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.ExistsRPCName) defer func() { if span != nil { @@ -87,7 +89,9 @@ func (s *server) Exists(ctx context.Context, uid *payload.Object_ID) (res *paylo return uid, nil } -func (s *server) GetObject(ctx context.Context, id *payload.Object_VectorRequest) (res *payload.Object_Vector, err error) { +func (s *server) GetObject( + ctx context.Context, id *payload.Object_VectorRequest, +) (res *payload.Object_Vector, err error) { return s.UnimplementedValdServer.UnimplementedObjectServer.GetObject(ctx, id) } diff --git a/pkg/agent/core/faiss/handler/grpc/object_test.go b/pkg/agent/core/faiss/handler/grpc/object_test.go new file mode 100644 index 0000000000..8cef7e4f3d --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/object_test.go @@ -0,0 +1,396 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_Exists(t *testing.T) { +// type args struct { +// ctx context.Context +// uid *payload.Object_ID +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Object_ID +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_ID, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_ID, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// uid:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// uid:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.Exists(test.args.ctx, test.args.uid) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_GetObject(t *testing.T) { +// type args struct { +// ctx context.Context +// id *payload.Object_VectorRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Object_Vector +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Vector, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Vector, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// id:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// id:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.GetObject(test.args.ctx, test.args.id) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamGetObject(t *testing.T) { +// type args struct { +// stream vald.Object_StreamGetObjectServer +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamGetObject(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/option_test.go b/pkg/agent/core/faiss/handler/grpc/option_test.go new file mode 100644 index 0000000000..14b2ebb109 --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/option_test.go @@ -0,0 +1,441 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func TestWithIP(t *testing.T) { +// type args struct { +// ip 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 { +// ip:"", +// }, +// 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 { +// ip:"", +// }, +// 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 := WithIP(test.args.ip) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithName(t *testing.T) { +// type args struct { +// name 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithName(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithFaiss(t *testing.T) { +// type args struct { +// f service.Faiss +// } +// 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 { +// f: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 { +// f: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 := WithFaiss(test.args.f) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithStreamConcurrency(t *testing.T) { +// type args struct { +// c 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 { +// c: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 { +// c: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 := WithStreamConcurrency(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/remove.go b/pkg/agent/core/faiss/handler/grpc/remove.go index 9cbaea4496..a2f0e31d15 100644 --- a/pkg/agent/core/faiss/handler/grpc/remove.go +++ b/pkg/agent/core/faiss/handler/grpc/remove.go @@ -27,11 +27,13 @@ import ( "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "github.com/vdaas/vald/internal/observability/trace" - "go.opentelemetry.io/otel/attribute" ) -func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (res *payload.Object_Location, err error) { +func (s *server) Remove( + ctx context.Context, req *payload.Remove_Request, +) (res *payload.Object_Location, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.RemoveRPCName) defer func() { if span != nil { @@ -129,6 +131,8 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) return s.UnimplementedValdServer.UnimplementedRemoveServer.StreamRemove(stream) } -func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequest) (res *payload.Object_Locations, err error) { +func (s *server) MultiRemove( + ctx context.Context, reqs *payload.Remove_MultiRequest, +) (res *payload.Object_Locations, err error) { return s.UnimplementedValdServer.UnimplementedRemoveServer.MultiRemove(ctx, reqs) } diff --git a/pkg/agent/core/faiss/handler/grpc/remove_test.go b/pkg/agent/core/faiss/handler/grpc/remove_test.go new file mode 100644 index 0000000000..36ca0b68b9 --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/remove_test.go @@ -0,0 +1,396 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_Remove(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Remove_Request +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Object_Location +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Location, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.Remove(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamRemove(t *testing.T) { +// type args struct { +// stream vald.Remove_StreamRemoveServer +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamRemove(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiRemove(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Remove_MultiRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Object_Locations +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.MultiRemove(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/search.go b/pkg/agent/core/faiss/handler/grpc/search.go index bbe5a45c4d..4cbc224384 100644 --- a/pkg/agent/core/faiss/handler/grpc/search.go +++ b/pkg/agent/core/faiss/handler/grpc/search.go @@ -27,11 +27,13 @@ import ( "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "github.com/vdaas/vald/internal/observability/trace" - "go.opentelemetry.io/otel/attribute" ) -func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) Search( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.SearchRPCName) defer func() { if span != nil { @@ -158,7 +160,9 @@ func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res * return res, nil } -func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) (res *payload.Search_Response, err error) { +func (s *server) SearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { return s.UnimplementedValdServer.UnimplementedSearchServer.SearchByID(ctx, req) } @@ -170,10 +174,14 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er return s.UnimplementedValdServer.UnimplementedSearchServer.StreamSearchByID(stream) } -func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiSearch( + ctx context.Context, reqs *payload.Search_MultiRequest, +) (res *payload.Search_Responses, errs error) { return s.UnimplementedValdServer.UnimplementedSearchServer.MultiSearch(ctx, reqs) } -func (s *server) MultiSearchByID(ctx context.Context, reqs *payload.Search_MultiIDRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiSearchByID( + ctx context.Context, reqs *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, errs error) { return s.UnimplementedValdServer.UnimplementedSearchServer.MultiSearchByID(ctx, reqs) } diff --git a/pkg/agent/core/faiss/handler/grpc/search_test.go b/pkg/agent/core/faiss/handler/grpc/search_test.go new file mode 100644 index 0000000000..0c9f982e97 --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/search_test.go @@ -0,0 +1,776 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_Search(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Search_Request +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.Search(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_SearchByID(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Search_IDRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.SearchByID(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamSearch(t *testing.T) { +// type args struct { +// stream vald.Search_StreamSearchServer +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamSearch(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamSearchByID(t *testing.T) { +// type args struct { +// stream vald.Search_StreamSearchByIDServer +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamSearchByID(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiSearch(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Search_MultiRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Search_Responses +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Search_Responses, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.MultiSearch(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiSearchByID(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Search_MultiIDRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Search_Responses +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Search_Responses, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.MultiSearchByID(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/update.go b/pkg/agent/core/faiss/handler/grpc/update.go index ca5b4f371d..da7d95edc6 100644 --- a/pkg/agent/core/faiss/handler/grpc/update.go +++ b/pkg/agent/core/faiss/handler/grpc/update.go @@ -27,11 +27,13 @@ import ( "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "github.com/vdaas/vald/internal/observability/trace" - "go.opentelemetry.io/otel/attribute" ) -func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res *payload.Object_Location, err error) { +func (s *server) Update( + ctx context.Context, req *payload.Update_Request, +) (res *payload.Object_Location, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.UpdateRPCName) defer func() { if span != nil { @@ -168,6 +170,8 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) return s.UnimplementedValdServer.UnimplementedUpdateServer.StreamUpdate(stream) } -func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequest) (res *payload.Object_Locations, err error) { +func (s *server) MultiUpdate( + ctx context.Context, reqs *payload.Update_MultiRequest, +) (res *payload.Object_Locations, err error) { return s.UnimplementedValdServer.UnimplementedUpdateServer.MultiUpdate(ctx, reqs) } diff --git a/pkg/agent/core/faiss/handler/grpc/update_test.go b/pkg/agent/core/faiss/handler/grpc/update_test.go new file mode 100644 index 0000000000..90d3ed9476 --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/update_test.go @@ -0,0 +1,396 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_Update(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Update_Request +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Object_Location +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Location, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.Update(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamUpdate(t *testing.T) { +// type args struct { +// stream vald.Update_StreamUpdateServer +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamUpdate(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiUpdate(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Update_MultiRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Object_Locations +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.MultiUpdate(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/upsert.go b/pkg/agent/core/faiss/handler/grpc/upsert.go index 38675e58c9..1d78d7a7d4 100644 --- a/pkg/agent/core/faiss/handler/grpc/upsert.go +++ b/pkg/agent/core/faiss/handler/grpc/upsert.go @@ -23,7 +23,9 @@ import ( "github.com/vdaas/vald/apis/grpc/v1/vald" ) -func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc *payload.Object_Location, err error) { +func (s *server) Upsert( + ctx context.Context, req *payload.Upsert_Request, +) (loc *payload.Object_Location, err error) { return s.UnimplementedValdServer.UnimplementedUpsertServer.Upsert(ctx, req) } @@ -31,6 +33,8 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) return s.UnimplementedValdServer.UnimplementedUpsertServer.StreamUpsert(stream) } -func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequest) (res *payload.Object_Locations, err error) { +func (s *server) MultiUpsert( + ctx context.Context, reqs *payload.Upsert_MultiRequest, +) (res *payload.Object_Locations, err error) { return s.UnimplementedValdServer.UnimplementedUpsertServer.MultiUpsert(ctx, reqs) } diff --git a/pkg/agent/core/faiss/handler/grpc/upsert_test.go b/pkg/agent/core/faiss/handler/grpc/upsert_test.go new file mode 100644 index 0000000000..dcbe0f2811 --- /dev/null +++ b/pkg/agent/core/faiss/handler/grpc/upsert_test.go @@ -0,0 +1,396 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_Upsert(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Upsert_Request +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantLoc *payload.Object_Location +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotLoc, err := s.Upsert(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotLoc, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamUpsert(t *testing.T) { +// type args struct { +// stream vald.Upsert_StreamUpsertServer +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamUpsert(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiUpsert(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Upsert_MultiRequest +// } +// type fields struct { +// name string +// ip string +// faiss service.Faiss +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Object_Locations +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// faiss:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// faiss: test.fields.faiss, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.MultiUpsert(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/rest/handler.go b/pkg/agent/core/faiss/handler/rest/handler.go index 108e808715..ef1c80bab9 100644 --- a/pkg/agent/core/faiss/handler/rest/handler.go +++ b/pkg/agent/core/faiss/handler/rest/handler.go @@ -59,99 +59,99 @@ func New(opts ...Option) Handler { } func (h *handler) Index(w http.ResponseWriter, r *http.Request) (int, error) { - data := make(map[string]interface{}) - return json.Handler(w, r, &data, func() (interface{}, error) { + data := make(map[string]any) + return json.Handler(w, r, &data, func() (any, error) { return dump.Request(nil, data, r) }) } func (h *handler) Search(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Search(r.Context(), req) }) } func (h *handler) SearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.SearchByID(r.Context(), req) }) } func (h *handler) LinearSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.LinearSearch(r.Context(), req) }) } func (h *handler) LinearSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.LinearSearchByID(r.Context(), req) }) } func (h *handler) Insert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Insert(r.Context(), req) }) } func (h *handler) MultiInsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.MultiInsert(r.Context(), req) }) } func (h *handler) Update(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Update(r.Context(), req) }) } func (h *handler) MultiUpdate(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.MultiUpdate(r.Context(), req) }) } func (h *handler) Remove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Remove(r.Context(), req) }) } func (h *handler) MultiRemove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.MultiRemove(r.Context(), req) }) } func (h *handler) CreateIndex(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Control_CreateIndexRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.CreateIndex(r.Context(), req) }) } func (h *handler) SaveIndex(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Empty - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.SaveIndex(r.Context(), req) }) } func (h *handler) CreateAndSaveIndex(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Control_CreateIndexRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { _, err = h.agent.CreateIndex(r.Context(), req) if err != nil { return nil, err @@ -162,14 +162,14 @@ func (h *handler) CreateAndSaveIndex(w http.ResponseWriter, r *http.Request) (co func (h *handler) GetObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_VectorRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.GetObject(r.Context(), req) }) } func (h *handler) Exists(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_ID - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Exists(r.Context(), req) }) } diff --git a/pkg/agent/core/faiss/handler/rest/handler_test.go b/pkg/agent/core/faiss/handler/rest/handler_test.go new file mode 100644 index 0000000000..4003db5eb9 --- /dev/null +++ b/pkg/agent/core/faiss/handler/rest/handler_test.go @@ -0,0 +1,1781 @@ +// 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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Index(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// want int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// got, err := h.Index(test.args.w, test.args.r) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Search(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Search(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_SearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.SearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.LinearSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.LinearSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Insert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Insert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiInsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.MultiInsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Update(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Update(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpdate(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.MultiUpdate(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Remove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Remove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiRemove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.MultiRemove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_CreateIndex(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.CreateIndex(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_SaveIndex(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.SaveIndex(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_CreateAndSaveIndex(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.CreateAndSaveIndex(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_GetObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.GetObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Exists(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Exists(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/rest/option_test.go b/pkg/agent/core/faiss/handler/rest/option_test.go new file mode 100644 index 0000000000..86d6885330 --- /dev/null +++ b/pkg/agent/core/faiss/handler/rest/option_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestWithAgent(t *testing.T) { +// type args struct { +// a grpc.Server +// } +// 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 { +// a: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 { +// a: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 := WithAgent(test.args.a) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/router/option_test.go b/pkg/agent/core/faiss/router/option_test.go new file mode 100644 index 0000000000..42e073651c --- /dev/null +++ b/pkg/agent/core/faiss/router/option_test.go @@ -0,0 +1,271 @@ +// 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 router + +// NOT IMPLEMENTED BELOW +// +// func TestWithHandler(t *testing.T) { +// type args struct { +// h rest.Handler +// } +// 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 { +// h: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 { +// h: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 := WithHandler(test.args.h) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTimeout(t *testing.T) { +// type args struct { +// timeout 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 { +// timeout:"", +// }, +// 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 { +// timeout:"", +// }, +// 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 := WithTimeout(test.args.timeout) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/router/router_test.go b/pkg/agent/core/faiss/router/router_test.go new file mode 100644 index 0000000000..e9e3069588 --- /dev/null +++ b/pkg/agent/core/faiss/router/router_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 router + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want http.Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, http.Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got http.Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/service/faiss.go b/pkg/agent/core/faiss/service/faiss.go index 3f8a85c744..a5b11e4f7c 100644 --- a/pkg/agent/core/faiss/service/faiss.go +++ b/pkg/agent/core/faiss/service/faiss.go @@ -1270,7 +1270,9 @@ func (f *faiss) Close(ctx context.Context) error { return nil } -func (f *faiss) toSearchResponse(sr []algorithm.SearchResult) (res *payload.Search_Response, err error) { +func (f *faiss) toSearchResponse( + sr []algorithm.SearchResult, +) (res *payload.Search_Response, err error) { if len(sr) == 0 { if f.Len() == 0 { return nil, nil diff --git a/pkg/agent/core/faiss/service/faiss_test.go b/pkg/agent/core/faiss/service/faiss_test.go new file mode 100644 index 0000000000..4911a58c52 --- /dev/null +++ b/pkg/agent/core/faiss/service/faiss_test.go @@ -0,0 +1,8401 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// cfg *config.Faiss +// opts []Option +// } +// type want struct { +// want Faiss +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Faiss, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Faiss, 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 { +// cfg:nil, +// 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 { +// cfg:nil, +// 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.cfg, test.args.opts...) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_initFaiss(t *testing.T) { +// type args struct { +// opts []core.Option +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// opts:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// opts:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.initFaiss(test.args.opts...) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_load(t *testing.T) { +// type args struct { +// ctx context.Context +// path string +// opts []core.Option +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// ctx:nil, +// path:"", +// opts:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// ctx:nil, +// path:"", +// opts:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.load(test.args.ctx, test.args.path, test.args.opts...) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_loadKVS(t *testing.T) { +// type args struct { +// ctx context.Context +// path string +// timeout time.Duration +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// ctx:nil, +// path:"", +// timeout:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// ctx:nil, +// path:"", +// timeout:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.loadKVS(test.args.ctx, test.args.path, test.args.timeout) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_mktmp(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.mktmp() +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want <-chan error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.Start(test.args.ctx) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_Train(t *testing.T) { +// type args struct { +// nb int +// xb []float32 +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// nb:0, +// xb:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// nb:0, +// xb:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.Train(test.args.nb, test.args.xb) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_Insert(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// vec:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// vec:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.Insert(test.args.uuid, test.args.vec) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_InsertWithTime(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// t int64 +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.InsertWithTime(test.args.uuid, test.args.vec, test.args.t) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_insert(t *testing.T) { +// type args struct { +// uuid string +// xb []float32 +// t int64 +// validation bool +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// xb:nil, +// t:0, +// validation:false, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// xb:nil, +// t:0, +// validation:false, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.insert(test.args.uuid, test.args.xb, test.args.t, test.args.validation) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_Update(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// vec:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// vec:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.Update(test.args.uuid, test.args.vec) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_UpdateWithTime(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// t int64 +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.UpdateWithTime(test.args.uuid, test.args.vec, test.args.t) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_update(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// t int64 +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.update(test.args.uuid, test.args.vec, test.args.t) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_readyForUpdate(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// vec:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// vec:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.readyForUpdate(test.args.uuid, test.args.vec) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_CreateIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.CreateIndex(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_SaveIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.SaveIndex(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_saveIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.saveIndex(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_moveAndSwitchSavedData(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.moveAndSwitchSavedData(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_CreateAndSaveIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.CreateAndSaveIndex(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_Search(t *testing.T) { +// type args struct { +// k uint32 +// nq uint32 +// xq []float32 +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// k:0, +// nq:0, +// xq:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// k:0, +// nq:0, +// xq:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// gotRes, err := f.Search(test.args.k, test.args.nq, test.args.xq) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_Delete(t *testing.T) { +// type args struct { +// uuid string +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.Delete(test.args.uuid) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_DeleteWithTime(t *testing.T) { +// type args struct { +// uuid string +// t int64 +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// t:0, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// t:0, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.DeleteWithTime(test.args.uuid, test.args.t) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_delete(t *testing.T) { +// type args struct { +// uuid string +// t int64 +// validation bool +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// uuid:"", +// t:0, +// validation:false, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// t:0, +// validation:false, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.delete(test.args.uuid, test.args.t, test.args.validation) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_Exists(t *testing.T) { +// type args struct { +// uuid string +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want uint32 +// want1 bool +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, uint32, bool) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got uint32, got1 bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// uuid:"", +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// uuid:"", +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got, got1 := f.Exists(test.args.uuid) +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_IsIndexing(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want bool +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, bool) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.IsIndexing() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_IsSaving(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want bool +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, bool) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.IsSaving() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_NumberOfCreateIndexExecution(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want uint64 +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, uint64) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.NumberOfCreateIndexExecution() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_NumberOfProactiveGCExecution(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want uint64 +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, uint64) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.NumberOfProactiveGCExecution() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_gc(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// f.gc() +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_Len(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want uint64 +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, uint64) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.Len() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_InsertVQueueBufferLen(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want uint64 +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, uint64) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.InsertVQueueBufferLen() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_DeleteVQueueBufferLen(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want uint64 +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, uint64) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.DeleteVQueueBufferLen() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_GetDimensionSize(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want int +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got int) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.GetDimensionSize() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_GetTrainSize(t *testing.T) { +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// want int +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got int) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency:0, +// }, +// 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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// got := f.GetTrainSize() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_Close(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// err := f.Close(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_faiss_toSearchResponse(t *testing.T) { +// type args struct { +// sr []algorithm.SearchResult +// } +// type fields struct { +// core core.Faiss +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// addVecs []float32 +// addIds []int64 +// isTrained bool +// trainSize int +// icnt uint64 +// indexing atomic.Value +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// inMem bool +// dim int +// nlist int +// m int +// alen int +// dur time.Duration +// sdur time.Duration +// lim time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// dcd bool +// idelay time.Duration +// kvsdbConcurrency int +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// sr:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 { +// sr:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// addVecs:nil, +// addIds:nil, +// isTrained:false, +// trainSize:0, +// icnt:0, +// indexing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// inMem:false, +// dim:0, +// nlist:0, +// m:0, +// alen:0, +// dur:nil, +// sdur:nil, +// lim:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// dcd:false, +// idelay:nil, +// kvsdbConcurrency: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 +// } +// f := &faiss{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// addVecs: test.fields.addVecs, +// addIds: test.fields.addIds, +// isTrained: test.fields.isTrained, +// trainSize: test.fields.trainSize, +// icnt: test.fields.icnt, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// nlist: test.fields.nlist, +// m: test.fields.m, +// alen: test.fields.alen, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// lim: test.fields.lim, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// dcd: test.fields.dcd, +// idelay: test.fields.idelay, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// } +// +// gotRes, err := f.toSearchResponse(test.args.sr) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/service/option_test.go b/pkg/agent/core/faiss/service/option_test.go new file mode 100644 index 0000000000..c9f4306b33 --- /dev/null +++ b/pkg/agent/core/faiss/service/option_test.go @@ -0,0 +1,1121 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithEnableInMemoryMode(t *testing.T) { +// type args struct { +// enabled 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 { +// enabled: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 { +// enabled: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 := WithEnableInMemoryMode(test.args.enabled) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// 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 TestWithAutoIndexCheckDuration(t *testing.T) { +// type args struct { +// dur 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 { +// dur:"", +// }, +// 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 { +// dur:"", +// }, +// 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 := WithAutoIndexCheckDuration(test.args.dur) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithAutoSaveIndexDuration(t *testing.T) { +// type args struct { +// dur 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 { +// dur:"", +// }, +// 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 { +// dur:"", +// }, +// 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 := WithAutoSaveIndexDuration(test.args.dur) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithAutoIndexDurationLimit(t *testing.T) { +// type args struct { +// dur 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 { +// dur:"", +// }, +// 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 { +// dur:"", +// }, +// 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 := WithAutoIndexDurationLimit(test.args.dur) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithAutoIndexLength(t *testing.T) { +// type args struct { +// l 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 { +// l: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 { +// l: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 := WithAutoIndexLength(test.args.l) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithInitialDelayMaxDuration(t *testing.T) { +// type args struct { +// dur 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 { +// dur:"", +// }, +// 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 { +// dur:"", +// }, +// 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 := WithInitialDelayMaxDuration(test.args.dur) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithMinLoadIndexTimeout(t *testing.T) { +// type args struct { +// dur 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 { +// dur:"", +// }, +// 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 { +// dur:"", +// }, +// 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 := WithMinLoadIndexTimeout(test.args.dur) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithMaxLoadIndexTimeout(t *testing.T) { +// type args struct { +// dur 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 { +// dur:"", +// }, +// 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 { +// dur:"", +// }, +// 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 := WithMaxLoadIndexTimeout(test.args.dur) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithLoadIndexTimeoutFactor(t *testing.T) { +// type args struct { +// dur 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 { +// dur:"", +// }, +// 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 { +// dur:"", +// }, +// 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 := WithLoadIndexTimeoutFactor(test.args.dur) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithProactiveGC(t *testing.T) { +// type args struct { +// enabled 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 { +// enabled: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 { +// enabled: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 := WithProactiveGC(test.args.enabled) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithCopyOnWrite(t *testing.T) { +// type args struct { +// enabled 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 { +// enabled: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 { +// enabled: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 := WithCopyOnWrite(test.args.enabled) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/usecase/agentd_test.go b/pkg/agent/core/faiss/usecase/agentd_test.go new file mode 100644 index 0000000000..1f71c705c1 --- /dev/null +++ b/pkg/agent/core/faiss/usecase/agentd_test.go @@ -0,0 +1,679 @@ +// 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 usecase + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// cfg *config.Data +// } +// type want struct { +// wantR runner.Runner +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, runner.Runner, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotR runner.Runner, 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(gotR, w.wantR) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotR, w.wantR) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// cfg: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 { +// cfg: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 +// } +// +// gotR, err := New(test.args.cfg) +// if err := checkFunc(test.want, gotR, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// faiss service.Faiss +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// faiss: test.fields.faiss, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// faiss service.Faiss +// server starter.Server +// observability observability.Observability +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// faiss: test.fields.faiss, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// faiss service.Faiss +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// faiss: test.fields.faiss, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PreStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// faiss service.Faiss +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// faiss: test.fields.faiss, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// faiss service.Faiss +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// faiss:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// faiss: test.fields.faiss, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PostStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/ngt/handler/grpc/flush.go b/pkg/agent/core/ngt/handler/grpc/flush.go index cdba112896..a622b1d47e 100644 --- a/pkg/agent/core/ngt/handler/grpc/flush.go +++ b/pkg/agent/core/ngt/handler/grpc/flush.go @@ -25,12 +25,14 @@ import ( "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "github.com/vdaas/vald/internal/observability/trace" - "go.opentelemetry.io/otel/attribute" ) // Flush removes all vectors that are indexed and uncommitted in the `vald-agent`. -func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (*payload.Info_Index_Count, error) { +func (s *server) Flush( + ctx context.Context, req *payload.Flush_Request, +) (*payload.Info_Index_Count, error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.FlushRPCName) defer func() { if span != nil { @@ -84,19 +86,19 @@ func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (*payloa } var ( - stored uint32 - uncommited uint32 - indexing atomic.Value - saving atomic.Value + stored uint32 + uncommitted uint32 + indexing atomic.Value + saving atomic.Value ) stored = 0 - uncommited = 0 + uncommitted = 0 indexing.Store(false) saving.Store(false) cnts := &payload.Info_Index_Count{ Stored: atomic.LoadUint32(&stored), - Uncommitted: atomic.LoadUint32(&uncommited), + Uncommitted: atomic.LoadUint32(&uncommitted), Indexing: indexing.Load().(bool), Saving: saving.Load().(bool), } diff --git a/pkg/agent/core/ngt/handler/grpc/flush_test.go b/pkg/agent/core/ngt/handler/grpc/flush_test.go new file mode 100644 index 0000000000..0abe429c72 --- /dev/null +++ b/pkg/agent/core/ngt/handler/grpc/flush_test.go @@ -0,0 +1,145 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func Test_server_Flush(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Flush_Request +// } +// type fields struct { +// name string +// ip string +// ngt service.NGT +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// want *payload.Info_Index_Count +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Count, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got *payload.Info_Index_Count, 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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// ngt: test.fields.ngt, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// got, err := s.Flush(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/ngt/handler/grpc/handler_test.go b/pkg/agent/core/ngt/handler/grpc/handler_test.go index e6efdfaf75..5f6d714c72 100644 --- a/pkg/agent/core/ngt/handler/grpc/handler_test.go +++ b/pkg/agent/core/ngt/handler/grpc/handler_test.go @@ -39,8 +39,17 @@ func TestMain(m *testing.M) { goleak.VerifyTestMain(m) } -func newIndexedNGTService(ctx context.Context, eg errgroup.Group, t request.ObjectType, dist vector.Distribution, num int, insertCfg *payload.Insert_Config, - ngtCfg *config.NGT, ngtOpts []service.Option, overwriteIDs []string, overwriteVectors [][]float32, +func newIndexedNGTService( + ctx context.Context, + eg errgroup.Group, + t request.ObjectType, + dist vector.Distribution, + num int, + insertCfg *payload.Insert_Config, + ngtCfg *config.NGT, + ngtOpts []service.Option, + overwriteIDs []string, + overwriteVectors [][]float32, ) (service.NGT, error) { ngt, err := service.New(ngtCfg, append(ngtOpts, service.WithErrGroup(eg), service.WithEnableInMemoryMode(true))...) if err != nil { @@ -167,7 +176,250 @@ func newIndexedNGTService(ctx context.Context, eg errgroup.Group, t request.Obje // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_server_newLocations(t *testing.T) { +// type args struct { +// uuids []string +// } +// type fields struct { +// name string +// ip string +// ngt service.NGT +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantLocs *payload.Object_Locations +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations) error { +// if !reflect.DeepEqual(gotLocs, w.wantLocs) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// uuids:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// uuids:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// ngt: test.fields.ngt, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotLocs := s.newLocations(test.args.uuids...) +// if err := checkFunc(test.want, gotLocs); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_newLocation(t *testing.T) { +// type args struct { +// uuid string +// } +// type fields struct { +// name string +// ip string +// ngt service.NGT +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// want *payload.Object_Location +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got *payload.Object_Location) 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 { +// uuid:"", +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// uuid:"", +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// ngt: test.fields.ngt, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// got := s.newLocation(test.args.uuid) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/agent/core/ngt/handler/grpc/index.go b/pkg/agent/core/ngt/handler/grpc/index.go index 7641446500..3a55be3983 100644 --- a/pkg/agent/core/ngt/handler/grpc/index.go +++ b/pkg/agent/core/ngt/handler/grpc/index.go @@ -27,7 +27,9 @@ import ( "github.com/vdaas/vald/internal/observability/trace" ) -func (s *server) CreateIndex(ctx context.Context, c *payload.Control_CreateIndexRequest) (res *payload.Empty, err error) { +func (s *server) CreateIndex( + ctx context.Context, c *payload.Control_CreateIndexRequest, +) (res *payload.Empty, err error) { ctx, span := trace.StartSpan(ctx, apiName+".CreateIndex") defer func() { if span != nil { @@ -39,7 +41,7 @@ func (s *server) CreateIndex(ctx context.Context, c *payload.Control_CreateIndex if err != nil { var ( code codes.Code - details = []interface{}{ + details = []any{ &errdetails.RequestInfo{ ServingData: errdetails.Serialize(c), }, @@ -110,7 +112,9 @@ func (s *server) SaveIndex(ctx context.Context, _ *payload.Empty) (res *payload. return res, nil } -func (s *server) CreateAndSaveIndex(ctx context.Context, c *payload.Control_CreateIndexRequest) (res *payload.Empty, err error) { +func (s *server) CreateAndSaveIndex( + ctx context.Context, c *payload.Control_CreateIndexRequest, +) (res *payload.Empty, err error) { ctx, span := trace.StartSpan(ctx, apiName+".CreateAndSaveIndex") defer func() { if span != nil { @@ -122,7 +126,7 @@ func (s *server) CreateAndSaveIndex(ctx context.Context, c *payload.Control_Crea if err != nil { var ( code codes.Code - details = []interface{}{ + details = []any{ &errdetails.RequestInfo{ ServingData: errdetails.Serialize(c), }, @@ -165,7 +169,9 @@ func (s *server) CreateAndSaveIndex(ctx context.Context, c *payload.Control_Crea return res, nil } -func (s *server) IndexInfo(ctx context.Context, _ *payload.Empty) (res *payload.Info_Index_Count, err error) { +func (s *server) IndexInfo( + ctx context.Context, _ *payload.Empty, +) (res *payload.Info_Index_Count, err error) { _, span := trace.StartSpan(ctx, apiName+".IndexInfo") defer func() { if span != nil { @@ -179,3 +185,58 @@ func (s *server) IndexInfo(ctx context.Context, _ *payload.Empty) (res *payload. Saving: s.ngt.IsSaving(), }, nil } + +func (s *server) IndexDetail( + ctx context.Context, _ *payload.Empty, +) (res *payload.Info_Index_Detail, err error) { + _, span := trace.StartSpan(ctx, apiName+".IndexDetail") + defer func() { + if span != nil { + span.End() + } + }() + res = &payload.Info_Index_Detail{ + Counts: make(map[string]*payload.Info_Index_Count), + Replica: 1, + LiveAgents: 1, + } + res.Counts[s.name] = &payload.Info_Index_Count{ + Stored: uint32(s.ngt.Len()), + Uncommitted: uint32(s.ngt.InsertVQueueBufferLen() + s.ngt.DeleteVQueueBufferLen()), + Indexing: s.ngt.IsIndexing(), + Saving: s.ngt.IsSaving(), + } + return res, nil +} + +func (s *server) IndexStatistics( + ctx context.Context, _ *payload.Empty, +) (res *payload.Info_Index_Statistics, err error) { + _, span := trace.StartSpan(ctx, apiName+".IndexStatistics") + defer func() { + if span != nil { + span.End() + } + }() + return s.ngt.IndexStatistics() +} + +func (s *server) IndexStatisticsDetail( + ctx context.Context, _ *payload.Empty, +) (res *payload.Info_Index_StatisticsDetail, err error) { + _, span := trace.StartSpan(ctx, apiName+".IndexStatisticsDetail") + defer func() { + if span != nil { + span.End() + } + }() + stats, err := s.ngt.IndexStatistics() + if err != nil { + return nil, err + } + return &payload.Info_Index_StatisticsDetail{ + Details: map[string]*payload.Info_Index_Statistics{ + s.name: stats, + }, + }, nil +} diff --git a/pkg/agent/core/ngt/handler/grpc/index_test.go b/pkg/agent/core/ngt/handler/grpc/index_test.go index 1c2452aa86..14b814e004 100644 --- a/pkg/agent/core/ngt/handler/grpc/index_test.go +++ b/pkg/agent/core/ngt/handler/grpc/index_test.go @@ -2474,3 +2474,390 @@ func Test_server_IndexInfo(t *testing.T) { } // NOT IMPLEMENTED BELOW +// +// func Test_server_IndexDetail(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 *payload.Empty +// } +// type fields struct { +// name string +// ip string +// ngt service.NGT +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Info_Index_Detail +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Detail, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Detail, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// ngt: test.fields.ngt, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.IndexDetail(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_IndexStatistics(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 *payload.Empty +// } +// type fields struct { +// name string +// ip string +// ngt service.NGT +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Info_Index_Statistics +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Statistics, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Statistics, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// ngt: test.fields.ngt, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.IndexStatistics(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_IndexStatisticsDetail(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 *payload.Empty +// } +// type fields struct { +// name string +// ip string +// ngt service.NGT +// eg errgroup.Group +// streamConcurrency int +// UnimplementedAgentServer agent.UnimplementedAgentServer +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Info_Index_StatisticsDetail +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_StatisticsDetail, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_StatisticsDetail, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// name:"", +// ip:"", +// ngt:nil, +// eg:nil, +// streamConcurrency:0, +// UnimplementedAgentServer:nil, +// UnimplementedValdServer: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 +// } +// s := &server{ +// name: test.fields.name, +// ip: test.fields.ip, +// ngt: test.fields.ngt, +// eg: test.fields.eg, +// streamConcurrency: test.fields.streamConcurrency, +// UnimplementedAgentServer: test.fields.UnimplementedAgentServer, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.IndexStatisticsDetail(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/ngt/handler/grpc/insert.go b/pkg/agent/core/ngt/handler/grpc/insert.go index d4be3907c9..ed46791b4e 100644 --- a/pkg/agent/core/ngt/handler/grpc/insert.go +++ b/pkg/agent/core/ngt/handler/grpc/insert.go @@ -26,13 +26,15 @@ import ( "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "github.com/vdaas/vald/internal/observability/trace" "github.com/vdaas/vald/internal/strings" - "go.opentelemetry.io/otel/attribute" ) // Insert inserts a vector to the NGT. -func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (res *payload.Object_Location, err error) { +func (s *server) Insert( + ctx context.Context, req *payload.Insert_Request, +) (res *payload.Object_Location, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.InsertRPCName) defer func() { if span != nil { @@ -190,7 +192,9 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) return nil } -func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequest) (res *payload.Object_Locations, err error) { +func (s *server) MultiInsert( + ctx context.Context, reqs *payload.Insert_MultiRequest, +) (res *payload.Object_Locations, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.MultiInsertRPCName) defer func() { if span != nil { diff --git a/pkg/agent/core/ngt/handler/grpc/insert_test.go b/pkg/agent/core/ngt/handler/grpc/insert_test.go index 1bb8f4af41..fa223ca69d 100644 --- a/pkg/agent/core/ngt/handler/grpc/insert_test.go +++ b/pkg/agent/core/ngt/handler/grpc/insert_test.go @@ -2654,7 +2654,7 @@ func Test_server_StreamInsert(t *testing.T) { ContextFunc: func() context.Context { return ctx }, - RecvMsgFunc: func(i interface{}) error { + RecvMsgFunc: func(i any) error { if recvIdx >= len(insertReqs) { return io.EOF } @@ -2668,7 +2668,7 @@ func Test_server_StreamInsert(t *testing.T) { return nil }, - SendMsgFunc: func(i interface{}) error { + SendMsgFunc: func(i any) error { rpcResp = append(rpcResp, i.(*payload.Object_StreamLocation)) return nil }, diff --git a/pkg/agent/core/ngt/handler/grpc/linear_search.go b/pkg/agent/core/ngt/handler/grpc/linear_search.go index abe0d374cd..1c13861428 100644 --- a/pkg/agent/core/ngt/handler/grpc/linear_search.go +++ b/pkg/agent/core/ngt/handler/grpc/linear_search.go @@ -26,14 +26,16 @@ import ( "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "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" - "go.opentelemetry.io/otel/attribute" ) -func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) LinearSearch( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.LinearSearchRPCName) defer func() { if span != nil { @@ -171,7 +173,9 @@ func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) return res, nil } -func (s *server) LinearSearchByID(ctx context.Context, req *payload.Search_IDRequest) (res *payload.Search_Response, err error) { +func (s *server) LinearSearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.LinearSearchByIDRPCName) defer func() { if span != nil { @@ -371,7 +375,9 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) return nil } -func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByIDServer) (err error) { +func (s *server) StreamLinearSearchByID( + stream vald.Search_StreamLinearSearchByIDServer, +) (err error) { ctx, span := trace.StartSpan(stream.Context(), apiName+"/"+vald.StreamLinearSearchByIDRPCName) defer func() { if span != nil { @@ -418,7 +424,9 @@ func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByI return nil } -func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_MultiRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiLinearSearch( + ctx context.Context, reqs *payload.Search_MultiRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.MultiLinearSearchRPCName) defer func() { if span != nil { @@ -492,7 +500,9 @@ func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_Mul return res, nil } -func (s *server) MultiLinearSearchByID(ctx context.Context, reqs *payload.Search_MultiIDRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiLinearSearchByID( + ctx context.Context, reqs *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.MultiLinearSearchByIDRPCName) defer func() { if span != nil { diff --git a/pkg/agent/core/ngt/handler/grpc/linear_search_test.go b/pkg/agent/core/ngt/handler/grpc/linear_search_test.go index acd25db5ae..85ecd233eb 100644 --- a/pkg/agent/core/ngt/handler/grpc/linear_search_test.go +++ b/pkg/agent/core/ngt/handler/grpc/linear_search_test.go @@ -140,7 +140,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -270,7 +269,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -393,7 +391,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -516,7 +513,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -646,7 +642,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -776,7 +771,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/core/ngt/handler/grpc/object.go b/pkg/agent/core/ngt/handler/grpc/object.go index ea7ec38b3d..e55c19963b 100644 --- a/pkg/agent/core/ngt/handler/grpc/object.go +++ b/pkg/agent/core/ngt/handler/grpc/object.go @@ -29,7 +29,9 @@ import ( "github.com/vdaas/vald/internal/sync" ) -func (s *server) Exists(ctx context.Context, uid *payload.Object_ID) (res *payload.Object_ID, err error) { +func (s *server) Exists( + ctx context.Context, uid *payload.Object_ID, +) (res *payload.Object_ID, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.ExistsRPCName) defer func() { if span != nil { @@ -77,7 +79,9 @@ func (s *server) Exists(ctx context.Context, uid *payload.Object_ID) (res *paylo return uid, nil } -func (s *server) GetObject(ctx context.Context, id *payload.Object_VectorRequest) (res *payload.Object_Vector, err error) { +func (s *server) GetObject( + ctx context.Context, id *payload.Object_VectorRequest, +) (res *payload.Object_Vector, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.GetObjectRPCName) defer func() { if span != nil { @@ -179,7 +183,9 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err return nil } -func (s *server) StreamListObject(_ *payload.Object_List_Request, stream vald.Object_StreamListObjectServer) (err error) { +func (s *server) StreamListObject( + _ *payload.Object_List_Request, stream vald.Object_StreamListObjectServer, +) (err error) { ctx, span := trace.StartSpan(stream.Context(), apiName+"/"+vald.StreamListObjectRPCName) defer func() { if span != nil { @@ -255,7 +261,9 @@ func (s *server) StreamListObject(_ *payload.Object_List_Request, stream vald.Ob // GetTimestamp returns meta information of the object specified by uuid. // This rpc is only served in AgentServer and not served in LB. Only for internal use mainly for index correction to reduce // network bandwidth(because vector itself is not required for index correction logic) while processing. -func (s *server) GetTimestamp(ctx context.Context, id *payload.Object_GetTimestampRequest) (res *payload.Object_Timestamp, err error) { +func (s *server) GetTimestamp( + ctx context.Context, id *payload.Object_TimestampRequest, +) (res *payload.Object_Timestamp, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.GetTimestampRPCName) defer func() { if span != nil { diff --git a/pkg/agent/core/ngt/handler/grpc/object_test.go b/pkg/agent/core/ngt/handler/grpc/object_test.go index f4f3f25699..39b5521bbb 100644 --- a/pkg/agent/core/ngt/handler/grpc/object_test.go +++ b/pkg/agent/core/ngt/handler/grpc/object_test.go @@ -1401,7 +1401,7 @@ func Test_server_GetTimestamp(t *testing.T) { // now test if the timestamp can be returned correctly for i := 0; i < num; i++ { testvec := req.GetRequests()[i].GetVector() - res, err := s.GetTimestamp(ectx, &payload.Object_GetTimestampRequest{ + res, err := s.GetTimestamp(ectx, &payload.Object_TimestampRequest{ Id: &payload.Object_ID{ Id: testvec.GetId(), }, @@ -1417,7 +1417,7 @@ func Test_server_GetTimestamp(t *testing.T) { eg, ectx, s := setup(t) defer eg.Wait() - _, err := s.GetTimestamp(ectx, &payload.Object_GetTimestampRequest{ + _, err := s.GetTimestamp(ectx, &payload.Object_TimestampRequest{ Id: &payload.Object_ID{ Id: "", }, @@ -1431,7 +1431,7 @@ func Test_server_GetTimestamp(t *testing.T) { eg, ectx, s := setup(t) defer eg.Wait() - _, err := s.GetTimestamp(ectx, &payload.Object_GetTimestampRequest{ + _, err := s.GetTimestamp(ectx, &payload.Object_TimestampRequest{ Id: &payload.Object_ID{ Id: "not exist ID", }, @@ -1573,7 +1573,6 @@ func Test_server_GetTimestamp(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/core/ngt/handler/grpc/remove.go b/pkg/agent/core/ngt/handler/grpc/remove.go index f57685bbb1..b246b2434c 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove.go +++ b/pkg/agent/core/ngt/handler/grpc/remove.go @@ -26,13 +26,15 @@ import ( "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "github.com/vdaas/vald/internal/observability/trace" "github.com/vdaas/vald/internal/strings" "github.com/vdaas/vald/internal/sync" - "go.opentelemetry.io/otel/attribute" ) -func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (res *payload.Object_Location, err error) { +func (s *server) Remove( + ctx context.Context, req *payload.Remove_Request, +) (res *payload.Object_Location, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.RemoveRPCName) defer func() { if span != nil { @@ -185,7 +187,9 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) return nil } -func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequest) (res *payload.Object_Locations, err error) { +func (s *server) MultiRemove( + ctx context.Context, reqs *payload.Remove_MultiRequest, +) (res *payload.Object_Locations, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.MultiRemoveRPCName) defer func() { if span != nil { @@ -274,7 +278,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ return s.newLocations(uuids...), nil } -func (s *server) RemoveByTimestamp(ctx context.Context, req *payload.Remove_TimestampRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) RemoveByTimestamp( + ctx context.Context, req *payload.Remove_TimestampRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.RemoveByTimestampRPCName) defer func() { if span != nil { diff --git a/pkg/agent/core/ngt/handler/grpc/remove_test.go b/pkg/agent/core/ngt/handler/grpc/remove_test.go index b6fcd1d3b5..92732f8e9b 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove_test.go +++ b/pkg/agent/core/ngt/handler/grpc/remove_test.go @@ -1111,7 +1111,6 @@ func Test_timestampOpFunc(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1241,7 +1240,6 @@ func Test_timestampOpFunc(t *testing.T) { // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/core/ngt/handler/grpc/search.go b/pkg/agent/core/ngt/handler/grpc/search.go index 3c0e43dc84..6543fd9ced 100644 --- a/pkg/agent/core/ngt/handler/grpc/search.go +++ b/pkg/agent/core/ngt/handler/grpc/search.go @@ -26,14 +26,16 @@ import ( "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "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" - "go.opentelemetry.io/otel/attribute" ) -func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) Search( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.SearchRPCName) defer func() { if span != nil { @@ -173,7 +175,9 @@ func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res * return res, nil } -func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) (res *payload.Search_Response, err error) { +func (s *server) SearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.SearchByIDRPCName) defer func() { if span != nil { @@ -422,7 +426,9 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er return nil } -func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiSearch( + ctx context.Context, reqs *payload.Search_MultiRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.MultiSearchRPCName) defer func() { if span != nil { @@ -496,7 +502,9 @@ func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequ return res, nil } -func (s *server) MultiSearchByID(ctx context.Context, reqs *payload.Search_MultiIDRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiSearchByID( + ctx context.Context, reqs *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.MultiSearchByIDRPCName) defer func() { if span != nil { diff --git a/pkg/agent/core/ngt/handler/grpc/search_test.go b/pkg/agent/core/ngt/handler/grpc/search_test.go index d8b47067dc..936998bdce 100644 --- a/pkg/agent/core/ngt/handler/grpc/search_test.go +++ b/pkg/agent/core/ngt/handler/grpc/search_test.go @@ -1260,7 +1260,6 @@ func Test_server_SearchByID(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1383,7 +1382,6 @@ func Test_server_SearchByID(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1513,7 +1511,6 @@ func Test_server_SearchByID(t *testing.T) { // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1643,7 +1640,6 @@ func Test_server_SearchByID(t *testing.T) { // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/core/ngt/handler/grpc/update.go b/pkg/agent/core/ngt/handler/grpc/update.go index 0a76d7395f..b650c15e83 100644 --- a/pkg/agent/core/ngt/handler/grpc/update.go +++ b/pkg/agent/core/ngt/handler/grpc/update.go @@ -26,12 +26,14 @@ import ( "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" + "github.com/vdaas/vald/internal/observability/attribute" "github.com/vdaas/vald/internal/observability/trace" "github.com/vdaas/vald/internal/strings" - "go.opentelemetry.io/otel/attribute" ) -func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res *payload.Object_Location, err error) { +func (s *server) Update( + ctx context.Context, req *payload.Update_Request, +) (res *payload.Object_Location, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.UpdateRPCName) defer func() { if span != nil { @@ -219,7 +221,9 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) return nil } -func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequest) (res *payload.Object_Locations, err error) { +func (s *server) MultiUpdate( + ctx context.Context, reqs *payload.Update_MultiRequest, +) (res *payload.Object_Locations, err error) { _, span := trace.StartSpan(ctx, apiName+"/"+vald.MultiUpdateRPCName) defer func() { if span != nil { diff --git a/pkg/agent/core/ngt/handler/grpc/update_test.go b/pkg/agent/core/ngt/handler/grpc/update_test.go index 97ce5daa7c..c2ef660f30 100644 --- a/pkg/agent/core/ngt/handler/grpc/update_test.go +++ b/pkg/agent/core/ngt/handler/grpc/update_test.go @@ -985,7 +985,6 @@ func Test_server_Update(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1115,7 +1114,6 @@ func Test_server_Update(t *testing.T) { // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/core/ngt/handler/grpc/upsert.go b/pkg/agent/core/ngt/handler/grpc/upsert.go index e1b39609dc..9bf49a2ea4 100644 --- a/pkg/agent/core/ngt/handler/grpc/upsert.go +++ b/pkg/agent/core/ngt/handler/grpc/upsert.go @@ -32,7 +32,9 @@ import ( "github.com/vdaas/vald/internal/sync" ) -func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc *payload.Object_Location, err error) { +func (s *server) Upsert( + ctx context.Context, req *payload.Upsert_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.UpsertRPCName) defer func() { if span != nil { @@ -180,7 +182,9 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) return nil } -func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequest) (res *payload.Object_Locations, err error) { +func (s *server) MultiUpsert( + ctx context.Context, reqs *payload.Upsert_MultiRequest, +) (res *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.MultiUpsertRPCName) defer func() { if span != nil { diff --git a/pkg/agent/core/ngt/handler/grpc/upsert_test.go b/pkg/agent/core/ngt/handler/grpc/upsert_test.go index abb06a0cee..90e671f698 100644 --- a/pkg/agent/core/ngt/handler/grpc/upsert_test.go +++ b/pkg/agent/core/ngt/handler/grpc/upsert_test.go @@ -1709,7 +1709,6 @@ func Test_server_Upsert(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1839,7 +1838,6 @@ func Test_server_Upsert(t *testing.T) { // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/core/ngt/handler/rest/handler.go b/pkg/agent/core/ngt/handler/rest/handler.go index b6594a2b49..310bbb2fd7 100644 --- a/pkg/agent/core/ngt/handler/rest/handler.go +++ b/pkg/agent/core/ngt/handler/rest/handler.go @@ -59,99 +59,99 @@ func New(opts ...Option) Handler { } func (*handler) Index(w http.ResponseWriter, r *http.Request) (int, error) { - data := make(map[string]interface{}) - return json.Handler(w, r, &data, func() (interface{}, error) { + data := make(map[string]any) + return json.Handler(w, r, &data, func() (any, error) { return dump.Request(nil, data, r) }) } func (h *handler) Search(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Search(r.Context(), req) }) } func (h *handler) SearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.SearchByID(r.Context(), req) }) } func (h *handler) LinearSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.LinearSearch(r.Context(), req) }) } func (h *handler) LinearSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.LinearSearchByID(r.Context(), req) }) } func (h *handler) Insert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Insert(r.Context(), req) }) } func (h *handler) MultiInsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.MultiInsert(r.Context(), req) }) } func (h *handler) Update(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Update(r.Context(), req) }) } func (h *handler) MultiUpdate(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.MultiUpdate(r.Context(), req) }) } func (h *handler) Remove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Remove(r.Context(), req) }) } func (h *handler) MultiRemove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.MultiRemove(r.Context(), req) }) } func (h *handler) CreateIndex(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Control_CreateIndexRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.CreateIndex(r.Context(), req) }) } func (h *handler) SaveIndex(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Empty - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.SaveIndex(r.Context(), req) }) } func (h *handler) CreateAndSaveIndex(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Control_CreateIndexRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { _, err = h.agent.CreateIndex(r.Context(), req) if err != nil { return nil, err @@ -162,14 +162,14 @@ func (h *handler) CreateAndSaveIndex(w http.ResponseWriter, r *http.Request) (co func (h *handler) GetObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_VectorRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.GetObject(r.Context(), req) }) } func (h *handler) Exists(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_ID - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.agent.Exists(r.Context(), req) }) } diff --git a/pkg/agent/core/ngt/handler/rest/handler_test.go b/pkg/agent/core/ngt/handler/rest/handler_test.go new file mode 100644 index 0000000000..4003db5eb9 --- /dev/null +++ b/pkg/agent/core/ngt/handler/rest/handler_test.go @@ -0,0 +1,1781 @@ +// 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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Index(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// want int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// got, err := h.Index(test.args.w, test.args.r) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Search(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Search(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_SearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.SearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.LinearSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.LinearSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Insert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Insert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiInsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.MultiInsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Update(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Update(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpdate(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.MultiUpdate(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Remove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Remove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiRemove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.MultiRemove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_CreateIndex(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.CreateIndex(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_SaveIndex(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.SaveIndex(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_CreateAndSaveIndex(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.CreateAndSaveIndex(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_GetObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.GetObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Exists(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// agent grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// agent: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 +// } +// h := &handler{ +// agent: test.fields.agent, +// } +// +// gotCode, err := h.Exists(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/ngt/handler/rest/option_test.go b/pkg/agent/core/ngt/handler/rest/option_test.go new file mode 100644 index 0000000000..86d6885330 --- /dev/null +++ b/pkg/agent/core/ngt/handler/rest/option_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestWithAgent(t *testing.T) { +// type args struct { +// a grpc.Server +// } +// 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 { +// a: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 { +// a: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 := WithAgent(test.args.a) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/ngt/service/ngt.go b/pkg/agent/core/ngt/service/ngt.go index f1e1a80902..ba0c11319a 100644 --- a/pkg/agent/core/ngt/service/ngt.go +++ b/pkg/agent/core/ngt/service/ngt.go @@ -89,8 +89,10 @@ type NGT interface { DeleteVQueueBufferLen() uint64 InsertVQueueBufferLen() uint64 GetDimensionSize() int - Close(ctx context.Context) error BrokenIndexCount() uint64 + IndexStatistics() (*payload.Info_Index_Statistics, error) + IsStatisticsEnabled() bool + Close(ctx context.Context) error } type ngt struct { @@ -160,6 +162,9 @@ type ngt struct { enableExportIndexInfo bool exportIndexInfoDuration time.Duration patcher client.Patcher + + enableStatistics bool + statisticsCache atomic.Pointer[payload.Info_Index_Statistics] } const ( @@ -177,7 +182,7 @@ const ( lastTimeSaveIndexTimestampAnnotationsKey = "vald.vdaas.org/last-time-save-index-timestamp" indexCountAnnotationsKey = "vald.vdaas.org/index-count" - // use this only for tests. usually just leave the ctx value empty and let time.Now() be used + // use this only for tests. usually just leave the ctx value empty and let time.Now() be used. saveIndexTimeKey contextSaveIndexTimeKey = "saveIndexTimeKey" ) @@ -924,7 +929,9 @@ func (n *ngt) Start(ctx context.Context) <-chan error { return ech } -func (n *ngt) Search(ctx context.Context, vec []float32, size uint32, epsilon, radius float32) (res *payload.Search_Response, err error) { +func (n *ngt) Search( + ctx context.Context, vec []float32, size uint32, epsilon, radius float32, +) (res *payload.Search_Response, err error) { if n.IsFlushing() { return nil, errors.ErrFlushingIsInProgress } @@ -946,7 +953,9 @@ func (n *ngt) Search(ctx context.Context, vec []float32, size uint32, epsilon, r return n.toSearchResponse(sr) } -func (n *ngt) SearchByID(ctx context.Context, uuid string, size uint32, epsilon, radius float32) (vec []float32, dst *payload.Search_Response, err error) { +func (n *ngt) SearchByID( + ctx context.Context, uuid string, size uint32, epsilon, radius float32, +) (vec []float32, dst *payload.Search_Response, err error) { if n.IsFlushing() { return nil, nil, errors.ErrFlushingIsInProgress } @@ -964,7 +973,9 @@ func (n *ngt) SearchByID(ctx context.Context, uuid string, size uint32, epsilon, return vec, dst, nil } -func (n *ngt) LinearSearch(ctx context.Context, vec []float32, size uint32) (res *payload.Search_Response, err error) { +func (n *ngt) LinearSearch( + ctx context.Context, vec []float32, size uint32, +) (res *payload.Search_Response, err error) { if n.IsFlushing() { return nil, errors.ErrFlushingIsInProgress } @@ -986,7 +997,9 @@ func (n *ngt) LinearSearch(ctx context.Context, vec []float32, size uint32) (res return n.toSearchResponse(sr) } -func (n *ngt) LinearSearchByID(ctx context.Context, uuid string, size uint32) (vec []float32, dst *payload.Search_Response, err error) { +func (n *ngt) LinearSearchByID( + ctx context.Context, uuid string, size uint32, +) (vec []float32, dst *payload.Search_Response, err error) { if n.IsFlushing() { return nil, nil, errors.ErrFlushingIsInProgress } @@ -1228,26 +1241,34 @@ func (n *ngt) RegenerateIndexes(ctx context.Context) (err error) { if err != nil { log.Errorf("failed to flushing vector to ngt index in delete kvs. error: %v", err) } - n.kvs = kvs.New(kvs.WithConcurrency(n.kvsdbConcurrency)) - - n.vq, err = vqueue.New() + n.kvs = nil + n.vq = nil // gc runtime.GC() atomic.AddUint64(&n.nogce, 1) - // delete file - err = file.DeleteDir(ctx, n.path) - if err != nil { - log.Errorf("failed to flushing vector to ngt index in delete file. error: %v", err) - } - - // delete cow - if n.enableCopyOnWrite { - err := file.DeleteDir(ctx, n.oldPath) + if n.inMem { + // delete file + err = file.DeleteDir(ctx, n.path) if err != nil { - log.Errorf("failed to flushing vector to ngt index in delete file. error: %v", err) + log.Errorf("failed to flushing vector to ngt index in delete file.\tpath: '%s', error: %v", n.path, err) } + + // delete cow + if n.enableCopyOnWrite { + err := file.DeleteDir(ctx, n.oldPath) + if err != nil { + log.Errorf("failed to flushing vector to ngt index in delete file.\tpath: '%s', error: %v", n.oldPath, err) + } + } + } + + nkvs := kvs.New(kvs.WithConcurrency(n.kvsdbConcurrency)) + + nvq, err := vqueue.New() + if err != nil { + log.Errorf("failed to create new vector vector queue. error: %v", err) } // renew instance @@ -1255,9 +1276,15 @@ func (n *ngt) RegenerateIndexes(ctx context.Context) (err error) { if err != nil { return err } + nn.kvs = nkvs + nn.vq = nvq + // Regenerate with flags set nn.flushing.Store(true) nn.indexing.Store(true) + defer nn.flushing.Store(false) + defer nn.indexing.Store(false) + n = nn return nil @@ -1400,6 +1427,50 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) { return err } } + if n.IsStatisticsEnabled() { + log.Info("loading index statistics to cache") + stats, err := n.core.GetGraphStatistics(core.AdditionalStatistics) + if err != nil { + log.Errorf("failed to load index statistics to cache: %v", err) + return err + } + n.statisticsCache.Store(&payload.Info_Index_Statistics{ + Valid: stats.Valid, + MedianIndegree: stats.MedianIndegree, + MedianOutdegree: stats.MedianOutdegree, + MaxNumberOfIndegree: stats.MaxNumberOfIndegree, + MaxNumberOfOutdegree: stats.MaxNumberOfOutdegree, + MinNumberOfIndegree: stats.MinNumberOfIndegree, + MinNumberOfOutdegree: stats.MinNumberOfOutdegree, + ModeIndegree: stats.ModeIndegree, + ModeOutdegree: stats.ModeOutdegree, + NodesSkippedFor10Edges: stats.NodesSkippedFor10Edges, + NodesSkippedForIndegreeDistance: stats.NodesSkippedForIndegreeDistance, + NumberOfEdges: stats.NumberOfEdges, + NumberOfIndexedObjects: stats.NumberOfIndexedObjects, + NumberOfNodes: stats.NumberOfNodes, + NumberOfNodesWithoutEdges: stats.NumberOfNodesWithoutEdges, + NumberOfNodesWithoutIndegree: stats.NumberOfNodesWithoutIndegree, + NumberOfObjects: stats.NumberOfObjects, + NumberOfRemovedObjects: stats.NumberOfRemovedObjects, + SizeOfObjectRepository: stats.SizeOfObjectRepository, + SizeOfRefinementObjectRepository: stats.SizeOfRefinementObjectRepository, + VarianceOfIndegree: stats.VarianceOfIndegree, + VarianceOfOutdegree: stats.VarianceOfOutdegree, + MeanEdgeLength: stats.MeanEdgeLength, + MeanEdgeLengthFor10Edges: stats.MeanEdgeLengthFor10Edges, + MeanIndegreeDistanceFor10Edges: stats.MeanIndegreeDistanceFor10Edges, + MeanNumberOfEdgesPerNode: stats.MeanNumberOfEdgesPerNode, + C1Indegree: stats.C1Indegree, + C5Indegree: stats.C5Indegree, + C95Outdegree: stats.C95Outdegree, + C99Outdegree: stats.C99Outdegree, + IndegreeCount: stats.IndegreeCount, + OutdegreeHistogram: stats.OutdegreeHistogram, + IndegreeHistogram: stats.IndegreeHistogram, + }) + } + return err } @@ -1958,7 +2029,24 @@ func (n *ngt) ListObjectFunc(ctx context.Context, f func(uuid string, oid uint32 }) } -func (n *ngt) toSearchResponse(sr []algorithm.SearchResult) (res *payload.Search_Response, err error) { +func (n *ngt) IndexStatistics() (stats *payload.Info_Index_Statistics, err error) { + if !n.IsStatisticsEnabled() { + return nil, errors.ErrNGTIndexStatisticsDisabled + } + stats = n.statisticsCache.Load() + if stats == nil { + return nil, errors.ErrNGTIndexStatisticsNotReady + } + return stats, nil +} + +func (n *ngt) IsStatisticsEnabled() bool { + return n.enableStatistics +} + +func (n *ngt) toSearchResponse( + sr []algorithm.SearchResult, +) (res *payload.Search_Response, err error) { if len(sr) == 0 { if n.Len() == 0 { return nil, nil diff --git a/pkg/agent/core/ngt/service/ngt_stateful_test.go b/pkg/agent/core/ngt/service/ngt_stateful_test.go index 3280bcfb88..5880b836f4 100644 --- a/pkg/agent/core/ngt/service/ngt_stateful_test.go +++ b/pkg/agent/core/ngt/service/ngt_stateful_test.go @@ -1322,7 +1322,7 @@ func rootCommands(t *testing.T) commands.Commands { GenCommandFunc: func(state commands.State) gopter.Gen { st := state.(*ngtState) - cs := make([]interface{}, 0) + cs := make([]any, 0) cs = append( cs, existsACommand, diff --git a/pkg/agent/core/ngt/service/ngt_test.go b/pkg/agent/core/ngt/service/ngt_test.go index 3adcf18726..ce27e440c3 100644 --- a/pkg/agent/core/ngt/service/ngt_test.go +++ b/pkg/agent/core/ngt/service/ngt_test.go @@ -38,6 +38,7 @@ import ( "github.com/vdaas/vald/internal/file" kvald "github.com/vdaas/vald/internal/k8s/vald" "github.com/vdaas/vald/internal/log" + "github.com/vdaas/vald/internal/net/grpc" "github.com/vdaas/vald/internal/safety" "github.com/vdaas/vald/internal/strings" "github.com/vdaas/vald/internal/sync" @@ -50,7 +51,6 @@ import ( "github.com/vdaas/vald/pkg/agent/internal/kvs" "github.com/vdaas/vald/pkg/agent/internal/metadata" "github.com/vdaas/vald/pkg/agent/internal/vqueue" - "google.golang.org/grpc" ) var defaultConfig = config.NGT{ @@ -1556,8 +1556,8 @@ func Test_ngt_E2E(t *testing.T) { type args struct { requests []*payload.Upsert_MultiRequest - addr string - dialOpts []grpc.DialOption + addr string + client grpc.Client } type want struct { err error @@ -1566,16 +1566,9 @@ func Test_ngt_E2E(t *testing.T) { name string args args want want - checkFunc func(want, error) error beforeFunc func(args) afterFunc func(args) } - defaultCheckFunc := func(w want, err error) error { - if !errors.Is(err, w.err) { - return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) - } - return nil - } multiUpsertRequestGenFunc := func(idxes []index, chunk int) (res []*payload.Upsert_MultiRequest) { reqs := make([]*payload.Upsert_Request, 0, chunk) for i := 0; i < len(idxes); i++ { @@ -1612,10 +1605,8 @@ func Test_ngt_E2E(t *testing.T) { createRandomData(500000, new(createRandomDataConfig)), 50, ), - addr: "127.0.0.1:8080", - dialOpts: []grpc.DialOption{ - grpc.WithInsecure(), - }, + addr: "127.0.0.1:8080", + client: grpc.New(grpc.WithInsecure(true)), }, }, } @@ -1633,24 +1624,15 @@ func Test_ngt_E2E(t *testing.T) { if test.afterFunc != nil { defer test.afterFunc(test.args) } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - conn, err := grpc.DialContext(ctx, test.args.addr, test.args.dialOpts...) - if err := checkFunc(test.want, err); err != nil { - t.Fatal(err) - } - defer func() { - if err := conn.Close(); err != nil { - t.Error(err) - } - }() - client := vald.NewValdClient(conn) + + defer test.args.client.Close(ctx) for i := 0; i < 2; i++ { for _, req := range test.args.requests { - _, err := client.MultiUpsert(ctx, req) + _, err := test.args.client.Do(ctx, test.args.addr, + func(ctx context.Context, conn *grpc.ClientConn, opts ...grpc.CallOption) (any, error) { + return vald.NewValdClient(conn).MultiUpsert(ctx, req) + }) if err != nil { t.Error(err) } @@ -1710,63 +1692,254 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // NOT IMPLEMENTED BELOW // -// func Test_ngt_Start(t *testing.T) { +// func Test_newNGT(t *testing.T) { +// type args struct { +// cfg *config.NGT +// opts []Option +// } +// type want struct { +// wantN *ngt +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, *ngt, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotN *ngt, 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(gotN, w.wantN) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotN, w.wantN) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// cfg:nil, +// 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 { +// cfg:nil, +// 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 +// } +// +// gotN, err := newNGT(test.args.cfg, test.args.opts...) +// if err := checkFunc(test.want, gotN, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_migrate(t *testing.T) { +// type args struct { +// 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 -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// want <-chan error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, <-chan error) error +// checkFunc func(want, 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, 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 // } @@ -1785,12 +1958,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -1802,12 +1979,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -1815,6 +1993,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1842,12 +2026,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -1859,12 +2047,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -1872,6 +2061,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1902,119 +2097,134 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.Start(test.args.ctx) -// if err := checkFunc(test.want, got); err != nil { +// err := n.prepareFolders(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_Search(t *testing.T) { +// func Test_ngt_load(t *testing.T) { // type args struct { -// ctx context.Context -// vec []float32 -// size uint32 -// epsilon float32 -// radius float32 +// ctx context.Context +// path string +// opts []core.Option // } // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// wantRes *payload.Search_Response -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, 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, 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 // } // tests := []test{ @@ -2024,10 +2234,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// vec:nil, -// size:0, -// epsilon:0, -// radius:0, +// path:"", +// opts:nil, // }, // fields: fields { // core:nil, @@ -2036,12 +2244,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -2053,12 +2265,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -2066,6 +2279,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2085,10 +2304,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// vec:nil, -// size:0, -// epsilon:0, -// radius:0, +// path:"", +// opts:nil, // }, // fields: fields { // core:nil, @@ -2097,12 +2314,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -2114,12 +2335,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -2127,6 +2349,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2157,123 +2385,8443 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// 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 { +// 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) // } -// // }) // } // } // -// func Test_ngt_SearchByID(t *testing.T) { +// func Test_ngt_backupBroken(t *testing.T) { // type args struct { -// ctx context.Context -// uuid string -// size uint32 -// epsilon float32 -// radius float32 +// 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 +// } +// 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 { +// 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, +// 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, +// }, +// 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, +// } +// +// err := n.backupBroken(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_rebuild(t *testing.T) { +// type args struct { +// ctx context.Context +// path string +// opts []core.Option +// } +// 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 +// } +// 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 { +// ctx:nil, +// path:"", +// opts: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, +// 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:"", +// opts: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, +// 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, +// } +// +// 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) +// } +// }) +// } +// } +// +// func Test_ngt_initNGT(t *testing.T) { +// type args struct { +// opts []core.Option +// } +// 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 +// } +// 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 { +// opts: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, +// 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, +// }, +// 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, +// } +// +// err := n.initNGT(test.args.opts...) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_loadKVS(t *testing.T) { +// type args struct { +// ctx context.Context +// path string +// timeout time.Duration +// } +// 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 +// } +// 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 { +// ctx:nil, +// path:"", +// timeout: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, +// 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:"", +// timeout: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, +// 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, +// } +// +// 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) +// } +// }) +// } +// } +// +// func Test_ngt_Start(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 { +// want <-chan error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// 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, +// 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, +// }, +// 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, +// } +// +// got := n.Start(test.args.ctx) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_Search(t *testing.T) { +// type args struct { +// ctx context.Context +// vec []float32 +// size uint32 +// epsilon float32 +// radius float32 +// } +// 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 { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// vec:nil, +// size:0, +// epsilon:0, +// radius:0, +// }, +// 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 { +// ctx:nil, +// vec:nil, +// size:0, +// epsilon:0, +// radius:0, +// }, +// 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, +// } +// +// 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_SearchByID(t *testing.T) { +// type args struct { +// ctx context.Context +// uuid string +// size uint32 +// epsilon float32 +// radius float32 +// } +// 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 { +// wantVec []float32 +// wantDst *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, []float32, *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 { +// 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{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// uuid:"", +// size:0, +// epsilon:0, +// radius:0, +// }, +// 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 { +// ctx:nil, +// uuid:"", +// size:0, +// epsilon:0, +// radius:0, +// }, +// 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, +// } +// +// 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_LinearSearch(t *testing.T) { +// type args struct { +// ctx context.Context +// vec []float32 +// size uint32 +// } +// 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 { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// vec:nil, +// size:0, +// }, +// 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 { +// ctx:nil, +// vec:nil, +// size:0, +// }, +// 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, +// } +// +// 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_LinearSearchByID(t *testing.T) { +// type args struct { +// ctx context.Context +// uuid string +// size uint32 +// } +// 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 { +// wantVec []float32 +// wantDst *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, []float32, *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 { +// 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{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// uuid:"", +// size:0, +// }, +// 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 { +// ctx:nil, +// uuid:"", +// size:0, +// }, +// 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, +// } +// +// 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_Insert(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// } +// 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 +// } +// 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 { +// uuid:"", +// vec: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, +// 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 { +// uuid:"", +// vec: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, +// 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, +// } +// +// 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_InsertWithTime(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// t int64 +// } +// 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 +// } +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// 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, +// } +// +// 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) +// } +// }) +// } +// } +// +// func Test_ngt_insert(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// t int64 +// validation bool +// } +// 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 +// } +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// validation:false, +// }, +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// validation:false, +// }, +// 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, +// } +// +// 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) +// } +// }) +// } +// } +// +// func Test_ngt_InsertMultiple(t *testing.T) { +// type args struct { +// vecs map[string][]float32 +// } +// 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 +// } +// 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 { +// vecs: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, +// 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 { +// vecs: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, +// 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, +// } +// +// err := n.InsertMultiple(test.args.vecs) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_InsertMultipleWithTime(t *testing.T) { +// type args struct { +// vecs map[string][]float32 +// t int64 +// } +// 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 +// } +// 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 { +// vecs:nil, +// t:0, +// }, +// 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 { +// vecs:nil, +// t:0, +// }, +// 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, +// } +// +// err := n.InsertMultipleWithTime(test.args.vecs, test.args.t) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_insertMultiple(t *testing.T) { +// type args struct { +// vecs map[string][]float32 +// now int64 +// validation bool +// } +// 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 +// } +// 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 { +// vecs:nil, +// now:0, +// validation:false, +// }, +// 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 { +// vecs:nil, +// now:0, +// validation:false, +// }, +// 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, +// } +// +// 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) +// } +// }) +// } +// } +// +// func Test_ngt_Update(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// } +// 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 +// } +// 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 { +// uuid:"", +// vec: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, +// 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 { +// uuid:"", +// vec: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, +// 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, +// } +// +// err := n.Update(test.args.uuid, test.args.vec) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_UpdateWithTime(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// t int64 +// } +// 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 +// } +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// 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, +// } +// +// 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) +// } +// }) +// } +// } +// +// func Test_ngt_update(t *testing.T) { +// type args struct { +// uuid string +// vec []float32 +// t int64 +// } +// 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 +// } +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// 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 { +// uuid:"", +// vec:nil, +// t:0, +// }, +// 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, +// } +// +// 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) +// } +// }) +// } +// } +// +// func Test_ngt_UpdateMultiple(t *testing.T) { +// type args struct { +// vecs map[string][]float32 +// } +// 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 +// } +// 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 { +// vecs: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, +// 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 { +// vecs: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, +// 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, +// } +// +// err := n.UpdateMultiple(test.args.vecs) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_UpdateMultipleWithTime(t *testing.T) { +// type args struct { +// vecs map[string][]float32 +// t int64 +// } +// 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 +// } +// 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 { +// vecs:nil, +// t:0, +// }, +// 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 { +// vecs:nil, +// t:0, +// }, +// 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, +// } +// +// err := n.UpdateMultipleWithTime(test.args.vecs, test.args.t) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_updateMultiple(t *testing.T) { +// type args struct { +// vecs map[string][]float32 +// t int64 +// } +// 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 +// } +// 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 { +// vecs:nil, +// t:0, +// }, +// 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 { +// vecs:nil, +// t:0, +// }, +// 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, +// } +// +// err := n.updateMultiple(test.args.vecs, test.args.t) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_Delete(t *testing.T) { +// type args struct { +// uuid string +// } +// 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 +// } +// 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 { +// uuid:"", +// }, +// 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 { +// uuid:"", +// }, +// 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, +// } +// +// err := n.Delete(test.args.uuid) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_DeleteWithTime(t *testing.T) { +// type args struct { +// uuid string +// t int64 +// } +// 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 +// } +// 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 { +// uuid:"", +// t:0, +// }, +// 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 { +// uuid:"", +// t:0, +// }, +// 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, +// } +// +// err := n.DeleteWithTime(test.args.uuid, test.args.t) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_delete(t *testing.T) { +// type args struct { +// uuid string +// t int64 +// validation bool +// } +// 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 +// } +// 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 { +// uuid:"", +// t:0, +// validation:false, +// }, +// 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 { +// uuid:"", +// t:0, +// validation:false, +// }, +// 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, +// } +// +// 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) +// } +// }) +// } +// } +// +// func Test_ngt_DeleteMultiple(t *testing.T) { +// type args struct { +// uuids []string +// } +// 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 +// } +// 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 { +// uuids: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, +// 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 { +// uuids: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, +// 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, +// } +// +// err := n.DeleteMultiple(test.args.uuids...) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_DeleteMultipleWithTime(t *testing.T) { +// type args struct { +// uuids []string +// t int64 +// } +// 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 +// } +// 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 { +// uuids:nil, +// t:0, +// }, +// 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 { +// uuids:nil, +// t:0, +// }, +// 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, +// } +// +// err := n.DeleteMultipleWithTime(test.args.uuids, test.args.t) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_deleteMultiple(t *testing.T) { +// type args struct { +// uuids []string +// now int64 +// validation bool +// } +// 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 +// } +// 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 { +// uuids:nil, +// now:0, +// validation:false, +// }, +// 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 { +// uuids:nil, +// now:0, +// validation:false, +// }, +// 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, +// } +// +// 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) +// } +// }) +// } +// } +// +// func Test_ngt_RegenerateIndexes(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 +// } +// 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 { +// 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, +// 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, +// }, +// 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, +// } +// +// err := n.RegenerateIndexes(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_removeInvalidIndex(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{} +// 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 { +// 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, +// 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, +// }, +// 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.removeInvalidIndex(test.args.ctx) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_saveIndex(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 -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// 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{ @@ -2283,10 +10831,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// uuid:"", -// size:0, -// epsilon:0, -// radius:0, // }, // fields: fields { // core:nil, @@ -2295,12 +10839,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -2312,12 +10860,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -2325,6 +10874,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2344,10 +10899,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// uuid:"", -// size:0, -// epsilon:0, -// radius:0, // }, // fields: fields { // core:nil, @@ -2356,12 +10907,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -2373,12 +10928,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -2386,6 +10942,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2416,117 +10978,133 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// 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 { +// err := n.saveIndex(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_LinearSearch(t *testing.T) { +// func Test_ngt_CreateAndSaveIndex(t *testing.T) { // type args struct { -// ctx context.Context -// vec []float32 -// size uint32 +// ctx context.Context +// poolSize uint32 // } // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// wantRes *payload.Search_Response -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, 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, 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 // } // tests := []test{ @@ -2536,8 +11114,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// vec:nil, -// size:0, +// poolSize:0, // }, // fields: fields { // core:nil, @@ -2546,12 +11123,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -2563,12 +11144,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -2576,6 +11158,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2595,8 +11183,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// vec:nil, -// size:0, +// poolSize:0, // }, // fields: fields { // core:nil, @@ -2605,12 +11192,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -2622,12 +11213,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -2635,6 +11227,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2665,121 +11263,132 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// gotRes, err := n.LinearSearch(test.args.ctx, test.args.vec, test.args.size) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// err := n.CreateAndSaveIndex(test.args.ctx, test.args.poolSize) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_LinearSearchByID(t *testing.T) { +// func Test_ngt_moveAndSwitchSavedData(t *testing.T) { // type args struct { -// ctx context.Context -// uuid string -// size uint32 +// 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 -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// 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{ @@ -2789,8 +11398,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// uuid:"", -// size:0, // }, // fields: fields { // core:nil, @@ -2799,12 +11406,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -2816,12 +11427,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -2829,6 +11441,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2848,8 +11466,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// uuid:"", -// size:0, // }, // fields: fields { // core:nil, @@ -2858,12 +11474,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -2875,12 +11495,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -2888,6 +11509,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2918,107 +11545,123 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// 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.moveAndSwitchSavedData(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_Insert(t *testing.T) { -// type args struct { -// uuid string -// vec []float32 -// } +// func Test_ngt_mktmp(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 // } // 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) { @@ -3031,10 +11674,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuid:"", -// vec:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -3042,12 +11681,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -3059,12 +11702,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -3072,13 +11716,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -3089,10 +11739,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// uuid:"", -// vec:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -3100,12 +11746,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -3117,12 +11767,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -3130,13 +11781,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -3150,122 +11807,145 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.Insert(test.args.uuid, test.args.vec) +// err := n.mktmp() // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_InsertWithTime(t *testing.T) { +// func Test_ngt_Exists(t *testing.T) { // type args struct { // uuid string -// vec []float32 -// t int64 // } // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// wantOid uint32 +// wantOk bool // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, uint32, bool) 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, gotOid uint32, gotOk bool) error { +// if !reflect.DeepEqual(gotOid, w.wantOid) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOid, w.wantOid) +// } +// if !reflect.DeepEqual(gotOk, w.wantOk) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOk, w.wantOk) // } // return nil // } @@ -3276,8 +11956,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // uuid:"", -// vec:nil, -// t:0, // }, // fields: fields { // core:nil, @@ -3286,12 +11964,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -3303,12 +11985,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -3316,6 +11999,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3335,8 +12024,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // uuid:"", -// vec:nil, -// t:0, // }, // fields: fields { // core:nil, @@ -3345,12 +12032,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -3362,12 +12053,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -3375,6 +12067,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3405,111 +12103,140 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.InsertWithTime(test.args.uuid, test.args.vec, test.args.t) -// if err := checkFunc(test.want, err); err != nil { +// gotOid, gotOk := n.Exists(test.args.uuid) +// if err := checkFunc(test.want, gotOid, gotOk); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_InsertMultiple(t *testing.T) { +// func Test_ngt_GetObject(t *testing.T) { // type args struct { -// vecs map[string][]float32 +// uuid string // } // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// wantVec []float32 +// wantTimestamp int64 +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, []float32, int64, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotVec []float32, gotTimestamp int64, 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(gotTimestamp, w.wantTimestamp) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotTimestamp, w.wantTimestamp) +// } // return nil // } // tests := []test{ @@ -3518,7 +12245,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// vecs:nil, +// uuid:"", // }, // fields: fields { // core:nil, @@ -3527,12 +12254,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -3544,12 +12275,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -3557,6 +12289,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3575,7 +12313,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// vecs:nil, +// uuid:"", // }, // fields: fields { // core:nil, @@ -3584,12 +12322,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -3601,12 +12343,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -3614,6 +12357,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3644,95 +12393,116 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.InsertMultiple(test.args.vecs) -// if err := checkFunc(test.want, err); err != nil { +// gotVec, gotTimestamp, err := n.GetObject(test.args.uuid) +// if err := checkFunc(test.want, gotVec, gotTimestamp, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_InsertMultipleWithTime(t *testing.T) { +// func Test_ngt_readyForUpdate(t *testing.T) { // type args struct { -// vecs map[string][]float32 -// t int64 +// uuid string +// vec []float32 // } // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 @@ -3758,8 +12528,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// vecs:nil, -// t:0, +// uuid:"", +// vec:nil, // }, // fields: fields { // core:nil, @@ -3768,12 +12538,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -3785,12 +12559,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -3798,6 +12573,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3816,8 +12597,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// vecs:nil, -// t:0, +// uuid:"", +// vec:nil, // }, // fields: fields { // core:nil, @@ -3826,12 +12607,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -3843,12 +12628,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -3856,6 +12642,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3886,111 +12678,127 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.InsertMultipleWithTime(test.args.vecs, test.args.t) +// err := n.readyForUpdate(test.args.uuid, test.args.vec) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_Update(t *testing.T) { -// type args struct { -// uuid string -// vec []float32 -// } +// func Test_ngt_IsSaving(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// want bool // } // 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) +// checkFunc func(want, bool) 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) +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -3999,10 +12807,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuid:"", -// vec:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -4010,12 +12814,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -4027,12 +12835,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -4040,13 +12849,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -4057,10 +12872,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// uuid:"", -// vec:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -4068,12 +12879,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -4085,12 +12900,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -4098,13 +12914,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -4118,122 +12940,137 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.Update(test.args.uuid, test.args.vec) -// if err := checkFunc(test.want, err); err != nil { +// got := n.IsSaving() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_UpdateWithTime(t *testing.T) { -// type args struct { -// uuid string -// vec []float32 -// t int64 -// } +// func Test_ngt_IsIndexing(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// want bool // } // 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) +// checkFunc func(want, bool) 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) +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -4241,12 +13078,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // // TODO test cases // /* // { -// name: "test_case_1", -// args: args { -// uuid:"", -// vec:nil, -// t:0, -// }, +// name: "test_case_1", // fields: fields { // core:nil, // eg:nil, @@ -4254,12 +13086,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -4271,12 +13107,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -4284,13 +13121,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -4301,11 +13144,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// uuid:"", -// vec:nil, -// t:0, -// }, // fields: fields { // core:nil, // eg:nil, @@ -4313,12 +13151,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -4330,12 +13172,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -4343,13 +13186,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -4363,120 +13212,137 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.UpdateWithTime(test.args.uuid, test.args.vec, test.args.t) -// if err := checkFunc(test.want, err); err != nil { +// got := n.IsIndexing() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_UpdateMultiple(t *testing.T) { -// type args struct { -// vecs map[string][]float32 -// } +// func Test_ngt_IsFlushing(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// want bool // } // 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) +// checkFunc func(want, bool) 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) +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -4485,9 +13351,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// vecs:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -4495,12 +13358,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -4512,12 +13379,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -4525,13 +13393,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -4542,9 +13416,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// vecs:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -4552,12 +13423,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -4569,12 +13444,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -4582,13 +13458,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -4602,121 +13484,141 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.UpdateMultiple(test.args.vecs) -// if err := checkFunc(test.want, err); err != nil { +// got := n.IsFlushing() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_UpdateMultipleWithTime(t *testing.T) { +// func Test_ngt_UUIDs(t *testing.T) { // type args struct { -// vecs map[string][]float32 -// t int64 +// 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 -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// wantUuids []string // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, []string) 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, gotUuids []string) error { +// if !reflect.DeepEqual(gotUuids, w.wantUuids) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotUuids, w.wantUuids) // } // return nil // } @@ -4726,8 +13628,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// vecs:nil, -// t:0, +// ctx:nil, // }, // fields: fields { // core:nil, @@ -4736,12 +13637,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -4753,12 +13658,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -4766,6 +13672,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4784,8 +13696,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// vecs:nil, -// t:0, +// ctx:nil, // }, // fields: fields { // core:nil, @@ -4794,12 +13705,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -4811,12 +13726,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -4824,6 +13740,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4854,110 +13776,127 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.UpdateMultipleWithTime(test.args.vecs, test.args.t) -// if err := checkFunc(test.want, err); err != nil { +// gotUuids := n.UUIDs(test.args.ctx) +// if err := checkFunc(test.want, gotUuids); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_Delete(t *testing.T) { -// type args struct { -// uuid string -// } +// func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// want uint64 // } // 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) +// checkFunc func(want, uint64) 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) +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -4966,9 +13905,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuid:"", -// }, // fields: fields { // core:nil, // eg:nil, @@ -4976,12 +13912,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -4993,12 +13933,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -5006,13 +13947,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -5023,9 +13970,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// uuid:"", -// }, // fields: fields { // core:nil, // eg:nil, @@ -5033,12 +13977,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -5050,12 +13998,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -5063,13 +14012,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -5083,121 +14038,137 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.Delete(test.args.uuid) -// if err := checkFunc(test.want, err); err != nil { +// got := n.NumberOfCreateIndexExecution() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_DeleteWithTime(t *testing.T) { -// type args struct { -// uuid string -// t int64 -// } +// func Test_ngt_NumberOfProactiveGCExecution(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// want uint64 // } // 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) +// checkFunc func(want, uint64) 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) +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -5206,10 +14177,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuid:"", -// t:0, -// }, // fields: fields { // core:nil, // eg:nil, @@ -5217,12 +14184,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -5234,12 +14205,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -5247,13 +14219,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -5264,10 +14242,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// uuid:"", -// t:0, -// }, // fields: fields { // core:nil, // eg:nil, @@ -5275,12 +14249,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -5292,12 +14270,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -5305,13 +14284,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -5325,120 +14310,137 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.DeleteWithTime(test.args.uuid, test.args.t) -// if err := checkFunc(test.want, err); err != nil { +// got := n.NumberOfProactiveGCExecution() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_DeleteMultiple(t *testing.T) { -// type args struct { -// uuids []string -// } +// func Test_ngt_lastNumberOfCreateIndexExecution(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// want uint64 // } // 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) +// checkFunc func(want, uint64) 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) +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -5447,9 +14449,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuids:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -5457,12 +14456,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -5474,12 +14477,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -5487,13 +14491,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -5504,9 +14514,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// uuids:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -5514,12 +14521,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -5531,12 +14542,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -5544,13 +14556,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -5564,122 +14582,133 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.DeleteMultiple(test.args.uuids...) -// if err := checkFunc(test.want, err); err != nil { +// got := n.lastNumberOfCreateIndexExecution() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_DeleteMultipleWithTime(t *testing.T) { -// type args struct { -// uuids []string -// t int64 -// } +// func Test_ngt_gc(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int -// } -// type want struct { -// err error +// 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) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) +// checkFunc func(want) 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) -// } +// defaultCheckFunc := func(w want) error { // return nil // } // tests := []test{ @@ -5687,10 +14716,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuids:nil, -// t:0, -// }, // fields: fields { // core:nil, // eg:nil, @@ -5698,12 +14723,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -5715,12 +14744,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -5728,13 +14758,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -5745,10 +14781,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// uuids:nil, -// t:0, -// }, // fields: fields { // core:nil, // eg:nil, @@ -5756,12 +14788,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -5773,12 +14809,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -5786,13 +14823,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -5806,121 +14849,137 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.DeleteMultipleWithTime(test.args.uuids, test.args.t) -// if err := checkFunc(test.want, err); err != nil { +// n.gc() +// if err := checkFunc(test.want); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_CreateIndex(t *testing.T) { -// type args struct { -// ctx context.Context -// poolSize uint32 -// } +// func Test_ngt_Len(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// want uint64 // } // 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) +// checkFunc func(want, uint64) 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) +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -5929,10 +14988,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// poolSize:0, -// }, // fields: fields { // core:nil, // eg:nil, @@ -5940,12 +14995,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -5957,12 +15016,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -5970,13 +15030,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -5987,10 +15053,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// ctx:nil, -// poolSize:0, -// }, // fields: fields { // core:nil, // eg:nil, @@ -5998,12 +15060,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -6015,12 +15081,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -6028,13 +15095,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -6048,120 +15121,137 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, -// } -// -// err := n.CreateIndex(test.args.ctx, test.args.poolSize) -// if err := checkFunc(test.want, err); err != nil { -// tt.Errorf("error = %v", err) +// 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, // } // +// got := n.Len() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } // -// func Test_ngt_SaveIndex(t *testing.T) { -// type args struct { -// ctx context.Context -// } +// func Test_ngt_InsertVQueueBufferLen(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// want uint64 // } // 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) +// checkFunc func(want, uint64) 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) +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -6170,9 +15260,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -6180,12 +15267,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -6197,12 +15288,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -6210,13 +15302,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -6227,9 +15325,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, @@ -6237,12 +15332,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -6254,12 +15353,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -6267,13 +15367,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -6287,121 +15393,137 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, -// } -// -// err := n.SaveIndex(test.args.ctx) -// if err := checkFunc(test.want, err); err != nil { -// tt.Errorf("error = %v", err) +// 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, // } // +// got := n.InsertVQueueBufferLen() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } // -// func Test_ngt_CreateAndSaveIndex(t *testing.T) { -// type args struct { -// ctx context.Context -// poolSize uint32 -// } +// func Test_ngt_DeleteVQueueBufferLen(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 +// want uint64 // } // 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) +// checkFunc func(want, uint64) 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) +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -6410,10 +15532,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// poolSize:0, -// }, // fields: fields { // core:nil, // eg:nil, @@ -6421,12 +15539,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -6438,12 +15560,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -6451,13 +15574,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -6468,10 +15597,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// ctx:nil, -// poolSize:0, -// }, // fields: fields { // core:nil, // eg:nil, @@ -6479,12 +15604,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -6496,12 +15625,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -6509,13 +15639,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -6529,124 +15665,137 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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 := n.CreateAndSaveIndex(test.args.ctx, test.args.poolSize) -// if err := checkFunc(test.want, err); err != nil { +// got := n.DeleteVQueueBufferLen() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_Exists(t *testing.T) { -// type args struct { -// uuid string -// } +// func Test_ngt_GetDimensionSize(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// wantOid uint32 -// wantOk bool +// want int // } // type test struct { // name string -// args args // fields fields // want want -// checkFunc func(want, uint32, bool) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, gotOid uint32, gotOk bool) error { -// if !reflect.DeepEqual(gotOid, w.wantOid) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOid, w.wantOid) -// } -// if !reflect.DeepEqual(gotOk, w.wantOk) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOk, w.wantOk) +// defaultCheckFunc := func(w want, got int) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -6655,9 +15804,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuid:"", -// }, // fields: fields { // core:nil, // eg:nil, @@ -6665,12 +15811,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -6682,12 +15832,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -6695,13 +15846,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -6712,9 +15869,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// uuid:"", -// }, // fields: fields { // core:nil, // eg:nil, @@ -6722,12 +15876,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -6739,12 +15897,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -6752,13 +15911,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -6772,128 +15937,137 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// gotOid, gotOk := n.Exists(test.args.uuid) -// if err := checkFunc(test.want, gotOid, gotOk); err != nil { +// got := n.GetDimensionSize() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_GetObject(t *testing.T) { -// type args struct { -// uuid string -// } +// func Test_ngt_BrokenIndexCount(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// wantVec []float32 -// wantTimestamp int64 -// err error +// want uint64 // } // type test struct { // name string -// args args // fields fields // want want -// checkFunc func(want, []float32, int64, error) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) +// checkFunc func(want, uint64) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, gotVec []float32, gotTimestamp int64, 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(gotTimestamp, w.wantTimestamp) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotTimestamp, w.wantTimestamp) +// defaultCheckFunc := func(w want, got uint64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -6902,9 +16076,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuid:"", -// }, // fields: fields { // core:nil, // eg:nil, @@ -6912,12 +16083,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -6929,12 +16104,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -6942,13 +16118,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -6959,9 +16141,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// uuid:"", -// }, // fields: fields { // core:nil, // eg:nil, @@ -6969,12 +16148,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -6986,12 +16169,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -6999,13 +16183,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -7019,117 +16209,138 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// gotVec, gotTimestamp, err := n.GetObject(test.args.uuid) -// if err := checkFunc(test.want, gotVec, gotTimestamp, err); err != nil { +// got := n.BrokenIndexCount() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_IsSaving(t *testing.T) { -// type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// func Test_ngt_ListObjectFunc(t *testing.T) { +// type args struct { +// ctx context.Context +// f func(uuid string, oid uint32, ts int64) bool // } -// type want struct { -// want bool +// 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, bool) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) +// checkFunc func(want) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got bool) error { -// if !reflect.DeepEqual(got, w.want) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) -// } +// defaultCheckFunc := func(w want) error { // return nil // } // tests := []test{ @@ -7137,6 +16348,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", +// args: args { +// ctx:nil, +// f:nil, +// }, // fields: fields { // core:nil, // eg:nil, @@ -7144,12 +16359,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -7161,12 +16380,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -7174,13 +16394,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // }, @@ -7191,6 +16417,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", +// args: args { +// ctx:nil, +// f:nil, +// }, // fields: fields { // core:nil, // eg:nil, @@ -7198,12 +16428,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -7215,12 +16449,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -7228,13 +16463,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // } @@ -7248,114 +16489,139 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt) +// test.beforeFunc(tt, test.args) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt) +// 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.IsSaving() -// if err := checkFunc(test.want, got); err != nil { +// n.ListObjectFunc(test.args.ctx, test.args.f) +// if err := checkFunc(test.want); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_IsIndexing(t *testing.T) { +// func Test_ngt_IndexStatistics(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// want bool +// want *payload.Info_Index_Statistics +// err error // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, bool) error +// checkFunc func(want, *payload.Info_Index_Statistics, error) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got bool) error { +// defaultCheckFunc := func(w want, got *payload.Info_Index_Statistics, 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) // } @@ -7373,12 +16639,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -7390,12 +16660,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -7403,6 +16674,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -7427,12 +16704,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -7444,12 +16725,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -7457,6 +16739,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -7487,110 +16775,127 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.IsIndexing() -// if err := checkFunc(test.want, got); err != nil { +// got, err := n.IndexStatistics() +// if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_UUIDs(t *testing.T) { -// type args struct { -// ctx context.Context -// } +// func Test_ngt_IsStatisticsEnabled(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// wantUuids []string +// want bool // } // type test struct { // name string -// args args // fields fields // want want -// checkFunc func(want, []string) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) +// checkFunc func(want, bool) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, gotUuids []string) error { -// if !reflect.DeepEqual(gotUuids, w.wantUuids) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotUuids, w.wantUuids) +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -7599,9 +16904,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -7609,12 +16911,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -7626,12 +16932,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -7639,13 +16946,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -7656,9 +16969,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, @@ -7666,12 +16976,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -7683,12 +16997,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -7696,13 +17011,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -7716,116 +17037,145 @@ 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 { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// gotUuids := n.UUIDs(test.args.ctx) -// if err := checkFunc(test.want, gotUuids); err != nil { +// got := n.IsStatisticsEnabled() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { +// func Test_ngt_toSearchResponse(t *testing.T) { +// type args struct { +// sr []algorithm.SearchResult +// } // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// want uint64 +// wantRes *payload.Search_Response +// err error // } // type test struct { // name string +// args args // fields fields // want want -// checkFunc func(want, uint64) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) +// checkFunc func(want, *payload.Search_Response, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got uint64) 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 // } @@ -7834,6 +17184,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", +// args: args { +// sr:nil, +// }, // fields: fields { // core:nil, // eg:nil, @@ -7841,12 +17194,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -7858,12 +17215,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -7871,13 +17229,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // }, @@ -7888,6 +17252,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", +// args: args { +// sr:nil, +// }, // fields: fields { // core:nil, // eg:nil, @@ -7895,12 +17262,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -7912,12 +17283,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -7925,13 +17297,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // } @@ -7945,116 +17323,141 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt) +// test.beforeFunc(tt, test.args) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt) +// 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.NumberOfCreateIndexExecution() -// if err := checkFunc(test.want, got); err != nil { +// gotRes, err := n.toSearchResponse(test.args.sr) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_NumberOfProactiveGCExecution(t *testing.T) { +// func Test_ngt_uncommittedEntry(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// want uint64 +// wantK string +// wantV string // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, uint64) error +// checkFunc func(want, string, string) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got uint64) 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, gotK string, gotV string) error { +// if !reflect.DeepEqual(gotK, w.wantK) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotK, w.wantK) +// } +// if !reflect.DeepEqual(gotV, w.wantV) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotV, w.wantV) // } // return nil // } @@ -8070,12 +17473,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -8087,12 +17494,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -8100,6 +17508,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -8124,12 +17538,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -8141,12 +17559,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -8154,6 +17573,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -8184,106 +17609,131 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.NumberOfProactiveGCExecution() -// if err := checkFunc(test.want, got); err != nil { +// gotK, gotV := n.uncommittedEntry() +// if err := checkFunc(test.want, gotK, gotV); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_Len(t *testing.T) { +// func Test_ngt_processedVqEntries(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// want uint64 +// wantK string +// wantV string // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, uint64) error +// checkFunc func(want, string, string) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got uint64) 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, gotK string, gotV string) error { +// if !reflect.DeepEqual(gotK, w.wantK) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotK, w.wantK) +// } +// if !reflect.DeepEqual(gotV, w.wantV) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotV, w.wantV) // } // return nil // } @@ -8299,12 +17749,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -8316,12 +17770,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -8329,6 +17784,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -8353,12 +17814,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -8370,12 +17835,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -8383,6 +17849,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -8413,106 +17885,131 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.Len() -// if err := checkFunc(test.want, got); err != nil { +// gotK, gotV := n.processedVqEntries() +// if err := checkFunc(test.want, gotK, gotV); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_InsertVQueueBufferLen(t *testing.T) { +// func Test_ngt_unsavedNumberOfCreateIndexExecutionEntry(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// want uint64 +// wantK string +// wantV string // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, uint64) error +// checkFunc func(want, string, string) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got uint64) 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, gotK string, gotV string) error { +// if !reflect.DeepEqual(gotK, w.wantK) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotK, w.wantK) +// } +// if !reflect.DeepEqual(gotV, w.wantV) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotV, w.wantV) // } // return nil // } @@ -8528,12 +18025,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -8545,12 +18046,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -8558,6 +18060,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -8582,12 +18090,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -8599,12 +18111,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -8612,6 +18125,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -8642,106 +18161,135 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.InsertVQueueBufferLen() -// if err := checkFunc(test.want, got); err != nil { +// gotK, gotV := n.unsavedNumberOfCreateIndexExecutionEntry() +// if err := checkFunc(test.want, gotK, gotV); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_DeleteVQueueBufferLen(t *testing.T) { +// func Test_ngt_lastTimeSaveIndexTimestampEntry(t *testing.T) { +// type args struct { +// timestamp time.Time +// } // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// want uint64 +// wantK string +// wantV string // } // type test struct { // name string +// args args // fields fields // want want -// checkFunc func(want, uint64) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) +// checkFunc func(want, string, string) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got uint64) 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, gotK string, gotV string) error { +// if !reflect.DeepEqual(gotK, w.wantK) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotK, w.wantK) +// } +// if !reflect.DeepEqual(gotV, w.wantV) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotV, w.wantV) // } // return nil // } @@ -8750,6 +18298,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", +// args: args { +// timestamp:time.Time{}, +// }, // fields: fields { // core:nil, // eg:nil, @@ -8757,12 +18308,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -8774,12 +18329,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -8787,13 +18343,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // }, @@ -8804,6 +18366,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", +// args: args { +// timestamp:time.Time{}, +// }, // fields: fields { // core:nil, // eg:nil, @@ -8811,12 +18376,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -8828,12 +18397,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -8841,13 +18411,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // } @@ -8861,116 +18437,141 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt) +// test.beforeFunc(tt, test.args) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt) +// 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.DeleteVQueueBufferLen() -// if err := checkFunc(test.want, got); err != nil { +// gotK, gotV := n.lastTimeSaveIndexTimestampEntry(test.args.timestamp) +// if err := checkFunc(test.want, gotK, gotV); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_GetDimensionSize(t *testing.T) { +// func Test_ngt_indexCountEntry(t *testing.T) { // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// want int +// wantK string +// wantV string // } // type test struct { // name string // fields fields // want want -// checkFunc func(want, int) error +// checkFunc func(want, string, string) error // beforeFunc func(*testing.T) // afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got int) 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, gotK string, gotV string) error { +// if !reflect.DeepEqual(gotK, w.wantK) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotK, w.wantK) +// } +// if !reflect.DeepEqual(gotV, w.wantV) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotV, w.wantV) // } // return nil // } @@ -8986,12 +18587,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -9003,12 +18608,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -9016,6 +18622,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -9040,12 +18652,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -9057,12 +18673,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -9070,6 +18687,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -9100,94 +18723,115 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.GetDimensionSize() -// if err := checkFunc(test.want, got); err != nil { +// gotK, gotV := n.indexCountEntry() +// if err := checkFunc(test.want, gotK, gotV); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_Close(t *testing.T) { +// func Test_ngt_exportMetricsOnTick(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 -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 @@ -9222,12 +18866,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -9239,12 +18887,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -9252,6 +18901,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -9279,12 +18934,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -9296,12 +18955,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -9309,6 +18969,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -9339,106 +19005,131 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, -// } -// -// err := n.Close(test.args.ctx) +// 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 := n.exportMetricsOnTick(test.args.ctx) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_BrokenIndexCount(t *testing.T) { +// func Test_ngt_exportMetricsOnCreateIndex(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 -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 { -// want uint64 +// err error // } // type test struct { // name string +// args args // fields fields // want want -// checkFunc func(want, uint64) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) +// checkFunc func(want, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got uint64) error { -// if !reflect.DeepEqual(got, w.want) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// defaultCheckFunc := func(w want, err error) error { +// if !errors.Is(err, w.err) { +// return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } // return nil // } @@ -9447,6 +19138,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", +// args: args { +// ctx:nil, +// }, // fields: fields { // core:nil, // eg:nil, @@ -9454,12 +19148,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -9471,12 +19169,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -9484,13 +19183,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // }, @@ -9501,6 +19206,9 @@ 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, @@ -9508,12 +19216,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -9525,12 +19237,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -9538,13 +19251,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // } @@ -9558,118 +19277,142 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt) +// test.beforeFunc(tt, test.args) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt) +// 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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, // } // -// got := n.BrokenIndexCount() -// if err := checkFunc(test.want, got); err != nil { +// err := n.exportMetricsOnCreateIndex(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_ngt_ListObjectFunc(t *testing.T) { +// func Test_ngt_exportMetricsOnSaveIndex(t *testing.T) { // type args struct { // ctx context.Context -// f func(uuid string, oid uint32, ts int64) bool // } // type fields struct { -// core core.NGT -// eg errgroup.Group -// kvs kvs.BidiMap -// fmap map[string]int64 -// vq vqueue.Queue -// indexing atomic.Value -// saving atomic.Value -// lastNocie uint64 -// nocie uint64 -// nogce uint64 -// wfci uint64 -// nobic uint64 -// 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 -// path string -// tmpPath atomic.Value -// oldPath string -// basePath string -// brokenPath string -// backupGen uint64 -// poolSize uint32 -// radius float32 -// epsilon float32 -// idelay time.Duration -// dcd bool -// kvsdbConcurrency int -// historyLimit int +// 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 // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want) 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) +// } // return nil // } // tests := []test{ @@ -9679,7 +19422,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// f:nil, // }, // fields: fields { // core:nil, @@ -9688,12 +19430,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -9705,12 +19451,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -9718,6 +19465,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -9737,7 +19490,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// f:nil, // }, // fields: fields { // core:nil, @@ -9746,12 +19498,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, @@ -9763,12 +19519,13 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // litFactor:nil, // enableProactiveGC:false, // enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", // tmpPath:nil, // oldPath:"", // basePath:"", // brokenPath:"", -// backupGen:0, // poolSize:0, // radius:0, // epsilon:0, @@ -9776,6 +19533,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // dcd:false, // kvsdbConcurrency:0, // historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -9806,46 +19569,57 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // 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, -// saving: test.fields.saving, -// lastNocie: test.fields.lastNocie, -// nocie: test.fields.nocie, -// nogce: test.fields.nogce, -// wfci: test.fields.wfci, -// nobic: test.fields.nobic, -// 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, -// path: test.fields.path, -// tmpPath: test.fields.tmpPath, -// oldPath: test.fields.oldPath, -// basePath: test.fields.basePath, -// brokenPath: test.fields.brokenPath, -// backupGen: test.fields.backupGen, -// 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, +// 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.ListObjectFunc(test.args.ctx, test.args.f) -// if err := checkFunc(test.want); err != nil { +// err := n.exportMetricsOnSaveIndex(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } // }) diff --git a/pkg/agent/core/ngt/service/option.go b/pkg/agent/core/ngt/service/option.go index 9d2a07f654..516da35ee0 100644 --- a/pkg/agent/core/ngt/service/option.go +++ b/pkg/agent/core/ngt/service/option.go @@ -50,6 +50,7 @@ var defaultOptions = []Option{ WithDefaultEpsilon(core.DefaultEpsilon), WithProactiveGC(true), WithExportIndexInfoDuration("1m"), + WithEnableStatistics(false), } // WithErrGroup returns the functional option to set the error group. @@ -339,3 +340,11 @@ func WithPatcher(p client.Patcher) Option { return nil } } + +// WithEnableStatistics returns the functional option to set the statistics flag. +func WithEnableStatistics(enabled bool) Option { + return func(n *ngt) error { + n.enableStatistics = enabled + return nil + } +} diff --git a/pkg/agent/core/ngt/service/option_test.go b/pkg/agent/core/ngt/service/option_test.go index 4fe907a153..d3a7c2e5b9 100644 --- a/pkg/agent/core/ngt/service/option_test.go +++ b/pkg/agent/core/ngt/service/option_test.go @@ -1392,3 +1392,258 @@ func TestWithExportIndexInfoDuration(t *testing.T) { } // NOT IMPLEMENTED BELOW +// +// func TestWithIsReadReplica(t *testing.T) { +// type args struct { +// isReadReplica 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 { +// isReadReplica: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 { +// isReadReplica: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 := WithIsReadReplica(test.args.isReadReplica) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithPatcher(t *testing.T) { +// type args struct { +// p client.Patcher +// } +// 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 { +// p: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 { +// p: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 := WithPatcher(test.args.p) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithEnableStatistics(t *testing.T) { +// type args struct { +// enabled 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 { +// enabled: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 { +// enabled: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 := WithEnableStatistics(test.args.enabled) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/ngt/usecase/agentd.go b/pkg/agent/core/ngt/usecase/agentd.go index d596c72e4d..c1432c3238 100644 --- a/pkg/agent/core/ngt/usecase/agentd.go +++ b/pkg/agent/core/ngt/usecase/agentd.go @@ -71,6 +71,7 @@ func New(cfg *config.Data) (r runner.Runner, err error) { service.WithProactiveGC(cfg.NGT.EnableProactiveGC), service.WithCopyOnWrite(cfg.NGT.EnableCopyOnWrite), service.WithIsReadReplica(cfg.NGT.IsReadReplica), + service.WithEnableStatistics(cfg.NGT.EnableStatistics), } if cfg.NGT.EnableExportIndexInfoToK8s { patcher, err := client.NewPatcher(fieldManager) diff --git a/pkg/agent/core/ngt/usecase/agentd_test.go b/pkg/agent/core/ngt/usecase/agentd_test.go index 483e3950e7..a178271b9c 100644 --- a/pkg/agent/core/ngt/usecase/agentd_test.go +++ b/pkg/agent/core/ngt/usecase/agentd_test.go @@ -103,7 +103,580 @@ package usecase // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// ngt service.NGT +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// ngt: test.fields.ngt, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// ngt service.NGT +// server starter.Server +// observability observability.Observability +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// ngt: test.fields.ngt, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// ngt service.NGT +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// ngt: test.fields.ngt, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PreStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// ngt service.NGT +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// ngt: test.fields.ngt, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// ngt service.NGT +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// ngt:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// ngt: test.fields.ngt, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PostStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/agent/internal/kvs/kvs_test.go b/pkg/agent/internal/kvs/kvs_test.go index e8f36a124b..c9dbd9db14 100644 --- a/pkg/agent/internal/kvs/kvs_test.go +++ b/pkg/agent/internal/kvs/kvs_test.go @@ -1887,7 +1887,91 @@ func Test_bidi_Len(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func Test_getShardID(t *testing.T) { +// type args struct { +// key string +// } +// type want struct { +// wantId uint64 +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, uint64) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotId uint64) error { +// if !reflect.DeepEqual(gotId, w.wantId) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotId, w.wantId) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// key:"", +// }, +// 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:"", +// }, +// 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 +// } +// +// gotId := getShardID(test.args.key) +// if err := checkFunc(test.want, gotId); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/agent/internal/kvs/option.go b/pkg/agent/internal/kvs/option.go index 06198c69dd..258f65b6f2 100644 --- a/pkg/agent/internal/kvs/option.go +++ b/pkg/agent/internal/kvs/option.go @@ -16,9 +16,7 @@ package kvs -import ( - "runtime" -) +import "runtime" // Option represents the functional option for bidi. type Option func(n *bidi) diff --git a/pkg/agent/internal/kvs/option_test.go b/pkg/agent/internal/kvs/option_test.go index 864e36a907..d5644241da 100644 --- a/pkg/agent/internal/kvs/option_test.go +++ b/pkg/agent/internal/kvs/option_test.go @@ -99,7 +99,6 @@ package kvs // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/internal/metadata/metadata_test.go b/pkg/agent/internal/metadata/metadata_test.go index fef2fe9273..9abc315fa6 100644 --- a/pkg/agent/internal/metadata/metadata_test.go +++ b/pkg/agent/internal/metadata/metadata_test.go @@ -104,7 +104,6 @@ package metadata // if err := checkFunc(test.want, gotMeta, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -193,7 +192,6 @@ package metadata // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/internal/vqueue/queue.go b/pkg/agent/internal/vqueue/queue.go index ce3fd8552f..ae073c5298 100644 --- a/pkg/agent/internal/vqueue/queue.go +++ b/pkg/agent/internal/vqueue/queue.go @@ -173,7 +173,9 @@ func (v *vqueue) DVExists(uuid string) bool { return didx.date > idx.date } -func (v *vqueue) RangePopInsert(ctx context.Context, now int64, f func(uuid string, vector []float32, date int64) bool) { +func (v *vqueue) RangePopInsert( + ctx context.Context, now int64, f func(uuid string, vector []float32, date int64) bool, +) { uii := make([]index, 0, atomic.LoadUint64(&v.ic)) defer func() { uii = nil diff --git a/pkg/agent/internal/vqueue/queue_test.go b/pkg/agent/internal/vqueue/queue_test.go index a181347374..2bf8ea74a5 100644 --- a/pkg/agent/internal/vqueue/queue_test.go +++ b/pkg/agent/internal/vqueue/queue_test.go @@ -166,7 +166,6 @@ func TestGetVector(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -283,7 +282,6 @@ func TestGetVector(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -397,7 +395,6 @@ func TestGetVector(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -516,7 +513,6 @@ func TestGetVector(t *testing.T) { // if err := checkFunc(test.want, gotVec, gotTimestamp, gotExists); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -627,7 +623,6 @@ func TestGetVector(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -738,7 +733,6 @@ func TestGetVector(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -755,8 +749,7 @@ func TestGetVector(t *testing.T) { // ic uint64 // dc uint64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -867,8 +860,7 @@ func TestGetVector(t *testing.T) { // ic uint64 // dc uint64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -969,7 +961,7 @@ func TestGetVector(t *testing.T) { // // func Test_vqueue_Range(t *testing.T) { // type args struct { -// ctx context.Context +// in0 context.Context // f func(uuid string, vector []float32, ts int64) bool // } // type fields struct { @@ -978,8 +970,7 @@ func TestGetVector(t *testing.T) { // ic uint64 // dc uint64 // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -998,7 +989,7 @@ func TestGetVector(t *testing.T) { // { // name: "test_case_1", // args: args { -// ctx:nil, +// in0:nil, // f:nil, // }, // fields: fields { @@ -1024,7 +1015,7 @@ func TestGetVector(t *testing.T) { // return test { // name: "test_case_2", // args: args { -// ctx:nil, +// in0:nil, // f:nil, // }, // fields: fields { @@ -1068,7 +1059,7 @@ func TestGetVector(t *testing.T) { // dc: test.fields.dc, // } // -// v.Range(test.args.ctx, test.args.f) +// v.Range(test.args.in0, test.args.f) // if err := checkFunc(test.want); err != nil { // tt.Errorf("error = %v", err) // } @@ -1172,7 +1163,6 @@ func TestGetVector(t *testing.T) { // if err := checkFunc(test.want, gotL); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1273,7 +1263,6 @@ func TestGetVector(t *testing.T) { // if err := checkFunc(test.want, gotL); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/sidecar/config/config_test.go b/pkg/agent/sidecar/config/config_test.go index bd991e40f6..3293573ade 100644 --- a/pkg/agent/sidecar/config/config_test.go +++ b/pkg/agent/sidecar/config/config_test.go @@ -91,7 +91,6 @@ package config // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -177,7 +176,6 @@ package config // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -267,7 +265,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/sidecar/handler/grpc/handler_test.go b/pkg/agent/sidecar/handler/grpc/handler_test.go index 267e98d0b8..77082875ab 100644 --- a/pkg/agent/sidecar/handler/grpc/handler_test.go +++ b/pkg/agent/sidecar/handler/grpc/handler_test.go @@ -100,7 +100,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/sidecar/handler/grpc/option_test.go b/pkg/agent/sidecar/handler/grpc/option_test.go index 1877f181f6..1d66a20e32 100644 --- a/pkg/agent/sidecar/handler/grpc/option_test.go +++ b/pkg/agent/sidecar/handler/grpc/option_test.go @@ -100,7 +100,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/sidecar/handler/rest/handler.go b/pkg/agent/sidecar/handler/rest/handler.go index 34a8dda12e..9a21b07b06 100644 --- a/pkg/agent/sidecar/handler/rest/handler.go +++ b/pkg/agent/sidecar/handler/rest/handler.go @@ -43,8 +43,8 @@ func New(opts ...Option) Handler { } func (*handler) Index(w http.ResponseWriter, r *http.Request) (int, error) { - data := make(map[string]interface{}) - return json.Handler(w, r, &data, func() (interface{}, error) { + data := make(map[string]any) + return json.Handler(w, r, &data, func() (any, error) { return dump.Request(nil, data, r) }) } diff --git a/pkg/agent/sidecar/handler/rest/handler_test.go b/pkg/agent/sidecar/handler/rest/handler_test.go new file mode 100644 index 0000000000..171e517390 --- /dev/null +++ b/pkg/agent/sidecar/handler/rest/handler_test.go @@ -0,0 +1,206 @@ +// 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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Index(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// sc sidecar.SidecarServer +// } +// type want struct { +// want int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// sc: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// sc: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 +// } +// h := &handler{ +// sc: test.fields.sc, +// } +// +// got, err := h.Index(test.args.w, test.args.r) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/sidecar/handler/rest/option.go b/pkg/agent/sidecar/handler/rest/option.go index ea7884a282..f183298e76 100644 --- a/pkg/agent/sidecar/handler/rest/option.go +++ b/pkg/agent/sidecar/handler/rest/option.go @@ -17,9 +17,7 @@ // Package rest provides rest api logic package rest -import ( - "github.com/vdaas/vald/apis/grpc/v1/agent/sidecar" -) +import "github.com/vdaas/vald/apis/grpc/v1/agent/sidecar" type Option func(*handler) diff --git a/pkg/agent/sidecar/handler/rest/option_test.go b/pkg/agent/sidecar/handler/rest/option_test.go new file mode 100644 index 0000000000..06236a571e --- /dev/null +++ b/pkg/agent/sidecar/handler/rest/option_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestWithSidecar(t *testing.T) { +// type args struct { +// sc sidecar.SidecarServer +// } +// 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 { +// sc: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 { +// sc: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 := WithSidecar(test.args.sc) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/sidecar/router/option.go b/pkg/agent/sidecar/router/option.go index 608300ea3e..91e9e8c523 100644 --- a/pkg/agent/sidecar/router/option.go +++ b/pkg/agent/sidecar/router/option.go @@ -17,9 +17,7 @@ // Package router provides implementation of Go API for routing http Handler wrapped by rest.Func package router -import ( - "github.com/vdaas/vald/pkg/agent/sidecar/handler/rest" -) +import "github.com/vdaas/vald/pkg/agent/sidecar/handler/rest" type Option func(*router) diff --git a/pkg/agent/sidecar/router/option_test.go b/pkg/agent/sidecar/router/option_test.go new file mode 100644 index 0000000000..c39d90a7bc --- /dev/null +++ b/pkg/agent/sidecar/router/option_test.go @@ -0,0 +1,186 @@ +// 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 router + +// NOT IMPLEMENTED BELOW +// +// func TestWithHandler(t *testing.T) { +// type args struct { +// h rest.Handler +// } +// 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 { +// h: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 { +// h: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 := WithHandler(test.args.h) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTimeout(t *testing.T) { +// type args struct { +// timeout 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 { +// timeout:"", +// }, +// 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 { +// timeout:"", +// }, +// 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 := WithTimeout(test.args.timeout) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/sidecar/router/router_test.go b/pkg/agent/sidecar/router/router_test.go new file mode 100644 index 0000000000..e9e3069588 --- /dev/null +++ b/pkg/agent/sidecar/router/router_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 router + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want http.Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, http.Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got http.Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/sidecar/service/observer/observer_test.go b/pkg/agent/sidecar/service/observer/observer_test.go index f71a8dd9ba..5a29088168 100644 --- a/pkg/agent/sidecar/service/observer/observer_test.go +++ b/pkg/agent/sidecar/service/observer/observer_test.go @@ -104,7 +104,6 @@ package observer // if err := checkFunc(test.want, gotSo, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -247,7 +246,6 @@ package observer // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -386,7 +384,1108 @@ package observer // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_observer_startTicker(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// w watch.Watcher +// dir string +// eg errgroup.Group +// checkDuration time.Duration +// metadataPath string +// postStopTimeout time.Duration +// watchEnabled bool +// tickerEnabled bool +// storage storage.Storage +// ch chan struct{} +// hooks []Hook +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 { +// ctx:nil, +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 +// } +// o := &observer{ +// w: test.fields.w, +// dir: test.fields.dir, +// eg: test.fields.eg, +// checkDuration: test.fields.checkDuration, +// metadataPath: test.fields.metadataPath, +// postStopTimeout: test.fields.postStopTimeout, +// watchEnabled: test.fields.watchEnabled, +// tickerEnabled: test.fields.tickerEnabled, +// storage: test.fields.storage, +// ch: test.fields.ch, +// hooks: test.fields.hooks, +// } +// +// got, err := o.startTicker(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_observer_startBackupLoop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// w watch.Watcher +// dir string +// eg errgroup.Group +// checkDuration time.Duration +// metadataPath string +// postStopTimeout time.Duration +// watchEnabled bool +// tickerEnabled bool +// storage storage.Storage +// ch chan struct{} +// hooks []Hook +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 { +// ctx:nil, +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 +// } +// o := &observer{ +// w: test.fields.w, +// dir: test.fields.dir, +// eg: test.fields.eg, +// checkDuration: test.fields.checkDuration, +// metadataPath: test.fields.metadataPath, +// postStopTimeout: test.fields.postStopTimeout, +// watchEnabled: test.fields.watchEnabled, +// tickerEnabled: test.fields.tickerEnabled, +// storage: test.fields.storage, +// ch: test.fields.ch, +// hooks: test.fields.hooks, +// } +// +// got, err := o.startBackupLoop(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_observer_onWrite(t *testing.T) { +// type args struct { +// ctx context.Context +// name string +// } +// type fields struct { +// w watch.Watcher +// dir string +// eg errgroup.Group +// checkDuration time.Duration +// metadataPath string +// postStopTimeout time.Duration +// watchEnabled bool +// tickerEnabled bool +// storage storage.Storage +// ch chan struct{} +// hooks []Hook +// } +// 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 { +// ctx:nil, +// name:"", +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 { +// ctx:nil, +// name:"", +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 +// } +// o := &observer{ +// w: test.fields.w, +// dir: test.fields.dir, +// eg: test.fields.eg, +// checkDuration: test.fields.checkDuration, +// metadataPath: test.fields.metadataPath, +// postStopTimeout: test.fields.postStopTimeout, +// watchEnabled: test.fields.watchEnabled, +// tickerEnabled: test.fields.tickerEnabled, +// storage: test.fields.storage, +// ch: test.fields.ch, +// hooks: test.fields.hooks, +// } +// +// err := o.onWrite(test.args.ctx, test.args.name) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_observer_onCreate(t *testing.T) { +// type args struct { +// ctx context.Context +// name string +// } +// type fields struct { +// w watch.Watcher +// dir string +// eg errgroup.Group +// checkDuration time.Duration +// metadataPath string +// postStopTimeout time.Duration +// watchEnabled bool +// tickerEnabled bool +// storage storage.Storage +// ch chan struct{} +// hooks []Hook +// } +// 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 { +// ctx:nil, +// name:"", +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 { +// ctx:nil, +// name:"", +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 +// } +// o := &observer{ +// w: test.fields.w, +// dir: test.fields.dir, +// eg: test.fields.eg, +// checkDuration: test.fields.checkDuration, +// metadataPath: test.fields.metadataPath, +// postStopTimeout: test.fields.postStopTimeout, +// watchEnabled: test.fields.watchEnabled, +// tickerEnabled: test.fields.tickerEnabled, +// storage: test.fields.storage, +// ch: test.fields.ch, +// hooks: test.fields.hooks, +// } +// +// err := o.onCreate(test.args.ctx, test.args.name) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_observer_isValidMetadata(t *testing.T) { +// type fields struct { +// w watch.Watcher +// dir string +// eg errgroup.Group +// checkDuration time.Duration +// metadataPath string +// postStopTimeout time.Duration +// watchEnabled bool +// tickerEnabled bool +// storage storage.Storage +// ch chan struct{} +// hooks []Hook +// } +// type want struct { +// want bool +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, bool, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got bool, 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 { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 +// } +// o := &observer{ +// w: test.fields.w, +// dir: test.fields.dir, +// eg: test.fields.eg, +// checkDuration: test.fields.checkDuration, +// metadataPath: test.fields.metadataPath, +// postStopTimeout: test.fields.postStopTimeout, +// watchEnabled: test.fields.watchEnabled, +// tickerEnabled: test.fields.tickerEnabled, +// storage: test.fields.storage, +// ch: test.fields.ch, +// hooks: test.fields.hooks, +// } +// +// got, err := o.isValidMetadata() +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_observer_terminate(t *testing.T) { +// type fields struct { +// w watch.Watcher +// dir string +// eg errgroup.Group +// checkDuration time.Duration +// metadataPath string +// postStopTimeout time.Duration +// watchEnabled bool +// tickerEnabled bool +// storage storage.Storage +// ch chan struct{} +// hooks []Hook +// } +// 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 { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 +// } +// o := &observer{ +// w: test.fields.w, +// dir: test.fields.dir, +// eg: test.fields.eg, +// checkDuration: test.fields.checkDuration, +// metadataPath: test.fields.metadataPath, +// postStopTimeout: test.fields.postStopTimeout, +// watchEnabled: test.fields.watchEnabled, +// tickerEnabled: test.fields.tickerEnabled, +// storage: test.fields.storage, +// ch: test.fields.ch, +// hooks: test.fields.hooks, +// } +// +// err := o.terminate() +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_observer_requestBackup(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// w watch.Watcher +// dir string +// eg errgroup.Group +// checkDuration time.Duration +// metadataPath string +// postStopTimeout time.Duration +// watchEnabled bool +// tickerEnabled bool +// storage storage.Storage +// ch chan struct{} +// hooks []Hook +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 { +// in0:nil, +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 +// } +// o := &observer{ +// w: test.fields.w, +// dir: test.fields.dir, +// eg: test.fields.eg, +// checkDuration: test.fields.checkDuration, +// metadataPath: test.fields.metadataPath, +// postStopTimeout: test.fields.postStopTimeout, +// watchEnabled: test.fields.watchEnabled, +// tickerEnabled: test.fields.tickerEnabled, +// storage: test.fields.storage, +// ch: test.fields.ch, +// hooks: test.fields.hooks, +// } +// +// err := o.requestBackup(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_observer_backup(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// w watch.Watcher +// dir string +// eg errgroup.Group +// checkDuration time.Duration +// metadataPath string +// postStopTimeout time.Duration +// watchEnabled bool +// tickerEnabled bool +// storage storage.Storage +// ch chan struct{} +// hooks []Hook +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 { +// ctx:nil, +// }, +// fields: fields { +// w:nil, +// dir:"", +// eg:nil, +// checkDuration:nil, +// metadataPath:"", +// postStopTimeout:nil, +// watchEnabled:false, +// tickerEnabled:false, +// storage:nil, +// ch:nil, +// hooks: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 +// } +// o := &observer{ +// w: test.fields.w, +// dir: test.fields.dir, +// eg: test.fields.eg, +// checkDuration: test.fields.checkDuration, +// metadataPath: test.fields.metadataPath, +// postStopTimeout: test.fields.postStopTimeout, +// watchEnabled: test.fields.watchEnabled, +// tickerEnabled: test.fields.tickerEnabled, +// storage: test.fields.storage, +// ch: test.fields.ch, +// hooks: test.fields.hooks, +// } +// +// err := o.backup(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/agent/sidecar/service/observer/option_test.go b/pkg/agent/sidecar/service/observer/option_test.go index 8db2813e10..b121bd5d76 100644 --- a/pkg/agent/sidecar/service/observer/option_test.go +++ b/pkg/agent/sidecar/service/observer/option_test.go @@ -100,7 +100,6 @@ package observer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package observer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package observer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package observer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package observer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package observer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package observer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -702,7 +695,6 @@ package observer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/sidecar/service/restorer/option_test.go b/pkg/agent/sidecar/service/restorer/option_test.go index 813b32b7ed..d1ff12face 100644 --- a/pkg/agent/sidecar/service/restorer/option_test.go +++ b/pkg/agent/sidecar/service/restorer/option_test.go @@ -100,7 +100,6 @@ package restorer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package restorer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package restorer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package restorer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package restorer // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/sidecar/service/restorer/restorer.go b/pkg/agent/sidecar/service/restorer/restorer.go index 91dff94d65..0d7312deef 100644 --- a/pkg/agent/sidecar/service/restorer/restorer.go +++ b/pkg/agent/sidecar/service/restorer/restorer.go @@ -127,7 +127,7 @@ func (r *restorer) startRestore(ctx context.Context) (<-chan error, error) { return ech, err } - restore := func(ctx context.Context) (interface{}, bool, error) { + restore := func(ctx context.Context) (any, bool, error) { err := r.restore(ctx) if err != nil { log.Errorf("restoring failed: %s", err) diff --git a/pkg/agent/sidecar/service/restorer/restorer_test.go b/pkg/agent/sidecar/service/restorer/restorer_test.go index d2b132a59a..5d8b5b528d 100644 --- a/pkg/agent/sidecar/service/restorer/restorer_test.go +++ b/pkg/agent/sidecar/service/restorer/restorer_test.go @@ -104,7 +104,6 @@ package restorer // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -227,7 +226,6 @@ package restorer // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -346,7 +344,246 @@ package restorer // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func Test_restorer_startRestore(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// dir string +// eg errgroup.Group +// storage storage.Storage +// backoffEnabled bool +// backoffOpts []backoff.Option +// bo backoff.Backoff +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// dir:"", +// eg:nil, +// storage:nil, +// backoffEnabled:false, +// backoffOpts:nil, +// bo: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 { +// ctx:nil, +// }, +// fields: fields { +// dir:"", +// eg:nil, +// storage:nil, +// backoffEnabled:false, +// backoffOpts:nil, +// bo: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 +// } +// r := &restorer{ +// dir: test.fields.dir, +// eg: test.fields.eg, +// storage: test.fields.storage, +// backoffEnabled: test.fields.backoffEnabled, +// backoffOpts: test.fields.backoffOpts, +// bo: test.fields.bo, +// } +// +// got, err := r.startRestore(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_restorer_restore(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// dir string +// eg errgroup.Group +// storage storage.Storage +// backoffEnabled bool +// backoffOpts []backoff.Option +// bo backoff.Backoff +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// dir:"", +// eg:nil, +// storage:nil, +// backoffEnabled:false, +// backoffOpts:nil, +// bo: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 { +// ctx:nil, +// }, +// fields: fields { +// dir:"", +// eg:nil, +// storage:nil, +// backoffEnabled:false, +// backoffOpts:nil, +// bo: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 +// } +// r := &restorer{ +// dir: test.fields.dir, +// eg: test.fields.eg, +// storage: test.fields.storage, +// backoffEnabled: test.fields.backoffEnabled, +// backoffOpts: test.fields.backoffOpts, +// bo: test.fields.bo, +// } +// +// err := r.restore(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/agent/sidecar/service/storage/option_test.go b/pkg/agent/sidecar/service/storage/option_test.go index 10e71b4bf1..700d4c5f66 100644 --- a/pkg/agent/sidecar/service/storage/option_test.go +++ b/pkg/agent/sidecar/service/storage/option_test.go @@ -100,7 +100,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -702,7 +695,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -788,7 +780,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -874,7 +865,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -960,7 +950,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/sidecar/service/storage/storage_test.go b/pkg/agent/sidecar/service/storage/storage_test.go index 905ee47d48..42bd600364 100644 --- a/pkg/agent/sidecar/service/storage/storage_test.go +++ b/pkg/agent/sidecar/service/storage/storage_test.go @@ -104,7 +104,288 @@ package storage // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_bs_initCompressor(t *testing.T) { +// type fields struct { +// eg errgroup.Group +// storageType string +// bucketName string +// filename string +// suffix string +// s3Opts []s3.Option +// s3SessionOpts []session.Option +// cloudStorageOpts []cloudstorage.Option +// cloudStorageURLOpenerOpts []urlopener.Option +// compressAlgorithm string +// compressionLevel int +// bucket blob.Bucket +// compressor compress.Compressor +// } +// 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 { +// eg:nil, +// storageType:"", +// bucketName:"", +// filename:"", +// suffix:"", +// s3Opts:nil, +// s3SessionOpts:nil, +// cloudStorageOpts:nil, +// cloudStorageURLOpenerOpts:nil, +// compressAlgorithm:"", +// compressionLevel:0, +// bucket:nil, +// compressor: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 { +// eg:nil, +// storageType:"", +// bucketName:"", +// filename:"", +// suffix:"", +// s3Opts:nil, +// s3SessionOpts:nil, +// cloudStorageOpts:nil, +// cloudStorageURLOpenerOpts:nil, +// compressAlgorithm:"", +// compressionLevel:0, +// bucket:nil, +// compressor: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 +// } +// b := &bs{ +// eg: test.fields.eg, +// storageType: test.fields.storageType, +// bucketName: test.fields.bucketName, +// filename: test.fields.filename, +// suffix: test.fields.suffix, +// s3Opts: test.fields.s3Opts, +// s3SessionOpts: test.fields.s3SessionOpts, +// cloudStorageOpts: test.fields.cloudStorageOpts, +// cloudStorageURLOpenerOpts: test.fields.cloudStorageURLOpenerOpts, +// compressAlgorithm: test.fields.compressAlgorithm, +// compressionLevel: test.fields.compressionLevel, +// bucket: test.fields.bucket, +// compressor: test.fields.compressor, +// } +// +// err := b.initCompressor() +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_bs_initBucket(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// storageType string +// bucketName string +// filename string +// suffix string +// s3Opts []s3.Option +// s3SessionOpts []session.Option +// cloudStorageOpts []cloudstorage.Option +// cloudStorageURLOpenerOpts []urlopener.Option +// compressAlgorithm string +// compressionLevel int +// bucket blob.Bucket +// compressor compress.Compressor +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// storageType:"", +// bucketName:"", +// filename:"", +// suffix:"", +// s3Opts:nil, +// s3SessionOpts:nil, +// cloudStorageOpts:nil, +// cloudStorageURLOpenerOpts:nil, +// compressAlgorithm:"", +// compressionLevel:0, +// bucket:nil, +// compressor: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// storageType:"", +// bucketName:"", +// filename:"", +// suffix:"", +// s3Opts:nil, +// s3SessionOpts:nil, +// cloudStorageOpts:nil, +// cloudStorageURLOpenerOpts:nil, +// compressAlgorithm:"", +// compressionLevel:0, +// bucket:nil, +// compressor: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 +// } +// b := &bs{ +// eg: test.fields.eg, +// storageType: test.fields.storageType, +// bucketName: test.fields.bucketName, +// filename: test.fields.filename, +// suffix: test.fields.suffix, +// s3Opts: test.fields.s3Opts, +// s3SessionOpts: test.fields.s3SessionOpts, +// cloudStorageOpts: test.fields.cloudStorageOpts, +// cloudStorageURLOpenerOpts: test.fields.cloudStorageURLOpenerOpts, +// compressAlgorithm: test.fields.compressAlgorithm, +// compressionLevel: test.fields.compressionLevel, +// bucket: test.fields.bucket, +// compressor: test.fields.compressor, +// } +// +// err := b.initBucket(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -255,7 +536,6 @@ package storage // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -402,7 +682,6 @@ package storage // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -553,7 +832,6 @@ package storage // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -704,7 +982,6 @@ package storage // if err := checkFunc(test.want, gotW, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -841,7 +1118,6 @@ package storage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/agent/sidecar/usecase/initcontainer/initcontainer_test.go b/pkg/agent/sidecar/usecase/initcontainer/initcontainer_test.go index 09bb31f032..1ee368d10b 100644 --- a/pkg/agent/sidecar/usecase/initcontainer/initcontainer_test.go +++ b/pkg/agent/sidecar/usecase/initcontainer/initcontainer_test.go @@ -103,7 +103,580 @@ package initcontainer // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// rs restorer.Restorer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// rs: test.fields.rs, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// rs restorer.Restorer +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// rs: test.fields.rs, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// rs restorer.Restorer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// rs: test.fields.rs, +// } +// +// err := r.PreStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// rs restorer.Restorer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// rs: test.fields.rs, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// rs restorer.Restorer +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// rs: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// rs: test.fields.rs, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/agent/sidecar/usecase/sidecar/sidecar_test.go b/pkg/agent/sidecar/usecase/sidecar/sidecar_test.go index 2be3aa945f..675e88956a 100644 --- a/pkg/agent/sidecar/usecase/sidecar/sidecar_test.go +++ b/pkg/agent/sidecar/usecase/sidecar/sidecar_test.go @@ -103,7 +103,580 @@ package sidecar // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// so observer.StorageObserver +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// so: test.fields.so, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// so observer.StorageObserver +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// so: test.fields.so, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// so observer.StorageObserver +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// so: test.fields.so, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// so observer.StorageObserver +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// so: test.fields.so, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// so observer.StorageObserver +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// so: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// so: test.fields.so, +// } +// +// err := r.PostStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/agent/sidecar/usecase/sidecard_test.go b/pkg/agent/sidecar/usecase/sidecard_test.go index 483e3950e7..5c5c635d65 100644 --- a/pkg/agent/sidecar/usecase/sidecard_test.go +++ b/pkg/agent/sidecar/usecase/sidecard_test.go @@ -103,7 +103,6 @@ package usecase // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/discoverer/k8s/config/config.go b/pkg/discoverer/k8s/config/config.go index fff4de8eaf..b29fbce0c4 100644 --- a/pkg/discoverer/k8s/config/config.go +++ b/pkg/discoverer/k8s/config/config.go @@ -17,9 +17,7 @@ // Package setting stores all server application settings package config -import ( - "github.com/vdaas/vald/internal/config" -) +import "github.com/vdaas/vald/internal/config" type GlobalConfig = config.GlobalConfig diff --git a/pkg/discoverer/k8s/config/config_test.go b/pkg/discoverer/k8s/config/config_test.go index 2d7afeecdd..5a237d0a9f 100644 --- a/pkg/discoverer/k8s/config/config_test.go +++ b/pkg/discoverer/k8s/config/config_test.go @@ -104,7 +104,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/discoverer/k8s/handler/grpc/handler.go b/pkg/discoverer/k8s/handler/grpc/handler.go index 588bd3f0e0..9a3fec538d 100644 --- a/pkg/discoverer/k8s/handler/grpc/handler.go +++ b/pkg/discoverer/k8s/handler/grpc/handler.go @@ -76,7 +76,9 @@ func New(opts ...Option) (ds DiscovererServer, err error) { func (*server) Start(context.Context) { } -func (s *server) Pods(ctx context.Context, req *payload.Discoverer_Request) (*payload.Info_Pods, error) { +func (s *server) Pods( + ctx context.Context, req *payload.Discoverer_Request, +) (*payload.Info_Pods, error) { ctx, span := trace.StartSpan(ctx, apiName+".Pods") defer func() { if span != nil { @@ -148,7 +150,9 @@ func (s *server) Pods(ctx context.Context, req *payload.Discoverer_Request) (*pa return cp, nil } -func (s *server) Nodes(ctx context.Context, req *payload.Discoverer_Request) (*payload.Info_Nodes, error) { +func (s *server) Nodes( + ctx context.Context, req *payload.Discoverer_Request, +) (*payload.Info_Nodes, error) { ctx, span := trace.StartSpan(ctx, apiName+".Nodes") defer func() { if span != nil { @@ -225,7 +229,9 @@ func (s *server) Nodes(ctx context.Context, req *payload.Discoverer_Request) (*p } // Services returns the services information that match the request. -func (s *server) Services(ctx context.Context, req *payload.Discoverer_Request) (*payload.Info_Services, error) { +func (s *server) Services( + ctx context.Context, req *payload.Discoverer_Request, +) (*payload.Info_Services, error) { ctx, span := trace.StartSpan(ctx, apiName+".Services") defer func() { if span != nil { diff --git a/pkg/discoverer/k8s/handler/grpc/handler_test.go b/pkg/discoverer/k8s/handler/grpc/handler_test.go index 0c347797fb..29b3f0af90 100644 --- a/pkg/discoverer/k8s/handler/grpc/handler_test.go +++ b/pkg/discoverer/k8s/handler/grpc/handler_test.go @@ -104,7 +104,6 @@ package grpc // if err := checkFunc(test.want, gotDs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -122,8 +121,7 @@ package grpc // name string // UnimplementedDiscovererServer discoverer.UnimplementedDiscovererServer // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -352,7 +350,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -482,7 +479,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -612,7 +608,182 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_singleflightKey(t *testing.T) { +// type args struct { +// pref string +// req *payload.Discoverer_Request +// } +// 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 { +// pref:"", +// req: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 { +// pref:"", +// req: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 := singleflightKey(test.args.pref, test.args.req) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_singleflightKeyForSvcs(t *testing.T) { +// type args struct { +// pref string +// req *payload.Discoverer_Request +// } +// 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 { +// pref:"", +// req: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 { +// pref:"", +// req: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 := singleflightKeyForSvcs(test.args.pref, test.args.req) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/discoverer/k8s/handler/grpc/option_test.go b/pkg/discoverer/k8s/handler/grpc/option_test.go index 72ad4b552c..79f1462876 100644 --- a/pkg/discoverer/k8s/handler/grpc/option_test.go +++ b/pkg/discoverer/k8s/handler/grpc/option_test.go @@ -100,7 +100,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/discoverer/k8s/handler/rest/handler.go b/pkg/discoverer/k8s/handler/rest/handler.go index 188a057a66..576ae11f0b 100644 --- a/pkg/discoverer/k8s/handler/rest/handler.go +++ b/pkg/discoverer/k8s/handler/rest/handler.go @@ -46,22 +46,22 @@ func New(opts ...Option) Handler { } func (*handler) Index(w http.ResponseWriter, r *http.Request) (int, error) { - data := make(map[string]interface{}) - return json.Handler(w, r, &data, func() (interface{}, error) { + data := make(map[string]any) + return json.Handler(w, r, &data, func() (any, error) { return dump.Request(nil, data, r) }) } func (h *handler) Pods(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Discoverer_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.dsc.Pods(r.Context(), req) }) } func (h *handler) Nodes(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Discoverer_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.dsc.Nodes(r.Context(), req) }) } diff --git a/pkg/discoverer/k8s/handler/rest/handler_test.go b/pkg/discoverer/k8s/handler/rest/handler_test.go new file mode 100644 index 0000000000..f48f4ac75c --- /dev/null +++ b/pkg/discoverer/k8s/handler/rest/handler_test.go @@ -0,0 +1,416 @@ +// 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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Index(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// dsc discoverer.DiscovererServer +// } +// type want struct { +// want int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// dsc: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// dsc: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 +// } +// h := &handler{ +// dsc: test.fields.dsc, +// } +// +// got, err := h.Index(test.args.w, test.args.r) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Pods(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// dsc discoverer.DiscovererServer +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// dsc: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// dsc: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 +// } +// h := &handler{ +// dsc: test.fields.dsc, +// } +// +// gotCode, err := h.Pods(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Nodes(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// dsc discoverer.DiscovererServer +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// dsc: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// dsc: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 +// } +// h := &handler{ +// dsc: test.fields.dsc, +// } +// +// gotCode, err := h.Nodes(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/discoverer/k8s/handler/rest/option_test.go b/pkg/discoverer/k8s/handler/rest/option_test.go new file mode 100644 index 0000000000..4a315bbd7b --- /dev/null +++ b/pkg/discoverer/k8s/handler/rest/option_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestWithDiscoverer(t *testing.T) { +// type args struct { +// dsc discoverer.DiscovererServer +// } +// 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 { +// dsc: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 { +// dsc: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 := WithDiscoverer(test.args.dsc) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/discoverer/k8s/router/option_test.go b/pkg/discoverer/k8s/router/option_test.go new file mode 100644 index 0000000000..42e073651c --- /dev/null +++ b/pkg/discoverer/k8s/router/option_test.go @@ -0,0 +1,271 @@ +// 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 router + +// NOT IMPLEMENTED BELOW +// +// func TestWithHandler(t *testing.T) { +// type args struct { +// h rest.Handler +// } +// 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 { +// h: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 { +// h: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 := WithHandler(test.args.h) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTimeout(t *testing.T) { +// type args struct { +// timeout 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 { +// timeout:"", +// }, +// 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 { +// timeout:"", +// }, +// 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 := WithTimeout(test.args.timeout) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/discoverer/k8s/router/router_test.go b/pkg/discoverer/k8s/router/router_test.go new file mode 100644 index 0000000000..e9e3069588 --- /dev/null +++ b/pkg/discoverer/k8s/router/router_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 router + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want http.Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, http.Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got http.Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/discoverer/k8s/service/discover.go b/pkg/discoverer/k8s/service/discover.go index a551d920ce..c95b02420d 100644 --- a/pkg/discoverer/k8s/service/discover.go +++ b/pkg/discoverer/k8s/service/discover.go @@ -91,7 +91,7 @@ func New(selector *config.Selectors, opts ...Option) (dsc Discoverer, err error) k8s.WithResourceController(mnode.New( mnode.WithControllerName("node metrics discoverer"), mnode.WithOnErrorFunc(func(err error) { - log.Error("failed to reconcile:", err) + log.Error("failed to reconcile node metrics:", err) }), mnode.WithOnReconcileFunc(func(nodes map[string]mnode.Node) { log.Debugf("node metrics reconciled\t%#v", nodes) @@ -113,7 +113,7 @@ func New(selector *config.Selectors, opts ...Option) (dsc Discoverer, err error) k8s.WithResourceController(mpod.New( mpod.WithControllerName("pod metrics discoverer"), mpod.WithOnErrorFunc(func(err error) { - log.Error("failed to reconcile:", err) + log.Error("failed to reconcile pod metrics:", err) }), mpod.WithOnReconcileFunc(func(podList map[string]mpod.Pod) { log.Debugf("pod metrics reconciled\t%#v", podList) @@ -135,7 +135,7 @@ func New(selector *config.Selectors, opts ...Option) (dsc Discoverer, err error) k8s.WithResourceController(pod.New( pod.WithControllerName("pod discoverer"), pod.WithOnErrorFunc(func(err error) { - log.Error("failed to reconcile:", err) + log.Error("failed to reconcile pod resource:", err) }), pod.WithOnReconcileFunc(func(_ context.Context, podList map[string][]pod.Pod) { log.Debugf("pod resource reconciled\t%#v", podList) @@ -160,7 +160,7 @@ func New(selector *config.Selectors, opts ...Option) (dsc Discoverer, err error) k8s.WithResourceController(node.New( node.WithControllerName("node discoverer"), node.WithOnErrorFunc(func(err error) { - log.Error("failed to reconcile:", err) + log.Error("failed to reconcile node resource:", err) }), node.WithOnReconcileFunc(func(nodes []node.Node) { log.Debugf("node resource reconciled\t%#v", nodes) @@ -510,7 +510,9 @@ func (d *discoverer) GetPods(req *payload.Discoverer_Request) (pods *payload.Inf return pods, nil } -func (d *discoverer) GetNodes(req *payload.Discoverer_Request) (nodes *payload.Info_Nodes, err error) { +func (d *discoverer) GetNodes( + req *payload.Discoverer_Request, +) (nodes *payload.Info_Nodes, err error) { nodes = new(payload.Info_Nodes) nbn, ok := d.nodeByName.Load().(map[string]*payload.Info_Node) if !ok { @@ -555,7 +557,9 @@ func (d *discoverer) GetNodes(req *payload.Discoverer_Request) (nodes *payload.I } // Get Services returns the services that matches the request. -func (d *discoverer) GetServices(req *payload.Discoverer_Request) (svcs *payload.Info_Services, err error) { +func (d *discoverer) GetServices( + req *payload.Discoverer_Request, +) (svcs *payload.Info_Services, err error) { svcs = new(payload.Info_Services) sbn, ok := d.svcsByName.Load().(map[string]*payload.Info_Service) if !ok { diff --git a/pkg/discoverer/k8s/service/discover_test.go b/pkg/discoverer/k8s/service/discover_test.go index 8ff5dcb6e1..53aae172d2 100644 --- a/pkg/discoverer/k8s/service/discover_test.go +++ b/pkg/discoverer/k8s/service/discover_test.go @@ -107,7 +107,6 @@ package service // if err := checkFunc(test.want, gotDsc, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -122,7 +121,7 @@ package service // nodeMetrics sync.Map[string, mnode.Node] // pods sync.Map[string, *[]pod.Pod] // podMetrics sync.Map[string, mpod.Pod] -// rrsvcs sync.Map[string, *service.Service] +// services sync.Map[string, *service.Service] // podsByNode atomic.Value // podsByNamespace atomic.Value // podsByName atomic.Value @@ -171,7 +170,7 @@ package service // nodeMetrics:nil, // pods:nil, // podMetrics:nil, -// rrsvcs:nil, +// services:nil, // podsByNode:nil, // podsByNamespace:nil, // podsByName:nil, @@ -209,7 +208,7 @@ package service // nodeMetrics:nil, // pods:nil, // podMetrics:nil, -// rrsvcs:nil, +// services:nil, // podsByNode:nil, // podsByNamespace:nil, // podsByName:nil, @@ -256,7 +255,7 @@ package service // nodeMetrics: test.fields.nodeMetrics, // pods: test.fields.pods, // podMetrics: test.fields.podMetrics, -// rrsvcs: test.fields.rrsvcs, +// services: test.fields.services, // podsByNode: test.fields.podsByNode, // podsByNamespace: test.fields.podsByNamespace, // podsByName: test.fields.podsByName, @@ -274,7 +273,6 @@ package service // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -289,7 +287,7 @@ package service // nodeMetrics sync.Map[string, mnode.Node] // pods sync.Map[string, *[]pod.Pod] // podMetrics sync.Map[string, mpod.Pod] -// rrsvcs sync.Map[string, *service.Service] +// services sync.Map[string, *service.Service] // podsByNode atomic.Value // podsByNamespace atomic.Value // podsByName atomic.Value @@ -338,7 +336,7 @@ package service // nodeMetrics:nil, // pods:nil, // podMetrics:nil, -// rrsvcs:nil, +// services:nil, // podsByNode:nil, // podsByNamespace:nil, // podsByName:nil, @@ -376,7 +374,7 @@ package service // nodeMetrics:nil, // pods:nil, // podMetrics:nil, -// rrsvcs:nil, +// services:nil, // podsByNode:nil, // podsByNamespace:nil, // podsByName:nil, @@ -423,7 +421,7 @@ package service // nodeMetrics: test.fields.nodeMetrics, // pods: test.fields.pods, // podMetrics: test.fields.podMetrics, -// rrsvcs: test.fields.rrsvcs, +// services: test.fields.services, // podsByNode: test.fields.podsByNode, // podsByNamespace: test.fields.podsByNamespace, // podsByName: test.fields.podsByName, @@ -441,7 +439,6 @@ package service // if err := checkFunc(test.want, gotPods, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -456,7 +453,7 @@ package service // nodeMetrics sync.Map[string, mnode.Node] // pods sync.Map[string, *[]pod.Pod] // podMetrics sync.Map[string, mpod.Pod] -// rrsvcs sync.Map[string, *service.Service] +// services sync.Map[string, *service.Service] // podsByNode atomic.Value // podsByNamespace atomic.Value // podsByName atomic.Value @@ -505,7 +502,7 @@ package service // nodeMetrics:nil, // pods:nil, // podMetrics:nil, -// rrsvcs:nil, +// services:nil, // podsByNode:nil, // podsByNamespace:nil, // podsByName:nil, @@ -543,7 +540,7 @@ package service // nodeMetrics:nil, // pods:nil, // podMetrics:nil, -// rrsvcs:nil, +// services:nil, // podsByNode:nil, // podsByNamespace:nil, // podsByName:nil, @@ -590,7 +587,7 @@ package service // nodeMetrics: test.fields.nodeMetrics, // pods: test.fields.pods, // podMetrics: test.fields.podMetrics, -// rrsvcs: test.fields.rrsvcs, +// services: test.fields.services, // podsByNode: test.fields.podsByNode, // podsByNamespace: test.fields.podsByNamespace, // podsByName: test.fields.podsByName, @@ -608,7 +605,6 @@ package service // if err := checkFunc(test.want, gotNodes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -623,7 +619,7 @@ package service // nodeMetrics sync.Map[string, mnode.Node] // pods sync.Map[string, *[]pod.Pod] // podMetrics sync.Map[string, mpod.Pod] -// rrsvcs sync.Map[string, *service.Service] +// services sync.Map[string, *service.Service] // podsByNode atomic.Value // podsByNamespace atomic.Value // podsByName atomic.Value @@ -672,7 +668,7 @@ package service // nodeMetrics:nil, // pods:nil, // podMetrics:nil, -// rrsvcs:nil, +// services:nil, // podsByNode:nil, // podsByNamespace:nil, // podsByName:nil, @@ -710,7 +706,7 @@ package service // nodeMetrics:nil, // pods:nil, // podMetrics:nil, -// rrsvcs:nil, +// services:nil, // podsByNode:nil, // podsByNamespace:nil, // podsByName:nil, @@ -757,7 +753,7 @@ package service // nodeMetrics: test.fields.nodeMetrics, // pods: test.fields.pods, // podMetrics: test.fields.podMetrics, -// rrsvcs: test.fields.rrsvcs, +// services: test.fields.services, // podsByNode: test.fields.podsByNode, // podsByNamespace: test.fields.podsByNamespace, // podsByName: test.fields.podsByName, @@ -775,7 +771,6 @@ package service // if err := checkFunc(test.want, gotSvcs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/discoverer/k8s/service/option_test.go b/pkg/discoverer/k8s/service/option_test.go index 07b019b5b3..fa2baf1625 100644 --- a/pkg/discoverer/k8s/service/option_test.go +++ b/pkg/discoverer/k8s/service/option_test.go @@ -100,7 +100,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/discoverer/k8s/usecase/discovered_test.go b/pkg/discoverer/k8s/usecase/discovered_test.go index 483e3950e7..a6d996d7c0 100644 --- a/pkg/discoverer/k8s/usecase/discovered_test.go +++ b/pkg/discoverer/k8s/usecase/discovered_test.go @@ -103,7 +103,620 @@ package usecase // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// dsc service.Discoverer +// h handler.DiscovererServer +// server starter.Server +// observability observability.Observability +// der net.Dialer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// dsc: test.fields.dsc, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// der: test.fields.der, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// dsc service.Discoverer +// h handler.DiscovererServer +// server starter.Server +// observability observability.Observability +// der net.Dialer +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// dsc: test.fields.dsc, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// der: test.fields.der, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// dsc service.Discoverer +// h handler.DiscovererServer +// server starter.Server +// observability observability.Observability +// der net.Dialer +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// dsc: test.fields.dsc, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// der: test.fields.der, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// dsc service.Discoverer +// h handler.DiscovererServer +// server starter.Server +// observability observability.Observability +// der net.Dialer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// dsc: test.fields.dsc, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// der: test.fields.der, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// dsc service.Discoverer +// h handler.DiscovererServer +// server starter.Server +// observability observability.Observability +// der net.Dialer +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// dsc:nil, +// h:nil, +// server:nil, +// observability:nil, +// der: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// dsc: test.fields.dsc, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// der: test.fields.der, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/gateway/filter/config/config_test.go b/pkg/gateway/filter/config/config_test.go index 2d7afeecdd..5a237d0a9f 100644 --- a/pkg/gateway/filter/config/config_test.go +++ b/pkg/gateway/filter/config/config_test.go @@ -104,7 +104,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/gateway/filter/handler/grpc/handler.go b/pkg/gateway/filter/handler/grpc/handler.go index aadf86077f..dd42febe0b 100644 --- a/pkg/gateway/filter/handler/grpc/handler.go +++ b/pkg/gateway/filter/handler/grpc/handler.go @@ -73,7 +73,9 @@ func New(opts ...Option) vald.ServerWithFilter { return s } -func (s *server) SearchObject(ctx context.Context, req *payload.Search_ObjectRequest) (res *payload.Search_Response, err error) { +func (s *server) SearchObject( + ctx context.Context, req *payload.Search_ObjectRequest, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.SearchObjectRPCName), apiName+"/"+vald.SearchObjectRPCName) defer func() { if span != nil { @@ -206,7 +208,9 @@ func (s *server) SearchObject(ctx context.Context, req *payload.Search_ObjectReq }) } -func (s *server) MultiSearchObject(ctx context.Context, reqs *payload.Search_MultiObjectRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiSearchObject( + ctx context.Context, reqs *payload.Search_MultiObjectRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiSearchObjectRPCName), apiName+"/"+vald.MultiSearchObjectRPCName) defer func() { if span != nil { @@ -324,7 +328,9 @@ func (s *server) StreamSearchObject(stream vald.Filter_StreamSearchObjectServer) }) } -func (s *server) LinearSearchObject(ctx context.Context, req *payload.Search_ObjectRequest) (*payload.Search_Response, error) { +func (s *server) LinearSearchObject( + ctx context.Context, req *payload.Search_ObjectRequest, +) (*payload.Search_Response, error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.LinearSearchObjectRPCName), apiName+"/"+vald.LinearSearchObjectRPCName) defer func() { if span != nil { @@ -455,7 +461,9 @@ func (s *server) LinearSearchObject(ctx context.Context, req *payload.Search_Obj }) } -func (s *server) MultiLinearSearchObject(ctx context.Context, reqs *payload.Search_MultiObjectRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiLinearSearchObject( + ctx context.Context, reqs *payload.Search_MultiObjectRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiLinearSearchObjectRPCName), apiName+"/"+vald.MultiLinearSearchObjectRPCName) defer func() { if span != nil { @@ -580,7 +588,9 @@ func (s *server) StreamLinearSearchObject(stream vald.Filter_StreamSearchObjectS return err } -func (s *server) InsertObject(ctx context.Context, req *payload.Insert_ObjectRequest) (*payload.Object_Location, error) { +func (s *server) InsertObject( + ctx context.Context, req *payload.Insert_ObjectRequest, +) (*payload.Object_Location, error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.InsertObjectRPCName), apiName+"/"+vald.InsertObjectRPCName) defer func() { if span != nil { @@ -769,7 +779,9 @@ func (s *server) StreamInsertObject(stream vald.Filter_StreamInsertObjectServer) return nil } -func (s *server) MultiInsertObject(ctx context.Context, reqs *payload.Insert_MultiObjectRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiInsertObject( + ctx context.Context, reqs *payload.Insert_MultiObjectRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiInsertObjectRPCName), apiName+"/"+vald.MultiInsertObjectRPCName) defer func() { if span != nil { @@ -833,7 +845,9 @@ func (s *server) MultiInsertObject(ctx context.Context, reqs *payload.Insert_Mul return locs, errs } -func (s *server) UpdateObject(ctx context.Context, req *payload.Update_ObjectRequest) (*payload.Object_Location, error) { +func (s *server) UpdateObject( + ctx context.Context, req *payload.Update_ObjectRequest, +) (*payload.Object_Location, error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.UpdateObjectRPCName), apiName+"/"+vald.UpdateObjectRPCName) defer func() { if span != nil { @@ -1022,7 +1036,9 @@ func (s *server) StreamUpdateObject(stream vald.Filter_StreamUpdateObjectServer) return nil } -func (s *server) MultiUpdateObject(ctx context.Context, reqs *payload.Update_MultiObjectRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiUpdateObject( + ctx context.Context, reqs *payload.Update_MultiObjectRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiUpdateObjectRPCName), apiName+"/"+vald.MultiUpdateObjectRPCName) defer func() { if span != nil { @@ -1086,7 +1102,9 @@ func (s *server) MultiUpdateObject(ctx context.Context, reqs *payload.Update_Mul return locs, errs } -func (s *server) UpsertObject(ctx context.Context, req *payload.Upsert_ObjectRequest) (*payload.Object_Location, error) { +func (s *server) UpsertObject( + ctx context.Context, req *payload.Upsert_ObjectRequest, +) (*payload.Object_Location, error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.UpsertObjectRPCName), apiName+"/"+vald.UpsertObjectRPCName) defer func() { if span != nil { @@ -1283,7 +1301,9 @@ func (s *server) StreamUpsertObject(stream vald.Filter_StreamUpsertObjectServer) return err } -func (s *server) MultiUpsertObject(ctx context.Context, reqs *payload.Upsert_MultiObjectRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiUpsertObject( + ctx context.Context, reqs *payload.Upsert_MultiObjectRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiUpsertObjectRPCName), apiName+"/"+vald.MultiUpsertObjectRPCName) defer func() { if span != nil { @@ -1356,7 +1376,9 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (*payload. return s.gateway.Exists(ctx, meta, s.copts...) } -func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) Search( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.SearchRPCName), apiName+"/"+vald.SearchRPCName) defer func() { if span != nil { @@ -1498,7 +1520,9 @@ func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res * return res, nil } -func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) (res *payload.Search_Response, err error) { +func (s *server) SearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.SearchByIDRPCName), apiName+"/"+vald.SearchByIDRPCName) defer func() { if span != nil { @@ -1699,7 +1723,9 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er return nil } -func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiSearch( + ctx context.Context, reqs *payload.Search_MultiRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiSearchRPCName), apiName+"/"+vald.MultiSearchRPCName) defer func() { if span != nil { @@ -1769,7 +1795,9 @@ func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequ return res, errs } -func (s *server) MultiSearchByID(ctx context.Context, reqs *payload.Search_MultiIDRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiSearchByID( + ctx context.Context, reqs *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiSearchByIDRPCName), apiName+"/"+vald.MultiSearchByIDRPCName) defer func() { if span != nil { @@ -1839,7 +1867,9 @@ func (s *server) MultiSearchByID(ctx context.Context, reqs *payload.Search_Multi return res, errs } -func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) LinearSearch( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.LinearSearchRPCName) defer func() { if span != nil { @@ -1975,7 +2005,9 @@ func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) return res, nil } -func (s *server) LinearSearchByID(ctx context.Context, req *payload.Search_IDRequest) (res *payload.Search_Response, err error) { +func (s *server) LinearSearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.LinearSearchByIDRPCName) defer func() { if span != nil { @@ -2114,7 +2146,9 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) return nil } -func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByIDServer) (err error) { +func (s *server) StreamLinearSearchByID( + stream vald.Search_StreamLinearSearchByIDServer, +) (err error) { ctx, span := trace.StartSpan( grpc.WithGRPCMethod(stream.Context(), vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.StreamLinearSearchByIDRPCName), apiName+"/"+vald.StreamLinearSearchByIDRPCName, @@ -2175,7 +2209,9 @@ func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByI return nil } -func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_MultiRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiLinearSearch( + ctx context.Context, reqs *payload.Search_MultiRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(ctx, apiName+"/"+vald.MultiLinearSearchRPCName) defer func() { if span != nil { @@ -2237,7 +2273,9 @@ func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_Mul return res, errs } -func (s *server) MultiLinearSearchByID(ctx context.Context, reqs *payload.Search_MultiIDRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiLinearSearchByID( + ctx context.Context, reqs *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiLinearSearchByIDRPCName), apiName+"/"+vald.MultiLinearSearchByIDRPCName) defer func() { if span != nil { @@ -2299,7 +2337,9 @@ func (s *server) MultiLinearSearchByID(ctx context.Context, reqs *payload.Search return res, errs } -func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (loc *payload.Object_Location, err error) { +func (s *server) Insert( + ctx context.Context, req *payload.Insert_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.InsertRPCName), apiName+"/"+vald.InsertRPCName) defer func() { if span != nil { @@ -2504,7 +2544,9 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) return nil } -func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiInsert( + ctx context.Context, reqs *payload.Insert_MultiRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiInsertRPCName), apiName+"/"+vald.MultiInsertRPCName) defer func() { if span != nil { @@ -2574,7 +2616,9 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ return locs, errs } -func (s *server) Update(ctx context.Context, req *payload.Update_Request) (loc *payload.Object_Location, err error) { +func (s *server) Update( + ctx context.Context, req *payload.Update_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.UpdateRPCName), apiName+"/"+vald.UpdateRPCName) defer func() { if span != nil { @@ -2758,7 +2802,9 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) return nil } -func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiUpdate( + ctx context.Context, reqs *payload.Update_MultiRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiUpdateRPCName), apiName+"/"+vald.MultiUpdateRPCName) defer func() { if span != nil { @@ -2828,7 +2874,9 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ return locs, errs } -func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc *payload.Object_Location, err error) { +func (s *server) Upsert( + ctx context.Context, req *payload.Upsert_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.UpsertRPCName), apiName+"/"+vald.UpsertRPCName) defer func() { if span != nil { @@ -3020,7 +3068,9 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) return nil } -func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiUpsert( + ctx context.Context, reqs *payload.Upsert_MultiRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiUpsertRPCName), apiName+"/"+vald.MultiUpsertRPCName) defer func() { if span != nil { @@ -3083,7 +3133,9 @@ func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequ return locs, errs } -func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (loc *payload.Object_Location, err error) { +func (s *server) Remove( + ctx context.Context, req *payload.Remove_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.RemoveRPCName), apiName+"/"+vald.RemoveRPCName) defer func() { if span != nil { @@ -3183,7 +3235,9 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) return nil } -func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiRemove( + ctx context.Context, reqs *payload.Remove_MultiRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.MultiRemoveRPCName), apiName+"/"+vald.MultiRemoveRPCName) defer func() { if span != nil { @@ -3246,7 +3300,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ return locs, errs } -func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (loc *payload.Info_Index_Count, err error) { +func (s *server) Flush( + ctx context.Context, req *payload.Flush_Request, +) (loc *payload.Info_Index_Count, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.FlushRPCName), apiName+"/"+vald.FlushRPCName) defer func() { if span != nil { @@ -3256,7 +3312,9 @@ func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (loc *pa return s.gateway.Flush(ctx, req, s.copts...) } -func (s *server) RemoveByTimestamp(ctx context.Context, req *payload.Remove_TimestampRequest) (*payload.Object_Locations, error) { +func (s *server) RemoveByTimestamp( + ctx context.Context, req *payload.Remove_TimestampRequest, +) (*payload.Object_Locations, error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.RemoveByTimestampRPCName), apiName+"/"+vald.RemoveByTimestampRPCName) defer func() { if span != nil { @@ -3299,7 +3357,9 @@ func (s *server) RemoveByTimestamp(ctx context.Context, req *payload.Remove_Time return locs, nil } -func (s *server) GetObject(ctx context.Context, req *payload.Object_VectorRequest) (vec *payload.Object_Vector, err error) { +func (s *server) GetObject( + ctx context.Context, req *payload.Object_VectorRequest, +) (vec *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FilterRPCServiceName+"/"+vald.GetObjectRPCName), apiName+"/"+vald.GetObjectRPCName) defer func() { if span != nil { diff --git a/pkg/gateway/filter/handler/grpc/handler_test.go b/pkg/gateway/filter/handler/grpc/handler_test.go index 08acfbc53b..377911df47 100644 --- a/pkg/gateway/filter/handler/grpc/handler_test.go +++ b/pkg/gateway/filter/handler/grpc/handler_test.go @@ -100,7 +100,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -274,7 +273,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -448,7 +446,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -615,7 +612,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -789,7 +785,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -963,7 +958,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1130,7 +1124,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1304,7 +1297,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1471,7 +1463,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1645,7 +1636,6 @@ package grpc // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1819,7 +1809,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1986,7 +1975,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2160,7 +2148,6 @@ package grpc // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2334,7 +2321,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2501,7 +2487,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2675,7 +2660,6 @@ package grpc // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -2849,7 +2833,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3023,7 +3006,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3197,7 +3179,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3364,7 +3345,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3531,7 +3511,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3705,7 +3684,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -3879,7 +3857,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -4053,7 +4030,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -4227,7 +4203,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -4394,7 +4369,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -4561,7 +4535,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -4735,7 +4708,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -4909,7 +4881,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -5083,7 +5054,6 @@ package grpc // if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -5250,7 +5220,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -5424,7 +5393,6 @@ package grpc // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -5598,7 +5566,6 @@ package grpc // if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -5765,7 +5732,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -5939,7 +5905,6 @@ package grpc // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -6113,7 +6078,6 @@ package grpc // if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -6280,7 +6244,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -6454,7 +6417,6 @@ package grpc // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -6628,7 +6590,6 @@ package grpc // if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -6795,7 +6756,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -6969,7 +6929,179 @@ package grpc // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func Test_server_Flush(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Flush_Request +// } +// type fields struct { +// eg errgroup.Group +// defaultVectorizer string +// defaultFilters []string +// name string +// ip string +// ingress ingress.Client +// egress egress.Client +// gateway client.Client +// copts []grpc.CallOption +// streamConcurrency int +// Vectorizer string +// DistanceFilters []string +// ObjectFilters []string +// SearchFilters []string +// InsertFilters []string +// UpdateFilters []string +// UpsertFilters []string +// UnimplementedValdServerWithFilter vald.UnimplementedValdServerWithFilter +// } +// type want struct { +// wantLoc *payload.Info_Index_Count +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Count, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLoc *payload.Info_Index_Count, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// defaultVectorizer:"", +// defaultFilters:nil, +// name:"", +// ip:"", +// ingress:nil, +// egress:nil, +// gateway:nil, +// copts:nil, +// streamConcurrency:0, +// Vectorizer:"", +// DistanceFilters:nil, +// ObjectFilters:nil, +// SearchFilters:nil, +// InsertFilters:nil, +// UpdateFilters:nil, +// UpsertFilters:nil, +// UnimplementedValdServerWithFilter: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// defaultVectorizer:"", +// defaultFilters:nil, +// name:"", +// ip:"", +// ingress:nil, +// egress:nil, +// gateway:nil, +// copts:nil, +// streamConcurrency:0, +// Vectorizer:"", +// DistanceFilters:nil, +// ObjectFilters:nil, +// SearchFilters:nil, +// InsertFilters:nil, +// UpdateFilters:nil, +// UpsertFilters:nil, +// UnimplementedValdServerWithFilter: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 +// } +// s := &server{ +// eg: test.fields.eg, +// defaultVectorizer: test.fields.defaultVectorizer, +// defaultFilters: test.fields.defaultFilters, +// name: test.fields.name, +// ip: test.fields.ip, +// ingress: test.fields.ingress, +// egress: test.fields.egress, +// gateway: test.fields.gateway, +// copts: test.fields.copts, +// streamConcurrency: test.fields.streamConcurrency, +// Vectorizer: test.fields.Vectorizer, +// DistanceFilters: test.fields.DistanceFilters, +// ObjectFilters: test.fields.ObjectFilters, +// SearchFilters: test.fields.SearchFilters, +// InsertFilters: test.fields.InsertFilters, +// UpdateFilters: test.fields.UpdateFilters, +// UpsertFilters: test.fields.UpsertFilters, +// UnimplementedValdServerWithFilter: test.fields.UnimplementedValdServerWithFilter, +// } +// +// gotLoc, err := s.Flush(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotLoc, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -7143,7 +7275,6 @@ package grpc // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -7317,7 +7448,6 @@ package grpc // if err := checkFunc(test.want, gotVec, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -7484,7 +7614,6 @@ package grpc // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/gateway/filter/handler/grpc/option_test.go b/pkg/gateway/filter/handler/grpc/option_test.go index 7d8557f80b..4221909396 100644 --- a/pkg/gateway/filter/handler/grpc/option_test.go +++ b/pkg/gateway/filter/handler/grpc/option_test.go @@ -100,7 +100,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -358,7 +355,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -444,7 +440,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -702,7 +695,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -788,7 +780,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -874,7 +865,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -960,7 +950,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1046,7 +1035,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1132,7 +1120,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1218,7 +1205,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/gateway/filter/handler/rest/handler.go b/pkg/gateway/filter/handler/rest/handler.go index bb2a7b24a7..f8d4c363c6 100644 --- a/pkg/gateway/filter/handler/rest/handler.go +++ b/pkg/gateway/filter/handler/rest/handler.go @@ -71,197 +71,199 @@ func New(opts ...Option) Handler { } func (*handler) Index(w http.ResponseWriter, r *http.Request) (int, error) { - data := make(map[string]interface{}) - return json.Handler(w, r, &data, func() (interface{}, error) { + data := make(map[string]any) + return json.Handler(w, r, &data, func() (any, error) { return dump.Request(nil, data, r) }) } func (h *handler) Search(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Search(r.Context(), req) }) } func (h *handler) SearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.SearchByID(r.Context(), req) }) } func (h *handler) MultiSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiSearch(r.Context(), req) }) } func (h *handler) MultiSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiIDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiSearchByID(r.Context(), req) }) } func (h *handler) LinearSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.LinearSearch(r.Context(), req) }) } func (h *handler) LinearSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.LinearSearchByID(r.Context(), req) }) } func (h *handler) MultiLinearSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiLinearSearch(r.Context(), req) }) } -func (h *handler) MultiLinearSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { +func (h *handler) MultiLinearSearchByID( + w http.ResponseWriter, r *http.Request, +) (code int, err error) { var req *payload.Search_MultiIDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiLinearSearchByID(r.Context(), req) }) } func (h *handler) Insert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Insert(r.Context(), req) }) } func (h *handler) MultiInsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiInsert(r.Context(), req) }) } func (h *handler) Update(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Update(r.Context(), req) }) } func (h *handler) MultiUpdate(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiUpdate(r.Context(), req) }) } func (h *handler) Upsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Upsert_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Upsert(r.Context(), req) }) } func (h *handler) MultiUpsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Upsert_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiUpsert(r.Context(), req) }) } func (h *handler) Remove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Remove(r.Context(), req) }) } func (h *handler) MultiRemove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiRemove(r.Context(), req) }) } func (h *handler) Flush(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Flush_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Flush(r.Context(), req) }) } func (h *handler) GetObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_VectorRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.GetObject(r.Context(), req) }) } func (h *handler) Exists(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_ID - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Exists(r.Context(), req) }) } func (h *handler) SearchObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_ObjectRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.SearchObject(r.Context(), req) }) } func (h *handler) InsertObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_ObjectRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.InsertObject(r.Context(), req) }) } func (h *handler) UpdateObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_ObjectRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.UpdateObject(r.Context(), req) }) } func (h *handler) UpsertObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Upsert_ObjectRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.UpsertObject(r.Context(), req) }) } func (h *handler) MultiSearchObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiObjectRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiSearchObject(r.Context(), req) }) } func (h *handler) MultiInsertObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_MultiObjectRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiInsertObject(r.Context(), req) }) } func (h *handler) MultiUpdateObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_MultiObjectRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiUpdateObject(r.Context(), req) }) } func (h *handler) MultiUpsertObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Upsert_MultiObjectRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiUpsertObject(r.Context(), req) }) } diff --git a/pkg/gateway/filter/handler/rest/handler_test.go b/pkg/gateway/filter/handler/rest/handler_test.go new file mode 100644 index 0000000000..b12992a932 --- /dev/null +++ b/pkg/gateway/filter/handler/rest/handler_test.go @@ -0,0 +1,3041 @@ +// 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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Index(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// want int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// got, err := h.Index(test.args.w, test.args.r) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Search(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Search(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_SearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.SearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.LinearSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.LinearSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiLinearSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiLinearSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiLinearSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiLinearSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Insert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Insert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiInsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiInsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Update(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Update(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpdate(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiUpdate(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Upsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Upsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiUpsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Remove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Remove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiRemove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiRemove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Flush(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Flush(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_GetObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.GetObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Exists(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Exists(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_SearchObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.SearchObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_InsertObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.InsertObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_UpdateObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.UpdateObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_UpsertObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.UpsertObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiSearchObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiSearchObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiInsertObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiInsertObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpdateObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiUpdateObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpsertObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.ServerWithFilter +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiUpsertObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/filter/handler/rest/option_test.go b/pkg/gateway/filter/handler/rest/option_test.go new file mode 100644 index 0000000000..45a06ff42a --- /dev/null +++ b/pkg/gateway/filter/handler/rest/option_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestWithVald(t *testing.T) { +// type args struct { +// v vald.ServerWithFilter +// } +// 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 { +// v: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 { +// v: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 := WithVald(test.args.v) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/filter/router/option.go b/pkg/gateway/filter/router/option.go index 15d81aeed2..a45c264466 100644 --- a/pkg/gateway/filter/router/option.go +++ b/pkg/gateway/filter/router/option.go @@ -17,9 +17,7 @@ // Package router provides implementation of Go API for routing http Handler wrapped by rest.Func package router -import ( - "github.com/vdaas/vald/pkg/gateway/filter/handler/rest" -) +import "github.com/vdaas/vald/pkg/gateway/filter/handler/rest" type Option func(*router) diff --git a/pkg/gateway/filter/router/option_test.go b/pkg/gateway/filter/router/option_test.go new file mode 100644 index 0000000000..c39d90a7bc --- /dev/null +++ b/pkg/gateway/filter/router/option_test.go @@ -0,0 +1,186 @@ +// 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 router + +// NOT IMPLEMENTED BELOW +// +// func TestWithHandler(t *testing.T) { +// type args struct { +// h rest.Handler +// } +// 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 { +// h: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 { +// h: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 := WithHandler(test.args.h) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTimeout(t *testing.T) { +// type args struct { +// timeout 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 { +// timeout:"", +// }, +// 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 { +// timeout:"", +// }, +// 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 := WithTimeout(test.args.timeout) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/filter/router/router_test.go b/pkg/gateway/filter/router/router_test.go new file mode 100644 index 0000000000..e9e3069588 --- /dev/null +++ b/pkg/gateway/filter/router/router_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 router + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want http.Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, http.Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got http.Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/filter/usecase/vald_test.go b/pkg/gateway/filter/usecase/vald_test.go index 483e3950e7..099617b125 100644 --- a/pkg/gateway/filter/usecase/vald_test.go +++ b/pkg/gateway/filter/usecase/vald_test.go @@ -103,7 +103,620 @@ package usecase // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// client client.Client +// ingress ingress.Client +// egress egress.Client +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// client: test.fields.client, +// ingress: test.fields.ingress, +// egress: test.fields.egress, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// client client.Client +// ingress ingress.Client +// egress egress.Client +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// client: test.fields.client, +// ingress: test.fields.ingress, +// egress: test.fields.egress, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// client client.Client +// ingress ingress.Client +// egress egress.Client +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// client: test.fields.client, +// ingress: test.fields.ingress, +// egress: test.fields.egress, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// client client.Client +// ingress ingress.Client +// egress egress.Client +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// client: test.fields.client, +// ingress: test.fields.ingress, +// egress: test.fields.egress, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// client client.Client +// ingress ingress.Client +// egress egress.Client +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// client:nil, +// ingress:nil, +// egress: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// client: test.fields.client, +// ingress: test.fields.ingress, +// egress: test.fields.egress, +// } +// +// err := r.PostStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/gateway/lb/config/config_test.go b/pkg/gateway/lb/config/config_test.go index 2d7afeecdd..5a237d0a9f 100644 --- a/pkg/gateway/lb/config/config_test.go +++ b/pkg/gateway/lb/config/config_test.go @@ -104,7 +104,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/gateway/lb/handler/grpc/aggregation.go b/pkg/gateway/lb/handler/grpc/aggregation.go index 21eededf57..596762cabc 100644 --- a/pkg/gateway/lb/handler/grpc/aggregation.go +++ b/pkg/gateway/lb/handler/grpc/aggregation.go @@ -49,13 +49,14 @@ type DistPayload struct { distance *big.Float } -func (s *server) aggregationSearch(ctx context.Context, aggr Aggregator, +func (s *server) aggregationSearch( + ctx context.Context, + aggr Aggregator, bcfg *payload.Search_Config, // Base Config of Request f func(ctx context.Context, fcfg *payload.Search_Config, // Forwarding Config to Agent - vc vald.Client, copts ...grpc.CallOption) (*payload.Search_Response, error)) ( - res *payload.Search_Response, err error, -) { + vc vald.Client, copts ...grpc.CallOption) (*payload.Search_Response, error), +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "aggregationSearch"), apiName+"/aggregationSearch") defer func() { if span != nil { @@ -665,7 +666,7 @@ type valdPoolSliceAggr struct { var ( poolDist = sync.Pool{ - New: func() interface{} { + New: func() any { return make([]*DistPayload, 0, poolLen.Load()) }, } diff --git a/pkg/gateway/lb/handler/grpc/aggregation_test.go b/pkg/gateway/lb/handler/grpc/aggregation_test.go index 7e21174f58..083d0b42cb 100644 --- a/pkg/gateway/lb/handler/grpc/aggregation_test.go +++ b/pkg/gateway/lb/handler/grpc/aggregation_test.go @@ -15,12 +15,247 @@ package grpc // NOT IMPLEMENTED BELOW // +// func Test_server_aggregationSearch(t *testing.T) { +// type args struct { +// ctx context.Context +// aggr Aggregator +// bcfg *payload.Search_Config +// f func(ctx context.Context, fcfg *payload.Search_Config, vc vald.Client, copts ...grpc.CallOption) (*payload.Search_Response, error) +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantRes *payload.Search_Response +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *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 { +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// aggr:nil, +// bcfg:nil, +// f:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// aggr:nil, +// bcfg:nil, +// f:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotRes, err := s.aggregationSearch(test.args.ctx, test.args.aggr, test.args.bcfg, test.args.f) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_newStd(t *testing.T) { +// type args struct { +// num int +// fnum int +// replica int +// } +// type want struct { +// want Aggregator +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Aggregator) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Aggregator) 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 { +// num:0, +// fnum:0, +// replica: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 { +// num:0, +// fnum:0, +// replica: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 := newStd(test.args.num, test.args.fnum, test.args.replica) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func Test_valdStdAggr_Start(t *testing.T) { // type args struct { // ctx context.Context // } // type fields struct { // num int +// fnum int // dch chan DistPayload // closed atomic.Bool // maxDist atomic.Value @@ -28,8 +263,7 @@ package grpc // result []*payload.Object_Distance // cancel context.CancelFunc // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -52,6 +286,7 @@ package grpc // }, // fields: fields { // num:0, +// fnum:0, // dch:nil, // closed:nil, // maxDist:nil, @@ -80,6 +315,7 @@ package grpc // }, // fields: fields { // num:0, +// fnum:0, // dch:nil, // closed:nil, // maxDist:nil, @@ -117,6 +353,7 @@ package grpc // } // v := &valdStdAggr{ // num: test.fields.num, +// fnum: test.fields.fnum, // dch: test.fields.dch, // closed: test.fields.closed, // maxDist: test.fields.maxDist, @@ -140,6 +377,7 @@ package grpc // } // type fields struct { // num int +// fnum int // dch chan DistPayload // closed atomic.Bool // maxDist atomic.Value @@ -147,8 +385,7 @@ package grpc // result []*payload.Object_Distance // cancel context.CancelFunc // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -172,6 +409,7 @@ package grpc // }, // fields: fields { // num:0, +// fnum:0, // dch:nil, // closed:nil, // maxDist:nil, @@ -201,6 +439,7 @@ package grpc // }, // fields: fields { // num:0, +// fnum:0, // dch:nil, // closed:nil, // maxDist:nil, @@ -238,6 +477,7 @@ package grpc // } // v := &valdStdAggr{ // num: test.fields.num, +// fnum: test.fields.fnum, // dch: test.fields.dch, // closed: test.fields.closed, // maxDist: test.fields.maxDist, @@ -257,6 +497,7 @@ package grpc // func Test_valdStdAggr_Result(t *testing.T) { // type fields struct { // num int +// fnum int // dch chan DistPayload // closed atomic.Bool // maxDist atomic.Value @@ -288,6 +529,7 @@ package grpc // name: "test_case_1", // fields: fields { // num:0, +// fnum:0, // dch:nil, // closed:nil, // maxDist:nil, @@ -313,6 +555,7 @@ package grpc // name: "test_case_2", // fields: fields { // num:0, +// fnum:0, // dch:nil, // closed:nil, // maxDist:nil, @@ -350,6 +593,7 @@ package grpc // } // v := &valdStdAggr{ // num: test.fields.num, +// fnum: test.fields.fnum, // dch: test.fields.dch, // closed: test.fields.closed, // maxDist: test.fields.maxDist, @@ -362,33 +606,36 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_valdPairingHeapAggr_Start(t *testing.T) { -// type args struct { -// in0 context.Context -// } +// func Test_valdStdAggr_GetNum(t *testing.T) { // type fields struct { // num int -// ph *PairingHeap +// fnum int +// dch chan DistPayload +// closed atomic.Bool +// maxDist atomic.Value // visited sync.Map[string, any] // result []*payload.Object_Distance +// cancel context.CancelFunc // } // type want struct { +// want int // } // 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) +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want) error { +// defaultCheckFunc := func(w want, got int) 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{ @@ -396,21 +643,22 @@ package grpc // /* // { // name: "test_case_1", -// args: args { -// in0:nil, -// }, // fields: fields { // num:0, -// ph:PairingHeap{}, +// fnum:0, +// dch:nil, +// closed:nil, +// maxDist:nil, // visited:nil, // result:nil, +// cancel:nil, // }, // 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() // }, // }, @@ -421,21 +669,1255 @@ package grpc // func() test { // return test { // name: "test_case_2", -// args: args { -// in0:nil, -// }, // fields: fields { // num:0, -// ph:PairingHeap{}, +// fnum:0, +// dch:nil, +// closed:nil, +// maxDist:nil, // visited:nil, // result:nil, +// cancel: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 +// } +// v := &valdStdAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// dch: test.fields.dch, +// closed: test.fields.closed, +// maxDist: test.fields.maxDist, +// visited: test.fields.visited, +// result: test.fields.result, +// cancel: test.fields.cancel, +// } +// +// got := v.GetNum() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdStdAggr_GetFnum(t *testing.T) { +// type fields struct { +// num int +// fnum int +// dch chan DistPayload +// closed atomic.Bool +// maxDist atomic.Value +// visited sync.Map[string, any] +// result []*payload.Object_Distance +// cancel context.CancelFunc +// } +// type want struct { +// want int +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got int) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// num:0, +// fnum:0, +// dch:nil, +// closed:nil, +// maxDist:nil, +// visited:nil, +// result:nil, +// cancel: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 { +// num:0, +// fnum:0, +// dch:nil, +// closed:nil, +// maxDist:nil, +// visited:nil, +// result:nil, +// cancel: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 +// } +// v := &valdStdAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// dch: test.fields.dch, +// closed: test.fields.closed, +// maxDist: test.fields.maxDist, +// visited: test.fields.visited, +// result: test.fields.result, +// cancel: test.fields.cancel, +// } +// +// got := v.GetFnum() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_newPairingHeap(t *testing.T) { +// type args struct { +// num int +// fnum int +// replica int +// } +// type want struct { +// want Aggregator +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Aggregator) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Aggregator) 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 { +// num:0, +// fnum:0, +// replica: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 { +// num:0, +// fnum:0, +// replica: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 := newPairingHeap(test.args.num, test.args.fnum, test.args.replica) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdPairingHeapAggr_Start(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// num int +// fnum int +// ph *PairingHeap +// visited sync.Map[string, any] +// result []*payload.Object_Distance +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 { +// in0:nil, +// }, +// fields: fields { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 +// } +// v := &valdPairingHeapAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// ph: test.fields.ph, +// visited: test.fields.visited, +// result: test.fields.result, +// } +// +// v.Start(test.args.in0) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdPairingHeapAggr_Send(t *testing.T) { +// type args struct { +// ctx context.Context +// data *payload.Search_Response +// } +// type fields struct { +// num int +// fnum int +// ph *PairingHeap +// visited sync.Map[string, any] +// result []*payload.Object_Distance +// } +// 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 { +// ctx:nil, +// data:nil, +// }, +// fields: fields { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 { +// ctx:nil, +// data:nil, +// }, +// fields: fields { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 +// } +// v := &valdPairingHeapAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// ph: test.fields.ph, +// visited: test.fields.visited, +// result: test.fields.result, +// } +// +// v.Send(test.args.ctx, test.args.data) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdPairingHeapAggr_Result(t *testing.T) { +// type fields struct { +// num int +// fnum int +// ph *PairingHeap +// visited sync.Map[string, any] +// result []*payload.Object_Distance +// } +// type want struct { +// want *payload.Search_Response +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *payload.Search_Response) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *payload.Search_Response) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 +// } +// v := &valdPairingHeapAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// ph: test.fields.ph, +// visited: test.fields.visited, +// result: test.fields.result, +// } +// +// got := v.Result() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdPairingHeapAggr_GetNum(t *testing.T) { +// type fields struct { +// num int +// fnum int +// ph *PairingHeap +// visited sync.Map[string, any] +// result []*payload.Object_Distance +// } +// type want struct { +// want int +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got int) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 +// } +// v := &valdPairingHeapAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// ph: test.fields.ph, +// visited: test.fields.visited, +// result: test.fields.result, +// } +// +// got := v.GetNum() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdPairingHeapAggr_GetFnum(t *testing.T) { +// type fields struct { +// num int +// fnum int +// ph *PairingHeap +// visited sync.Map[string, any] +// result []*payload.Object_Distance +// } +// type want struct { +// want int +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got int) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 { +// num:0, +// fnum:0, +// ph:PairingHeap{}, +// visited:nil, +// result: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 +// } +// v := &valdPairingHeapAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// ph: test.fields.ph, +// visited: test.fields.visited, +// result: test.fields.result, +// } +// +// got := v.GetFnum() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_newSlice(t *testing.T) { +// type args struct { +// num int +// fnum int +// replica int +// } +// type want struct { +// want Aggregator +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Aggregator) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Aggregator) 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 { +// num:0, +// fnum:0, +// replica: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 { +// num:0, +// fnum:0, +// replica: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 := newSlice(test.args.num, test.args.fnum, test.args.replica) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdSliceAggr_Start(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// num int +// fnum int +// result []*DistPayload +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// num:0, +// fnum:0, +// result: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 { +// in0:nil, +// }, +// fields: fields { +// num:0, +// fnum:0, +// result: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 +// } +// v := &valdSliceAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// result: test.fields.result, +// } +// +// v.Start(test.args.in0) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdSliceAggr_Send(t *testing.T) { +// type args struct { +// ctx context.Context +// data *payload.Search_Response +// } +// type fields struct { +// num int +// fnum int +// result []*DistPayload +// } +// 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 { +// ctx:nil, +// data:nil, +// }, +// fields: fields { +// num:0, +// fnum:0, +// result: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 { +// ctx:nil, +// data:nil, +// }, +// fields: fields { +// num:0, +// fnum:0, +// result: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 +// } +// v := &valdSliceAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// result: test.fields.result, +// } +// +// v.Send(test.args.ctx, test.args.data) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdSliceAggr_Result(t *testing.T) { +// type fields struct { +// num int +// fnum int +// result []*DistPayload +// } +// type want struct { +// wantRes *payload.Search_Response +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *payload.Search_Response) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Search_Response) error { +// if !reflect.DeepEqual(gotRes, w.wantRes) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// num:0, +// fnum:0, +// result: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 { +// num:0, +// fnum:0, +// result: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 +// } +// v := &valdSliceAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// result: test.fields.result, +// } +// +// gotRes := v.Result() +// if err := checkFunc(test.want, gotRes); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_valdSliceAggr_GetNum(t *testing.T) { +// type fields struct { +// num int +// fnum int +// result []*DistPayload +// } +// type want struct { +// want int +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got int) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// num:0, +// fnum:0, +// result: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 { +// num:0, +// fnum:0, +// result:nil, // }, // 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() // }, // } @@ -449,53 +1931,50 @@ package grpc // 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 { // checkFunc = defaultCheckFunc // } -// v := &valdPairingHeapAggr{ -// num: test.fields.num, -// ph: test.fields.ph, -// visited: test.fields.visited, -// result: test.fields.result, +// v := &valdSliceAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// result: test.fields.result, // } // -// v.Start(test.args.in0) -// if err := checkFunc(test.want); err != nil { +// got := v.GetNum() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_valdPairingHeapAggr_Send(t *testing.T) { -// type args struct { -// ctx context.Context -// data *payload.Search_Response -// } +// func Test_valdSliceAggr_GetFnum(t *testing.T) { // type fields struct { -// num int -// ph *PairingHeap -// visited sync.Map[string, any] -// result []*payload.Object_Distance +// num int +// fnum int +// result []*DistPayload // } // type want struct { +// want int // } // 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) +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want) error { +// defaultCheckFunc := func(w want, got int) 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{ @@ -503,22 +1982,17 @@ package grpc // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// data:nil, -// }, // fields: fields { // num:0, -// ph:PairingHeap{}, -// visited:nil, +// fnum:0, // result:nil, // }, // 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() // }, // }, @@ -529,22 +2003,17 @@ package grpc // func() test { // return test { // name: "test_case_2", -// args: args { -// ctx:nil, -// data:nil, -// }, // fields: fields { // num:0, -// ph:PairingHeap{}, -// visited:nil, +// fnum:0, // result:nil, // }, // 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() // }, // } @@ -558,49 +2027,47 @@ package grpc // 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 { // checkFunc = defaultCheckFunc // } -// v := &valdPairingHeapAggr{ -// num: test.fields.num, -// ph: test.fields.ph, -// visited: test.fields.visited, -// result: test.fields.result, +// v := &valdSliceAggr{ +// num: test.fields.num, +// fnum: test.fields.fnum, +// result: test.fields.result, // } // -// v.Send(test.args.ctx, test.args.data) -// if err := checkFunc(test.want); err != nil { +// got := v.GetFnum() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_valdPairingHeapAggr_Result(t *testing.T) { -// type fields struct { +// func Test_newPoolSlice(t *testing.T) { +// type args struct { // num int -// ph *PairingHeap -// visited sync.Map[string, any] -// result []*payload.Object_Distance +// fnum int +// replica int // } // type want struct { -// want *payload.Search_Response +// want Aggregator // } // type test struct { // name string -// fields fields +// args args // want want -// checkFunc func(want, *payload.Search_Response) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) +// checkFunc func(want, Aggregator) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got *payload.Search_Response) error { +// defaultCheckFunc := func(w want, got Aggregator) error { // if !reflect.DeepEqual(got, w.want) { // return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } @@ -611,18 +2078,17 @@ package grpc // /* // { // name: "test_case_1", -// fields: fields { +// args: args { // num:0, -// ph:PairingHeap{}, -// visited:nil, -// result:nil, +// fnum:0, +// replica:0, // }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // }, @@ -633,18 +2099,17 @@ package grpc // func() test { // return test { // name: "test_case_2", -// fields: fields { +// args: args { // num:0, -// ph:PairingHeap{}, -// visited:nil, -// result:nil, +// fnum:0, +// replica:0, // }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // } @@ -658,41 +2123,34 @@ package grpc // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt) +// test.beforeFunc(tt, test.args) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt) +// defer test.afterFunc(tt, test.args) // } // checkFunc := test.checkFunc // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// v := &valdPairingHeapAggr{ -// num: test.fields.num, -// ph: test.fields.ph, -// visited: test.fields.visited, -// result: test.fields.result, -// } // -// got := v.Result() +// got := newPoolSlice(test.args.num, test.args.fnum, test.args.replica) // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_valdSliceAggr_Start(t *testing.T) { +// func Test_valdPoolSliceAggr_Start(t *testing.T) { // type args struct { // in0 context.Context // } // type fields struct { // num int +// fnum int // result []*DistPayload // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -715,6 +2173,7 @@ package grpc // }, // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // want: want{}, @@ -738,6 +2197,7 @@ package grpc // }, // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // want: want{}, @@ -768,8 +2228,9 @@ package grpc // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// v := &valdSliceAggr{ +// v := &valdPoolSliceAggr{ // num: test.fields.num, +// fnum: test.fields.fnum, // result: test.fields.result, // } // @@ -781,17 +2242,17 @@ package grpc // } // } // -// func Test_valdSliceAggr_Send(t *testing.T) { +// func Test_valdPoolSliceAggr_Send(t *testing.T) { // type args struct { // ctx context.Context // data *payload.Search_Response // } // type fields struct { // num int +// fnum int // result []*DistPayload // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -815,6 +2276,7 @@ package grpc // }, // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // want: want{}, @@ -839,6 +2301,7 @@ package grpc // }, // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // want: want{}, @@ -869,8 +2332,9 @@ package grpc // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// v := &valdSliceAggr{ +// v := &valdPoolSliceAggr{ // num: test.fields.num, +// fnum: test.fields.fnum, // result: test.fields.result, // } // @@ -882,9 +2346,10 @@ package grpc // } // } // -// func Test_valdSliceAggr_Result(t *testing.T) { +// func Test_valdPoolSliceAggr_Result(t *testing.T) { // type fields struct { // num int +// fnum int // result []*DistPayload // } // type want struct { @@ -911,6 +2376,7 @@ package grpc // name: "test_case_1", // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // want: want{}, @@ -931,6 +2397,7 @@ package grpc // name: "test_case_2", // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // want: want{}, @@ -961,8 +2428,9 @@ package grpc // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// v := &valdSliceAggr{ +// v := &valdPoolSliceAggr{ // num: test.fields.num, +// fnum: test.fields.fnum, // result: test.fields.result, // } // @@ -970,31 +2438,31 @@ package grpc // if err := checkFunc(test.want, gotRes); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_valdPoolSliceAggr_Start(t *testing.T) { -// type args struct { -// in0 context.Context -// } +// func Test_valdPoolSliceAggr_GetNum(t *testing.T) { // type fields struct { // num int +// fnum int // result []*DistPayload // } // type want struct { +// want int // } // 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) +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want) error { +// defaultCheckFunc := func(w want, got int) 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{ @@ -1002,19 +2470,17 @@ package grpc // /* // { // name: "test_case_1", -// args: args { -// in0:nil, -// }, // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // 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() // }, // }, @@ -1025,19 +2491,17 @@ package grpc // func() test { // return test { // name: "test_case_2", -// args: args { -// in0:nil, -// }, // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // 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() // }, // } @@ -1051,10 +2515,10 @@ package grpc // 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 { @@ -1062,38 +2526,39 @@ package grpc // } // v := &valdPoolSliceAggr{ // num: test.fields.num, +// fnum: test.fields.fnum, // result: test.fields.result, // } // -// v.Start(test.args.in0) -// if err := checkFunc(test.want); err != nil { +// got := v.GetNum() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_valdPoolSliceAggr_Send(t *testing.T) { -// type args struct { -// ctx context.Context -// data *payload.Search_Response -// } +// func Test_valdPoolSliceAggr_GetFnum(t *testing.T) { // type fields struct { // num int +// fnum int // result []*DistPayload // } // type want struct { +// want int // } // 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) +// checkFunc func(want, int) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want) error { +// defaultCheckFunc := func(w want, got int) 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{ @@ -1101,20 +2566,17 @@ package grpc // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// data:nil, -// }, // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // 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() // }, // }, @@ -1125,20 +2587,17 @@ package grpc // func() test { // return test { // name: "test_case_2", -// args: args { -// ctx:nil, -// data:nil, -// }, // fields: fields { // num:0, +// fnum:0, // result:nil, // }, // 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() // }, // } @@ -1152,10 +2611,10 @@ package grpc // 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 { @@ -1163,36 +2622,37 @@ package grpc // } // v := &valdPoolSliceAggr{ // num: test.fields.num, +// fnum: test.fields.fnum, // result: test.fields.result, // } // -// v.Send(test.args.ctx, test.args.data) -// if err := checkFunc(test.want); err != nil { +// got := v.GetFnum() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_valdPoolSliceAggr_Result(t *testing.T) { -// type fields struct { -// num int -// result []*DistPayload +// func Test_removeDuplicates(t *testing.T) { +// type args struct { +// x S +// less func(left, right E) int // } // type want struct { -// wantRes *payload.Search_Response +// want S // } // type test struct { // name string -// fields fields +// args args // want want -// checkFunc func(want, *payload.Search_Response) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) +// checkFunc func(want, S) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Search_Response) error { -// if !reflect.DeepEqual(gotRes, w.wantRes) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) +// defaultCheckFunc := func(w want, got S) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -1201,16 +2661,16 @@ package grpc // /* // { // name: "test_case_1", -// fields: fields { -// num:0, -// result:nil, +// args: args { +// x:nil, +// less:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // }, @@ -1221,16 +2681,16 @@ package grpc // func() test { // return test { // name: "test_case_2", -// fields: fields { -// num:0, -// result:nil, +// args: args { +// x:nil, +// less:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // } @@ -1244,25 +2704,20 @@ package grpc // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt) +// test.beforeFunc(tt, test.args) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt) +// defer test.afterFunc(tt, test.args) // } // checkFunc := test.checkFunc // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// v := &valdPoolSliceAggr{ -// num: test.fields.num, -// result: test.fields.result, -// } // -// gotRes := v.Result() -// if err := checkFunc(test.want, gotRes); err != nil { +// got := removeDuplicates(test.args.x, test.args.less) +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/gateway/lb/handler/grpc/handler.go b/pkg/gateway/lb/handler/grpc/handler.go index b79ac366af..acfdfad8f3 100644 --- a/pkg/gateway/lb/handler/grpc/handler.go +++ b/pkg/gateway/lb/handler/grpc/handler.go @@ -206,7 +206,9 @@ func (s *server) exists(ctx context.Context, uuid string) (id *payload.Object_ID return id, nil } -func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *payload.Object_ID, err error) { +func (s *server) Exists( + ctx context.Context, meta *payload.Object_ID, +) (id *payload.Object_ID, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.ObjectRPCServiceName+"/"+vald.ExistsRPCName), apiName+"/"+vald.ExistsRPCName) defer func() { if span != nil { @@ -267,7 +269,9 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *paylo return nil, err } -func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) Search( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.SearchRPCName), apiName+"/"+vald.SearchRPCName) defer func() { if span != nil { @@ -321,9 +325,9 @@ func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res * return res, nil } -func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) ( - res *payload.Search_Response, err error, -) { +func (s *server) SearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.SearchByIDRPCName), apiName+"/"+vald.SearchByIDRPCName) defer func() { if span != nil { @@ -451,7 +455,7 @@ func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) // calculateNum adjusts the number of search results based on the ratio and the number of replicas. // It ensures that the number of results is not less than the minimum required and adjusts based on the provided ratio. func (s *server) calculateNum(ctx context.Context, num uint32, ratio float32) (n uint32) { - min := float64(s.replica) / float64(len(s.gateway.Addrs(ctx))) + min := float64(s.replica) / float64(s.gateway.GetAgentCount(ctx)) if ratio <= 0.0 { return uint32(math.Ceil(float64(num) * min)) } @@ -463,10 +467,11 @@ func (s *server) calculateNum(ctx context.Context, num uint32, ratio float32) (n return n - 1 } -func (s *server) doSearch(ctx context.Context, cfg *payload.Search_Config, - f func(ctx context.Context, cfg *payload.Search_Config, vc vald.Client, copts ...grpc.CallOption) (*payload.Search_Response, error)) ( - res *payload.Search_Response, err error, -) { +func (s *server) doSearch( + ctx context.Context, + cfg *payload.Search_Config, + f func(ctx context.Context, cfg *payload.Search_Config, vc vald.Client, copts ...grpc.CallOption) (*payload.Search_Response, error), +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "doSearch"), apiName+"/doSearch") defer func() { if span != nil { @@ -601,7 +606,9 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er return nil } -func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiSearch( + ctx context.Context, reqs *payload.Search_MultiRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.MultiSearchRPCName), apiName+"/"+vald.MultiSearchRPCName) defer func() { if span != nil { @@ -675,7 +682,9 @@ func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequ return res, nil } -func (s *server) MultiSearchByID(ctx context.Context, reqs *payload.Search_MultiIDRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiSearchByID( + ctx context.Context, reqs *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.MultiSearchByIDRPCName), apiName+"/"+vald.MultiSearchByIDRPCName) defer func() { if span != nil { @@ -750,7 +759,9 @@ func (s *server) MultiSearchByID(ctx context.Context, reqs *payload.Search_Multi return res, nil } -func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) LinearSearch( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.LinearSearchRPCName), apiName+"/"+vald.LinearSearchRPCName) defer func() { if span != nil { @@ -804,9 +815,9 @@ func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) return res, nil } -func (s *server) LinearSearchByID(ctx context.Context, req *payload.Search_IDRequest) ( - res *payload.Search_Response, err error, -) { +func (s *server) LinearSearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.LinearSearchByIDRPCName), apiName+"/"+vald.LinearSearchByIDRPCName) defer func() { if span != nil { @@ -979,7 +990,9 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) return nil } -func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByIDServer) (err error) { +func (s *server) StreamLinearSearchByID( + stream vald.Search_StreamLinearSearchByIDServer, +) (err error) { ctx, span := trace.StartSpan( grpc.WithGRPCMethod(stream.Context(), vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.StreamLinearSearchByIDRPCName), apiName+"/"+vald.StreamLinearSearchByIDRPCName, @@ -1030,7 +1043,9 @@ func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByI return nil } -func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_MultiRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiLinearSearch( + ctx context.Context, reqs *payload.Search_MultiRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.MultiLinearSearchRPCName), apiName+"/"+vald.MultiLinearSearchRPCName) defer func() { if span != nil { @@ -1104,7 +1119,9 @@ func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_Mul return res, nil } -func (s *server) MultiLinearSearchByID(ctx context.Context, reqs *payload.Search_MultiIDRequest) (res *payload.Search_Responses, errs error) { +func (s *server) MultiLinearSearchByID( + ctx context.Context, reqs *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.MultiLinearSearchByIDRPCName), apiName+"/"+vald.MultiLinearSearchByIDRPCName) defer func() { if span != nil { @@ -1179,7 +1196,9 @@ func (s *server) MultiLinearSearchByID(ctx context.Context, reqs *payload.Search return res, nil } -func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (ce *payload.Object_Location, err error) { +func (s *server) Insert( + ctx context.Context, req *payload.Insert_Request, +) (ce *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.InsertRPCServiceName+"/"+vald.InsertRPCName), apiName+"/"+vald.InsertRPCName) defer func() { if span != nil { @@ -1447,7 +1466,9 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) return nil } -func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiInsert( + ctx context.Context, reqs *payload.Insert_MultiRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.InsertRPCServiceName+"/"+vald.MultiInsertRPCName), apiName+"/"+vald.MultiInsertRPCName) defer func() { if span != nil { @@ -1560,7 +1581,9 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ return locs, errs } -func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res *payload.Object_Location, err error) { +func (s *server) Update( + ctx context.Context, req *payload.Update_Request, +) (res *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.UpdateRPCServiceName+"/"+vald.UpdateRPCName), apiName+"/"+vald.UpdateRPCName) defer func() { if span != nil { @@ -1983,7 +2006,9 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) return nil } -func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiUpdate( + ctx context.Context, reqs *payload.Update_MultiRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.UpdateRPCServiceName+"/"+vald.MultiUpdateRPCName), apiName+"/"+vald.MultiUpdateRPCName) defer func() { if span != nil { @@ -2096,7 +2121,9 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ return locs, errs } -func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc *payload.Object_Location, err error) { +func (s *server) Upsert( + ctx context.Context, req *payload.Upsert_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.UpsertRPCServiceName+"/"+vald.UpsertRPCName), apiName+"/"+vald.UpsertRPCName) defer func() { if span != nil { @@ -2331,7 +2358,9 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) return nil } -func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiUpsert( + ctx context.Context, reqs *payload.Upsert_MultiRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.UpsertRPCServiceName+"/"+vald.MultiUpsertRPCName), apiName+"/"+vald.MultiUpsertRPCName) defer func() { if span != nil { @@ -2444,7 +2473,9 @@ func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequ return locs, errs } -func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (locs *payload.Object_Location, err error) { +func (s *server) Remove( + ctx context.Context, req *payload.Remove_Request, +) (locs *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.RemoveRPCServiceName+"/"+vald.RemoveRPCName), apiName+"/"+vald.RemoveRPCName) defer func() { if span != nil { @@ -2634,7 +2665,9 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) return nil } -func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) MultiRemove( + ctx context.Context, reqs *payload.Remove_MultiRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.RemoveRPCServiceName+"/"+vald.MultiRemoveRPCName), apiName+"/"+vald.MultiRemoveRPCName) defer func() { if span != nil { @@ -2736,7 +2769,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ return locs, errs } -func (s *server) RemoveByTimestamp(ctx context.Context, req *payload.Remove_TimestampRequest) (locs *payload.Object_Locations, errs error) { +func (s *server) RemoveByTimestamp( + ctx context.Context, req *payload.Remove_TimestampRequest, +) (locs *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.RemoveRPCServiceName+"/"+vald.RemoveByTimestampRPCName), apiName+"/"+vald.RemoveByTimestampRPCName) defer func() { if span != nil { @@ -2861,7 +2896,9 @@ func (s *server) RemoveByTimestamp(ctx context.Context, req *payload.Remove_Time return locs, nil } -func (s *server) getObject(ctx context.Context, uuid string) (vec *payload.Object_Vector, err error) { +func (s *server) getObject( + ctx context.Context, uuid string, +) (vec *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "getObject"), apiName+"/"+vald.GetObjectRPCName+"/getObject") defer func() { if span != nil { @@ -2989,7 +3026,9 @@ func (s *server) getObject(ctx context.Context, uuid string) (vec *payload.Objec return vec, nil } -func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (cnts *payload.Info_Index_Count, err error) { +func (s *server) Flush( + ctx context.Context, req *payload.Flush_Request, +) (cnts *payload.Info_Index_Count, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.FlushRPCServiceName+"/"+vald.FlushRPCName), apiName+"/"+vald.FlushRPCName) defer func() { if span != nil { @@ -3072,7 +3111,7 @@ func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (cnts *p } if cnts.Stored > 0 || cnts.Uncommitted > 0 || cnts.Indexing || cnts.Saving { err = errors.Errorf( - "stored index: %d, uncommited: %d, indexing: %t, saving: %t", + "stored index: %d, uncommitted: %d, indexing: %t, saving: %t", cnts.Stored, cnts.Uncommitted, cnts.Indexing, cnts.Saving, ) err = status.WrapWithInternal(vald.FlushRPCName+" API flush failed", err, @@ -3095,7 +3134,9 @@ func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (cnts *p return cnts, nil } -func (s *server) GetObject(ctx context.Context, req *payload.Object_VectorRequest) (vec *payload.Object_Vector, err error) { +func (s *server) GetObject( + ctx context.Context, req *payload.Object_VectorRequest, +) (vec *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.ObjectRPCServiceName+"/"+vald.GetObjectRPCName), apiName+"/"+vald.GetObjectRPCName) defer func() { if span != nil { @@ -3207,7 +3248,9 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err return nil } -func (s *server) StreamListObject(req *payload.Object_List_Request, stream vald.Object_StreamListObjectServer) error { +func (s *server) StreamListObject( + req *payload.Object_List_Request, stream vald.Object_StreamListObjectServer, +) error { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(stream.Context(), vald.PackageName+"."+vald.ObjectRPCServiceName+"/"+vald.StreamListObjectRPCName), apiName+"/"+vald.StreamListObjectRPCName) defer func() { if span != nil { @@ -3293,3 +3336,728 @@ func (s *server) StreamListObject(req *payload.Object_List_Request, stream vald. }) return err } + +func (s *server) IndexInfo( + ctx context.Context, _ *payload.Empty, +) (vec *payload.Info_Index_Count, err error) { + ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.IndexRPCServiceName+"/"+vald.IndexInfoRPCName), apiName+"/"+vald.IndexInfoRPCName) + defer func() { + if span != nil { + span.End() + } + }() + ech := make(chan error, 1) + var ( + stored, uncommitted atomic.Uint32 + indexing, saving atomic.Bool + ) + s.eg.Go(safety.RecoverFunc(func() error { + defer close(ech) + ech <- s.gateway.BroadCast(ctx, service.READ, func(ctx context.Context, target string, vc vald.Client, copts ...grpc.CallOption) error { + sctx, sspan := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "BroadCast/"+target), apiName+"/"+vald.IndexInfoRPCName+"/"+target) + defer func() { + if sspan != nil { + sspan.End() + } + }() + info, err := vc.IndexInfo(sctx, new(payload.Empty), copts...) + if err != nil { + var ( + attrs trace.Attributes + st *status.Status + msg string + code codes.Code + ) + switch { + case errors.Is(err, context.Canceled), + errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): + attrs = trace.StatusCodeCancelled( + errdetails.ValdGRPCResourceTypePrefix + + "/vald.v1." + vald.IndexInfoRPCName + ".BroadCast/" + + target + " canceled: " + err.Error()) + code = codes.Canceled + case errors.Is(err, context.DeadlineExceeded), + errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): + attrs = trace.StatusCodeDeadlineExceeded( + errdetails.ValdGRPCResourceTypePrefix + + "/vald.v1." + vald.IndexInfoRPCName + ".BroadCast/" + + target + " deadline_exceeded: " + err.Error()) + code = codes.DeadlineExceeded + default: + st, msg, err = status.ParseError(err, codes.NotFound, "error "+vald.IndexInfoRPCName+" API", + &errdetails.ResourceInfo{ + ResourceType: errdetails.ValdGRPCResourceTypePrefix + "/vald.v1." + vald.IndexInfoRPCName + ".BroadCase/" + target, + ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), + }) + if st != nil { + code = st.Code() + } else { + code = codes.NotFound + } + attrs = trace.FromGRPCStatus(code, msg) + } + if sspan != nil { + sspan.RecordError(err) + sspan.SetAttributes(attrs...) + sspan.SetStatus(trace.StatusError, err.Error()) + } + if err != nil && st != nil && + code != codes.Canceled && + code != codes.DeadlineExceeded && + code != codes.InvalidArgument && + code != codes.NotFound && + code != codes.OK && + code != codes.Unimplemented { + return err + } + return nil + } + if info != nil { + stored.Add(info.GetStored()) + uncommitted.Add(info.GetUncommitted()) + if info.GetIndexing() { + indexing.Store(true) + } + if info.GetSaving() { + saving.Store(true) + } + } + return nil + }) + return nil + })) + select { + case <-ctx.Done(): + err = ctx.Err() + case err = <-ech: + } + if err != nil { + resInfo := &errdetails.ResourceInfo{ + ResourceType: errdetails.ValdGRPCResourceTypePrefix + "/vald.v1." + vald.IndexInfoRPCName, + ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), + } + var attrs trace.Attributes + switch { + case errors.Is(err, errors.ErrGRPCClientConnNotFound("*")): + err = status.WrapWithInternal(vald.IndexInfoRPCName+" API connection not found", err, resInfo) + attrs = trace.StatusCodeInternal(err.Error()) + case errors.Is(err, context.Canceled): + err = status.WrapWithCanceled(vald.IndexInfoRPCName+" API canceled", err, resInfo) + attrs = trace.StatusCodeCancelled(err.Error()) + case errors.Is(err, context.DeadlineExceeded): + err = status.WrapWithDeadlineExceeded(vald.IndexInfoRPCName+" API deadline exceeded", err, resInfo) + attrs = trace.StatusCodeDeadlineExceeded(err.Error()) + default: + var ( + st *status.Status + msg string + ) + st, msg, err = status.ParseError(err, codes.Unknown, vald.IndexInfoRPCName+" API request returned error", resInfo) + attrs = trace.FromGRPCStatus(st.Code(), msg) + } + log.Debug(err) + if span != nil { + span.RecordError(err) + span.SetAttributes(attrs...) + span.SetStatus(trace.StatusError, err.Error()) + } + return nil, err + } + return &payload.Info_Index_Count{ + Stored: stored.Load(), + Uncommitted: uncommitted.Load(), + Indexing: indexing.Load(), + Saving: saving.Load(), + }, nil +} + +func (s *server) IndexDetail( + ctx context.Context, _ *payload.Empty, +) (vec *payload.Info_Index_Detail, err error) { + ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.IndexRPCServiceName+"/"+vald.IndexDetailRPCName), apiName+"/"+vald.IndexDetailRPCName) + defer func() { + if span != nil { + span.End() + } + }() + ech := make(chan error, 1) + var ( + mu sync.Mutex + detail = &payload.Info_Index_Detail{ + Counts: make(map[string]*payload.Info_Index_Count), + Replica: uint32(s.replica), + LiveAgents: uint32(s.gateway.GetAgentCount(ctx)), + } + ) + s.eg.Go(safety.RecoverFunc(func() error { + defer close(ech) + ech <- s.gateway.BroadCast(ctx, service.READ, func(ctx context.Context, target string, vc vald.Client, copts ...grpc.CallOption) error { + sctx, sspan := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "BroadCast/"+target), apiName+"/"+vald.IndexDetailRPCName+"/"+target) + defer func() { + if sspan != nil { + sspan.End() + } + }() + info, err := vc.IndexInfo(sctx, new(payload.Empty), copts...) + if err != nil { + var ( + attrs trace.Attributes + st *status.Status + msg string + code codes.Code + ) + switch { + case errors.Is(err, context.Canceled), + errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): + attrs = trace.StatusCodeCancelled( + errdetails.ValdGRPCResourceTypePrefix + + "/vald.v1." + vald.IndexDetailRPCName + ".BroadCast/" + + target + " canceled: " + err.Error()) + code = codes.Canceled + case errors.Is(err, context.DeadlineExceeded), + errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): + attrs = trace.StatusCodeDeadlineExceeded( + errdetails.ValdGRPCResourceTypePrefix + + "/vald.v1." + vald.IndexDetailRPCName + ".BroadCast/" + + target + " deadline_exceeded: " + err.Error()) + code = codes.DeadlineExceeded + default: + st, msg, err = status.ParseError(err, codes.NotFound, "error "+vald.IndexDetailRPCName+" API", + &errdetails.ResourceInfo{ + ResourceType: errdetails.ValdGRPCResourceTypePrefix + "/vald.v1." + vald.IndexDetailRPCName + ".BroadCase/" + target, + ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), + }) + if st != nil { + code = st.Code() + } else { + code = codes.NotFound + } + attrs = trace.FromGRPCStatus(code, msg) + } + if sspan != nil { + sspan.RecordError(err) + sspan.SetAttributes(attrs...) + sspan.SetStatus(trace.StatusError, err.Error()) + } + if err != nil && st != nil && + code != codes.Canceled && + code != codes.DeadlineExceeded && + code != codes.InvalidArgument && + code != codes.NotFound && + code != codes.OK && + code != codes.Unimplemented { + return err + } + return nil + } + if info != nil { + mu.Lock() + detail.Counts[target] = info + mu.Unlock() + } + return nil + }) + return nil + })) + select { + case <-ctx.Done(): + err = ctx.Err() + case err = <-ech: + } + if err != nil { + resInfo := &errdetails.ResourceInfo{ + ResourceType: errdetails.ValdGRPCResourceTypePrefix + "/vald.v1." + vald.IndexDetailRPCName, + ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), + } + var attrs trace.Attributes + switch { + case errors.Is(err, errors.ErrGRPCClientConnNotFound("*")): + err = status.WrapWithInternal(vald.IndexDetailRPCName+" API connection not found", err, resInfo) + attrs = trace.StatusCodeInternal(err.Error()) + case errors.Is(err, context.Canceled): + err = status.WrapWithCanceled(vald.IndexDetailRPCName+" API canceled", err, resInfo) + attrs = trace.StatusCodeCancelled(err.Error()) + case errors.Is(err, context.DeadlineExceeded): + err = status.WrapWithDeadlineExceeded(vald.IndexDetailRPCName+" API deadline exceeded", err, resInfo) + attrs = trace.StatusCodeDeadlineExceeded(err.Error()) + default: + var ( + st *status.Status + msg string + ) + st, msg, err = status.ParseError(err, codes.Unknown, vald.IndexDetailRPCName+" API request returned error", resInfo) + attrs = trace.FromGRPCStatus(st.Code(), msg) + } + log.Debug(err) + if span != nil { + span.RecordError(err) + span.SetAttributes(attrs...) + span.SetStatus(trace.StatusError, err.Error()) + } + return nil, err + } + return detail, nil +} + +func (s *server) GetTimestamp( + ctx context.Context, req *payload.Object_TimestampRequest, +) (ts *payload.Object_Timestamp, err error) { + ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.ObjectRPCServiceName+"/"+vald.GetTimestampRPCName), apiName+"/"+vald.GetTimestampRPCName) + defer func() { + if span != nil { + span.End() + } + }() + uuid := req.GetId().GetId() + tch := make(chan *payload.Object_Timestamp, 1) + ech := make(chan error, 1) + doneErr := errors.New("done getTimestamp") + ctx, cancel := context.WithCancelCause(ctx) + s.eg.Go(safety.RecoverFunc(func() error { + defer close(tch) + defer close(ech) + var once sync.Once + ech <- s.gateway.BroadCast(ctx, service.READ, func(ctx context.Context, target string, vc vald.Client, copts ...grpc.CallOption) error { + sctx, sspan := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "BroadCast/"+target), apiName+"/getTimestamp/BroadCast/"+target) + defer func() { + if sspan != nil { + sspan.End() + } + }() + req := &payload.Object_TimestampRequest{ + Id: &payload.Object_ID{ + Id: uuid, + }, + } + ots, err := vc.GetTimestamp(sctx, req, copts...) + if err != nil { + var ( + attrs trace.Attributes + st *status.Status + msg string + code codes.Code + ) + switch { + case errors.Is(err, context.Canceled), + errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): + attrs = trace.StatusCodeCancelled( + errdetails.ValdGRPCResourceTypePrefix + + "/vald.v1." + vald.GetTimestampRPCName + ".BroadCast/" + + target + " canceled: " + err.Error()) + code = codes.Canceled + case errors.Is(err, context.DeadlineExceeded), + errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): + attrs = trace.StatusCodeDeadlineExceeded( + errdetails.ValdGRPCResourceTypePrefix + + "/vald.v1." + vald.GetTimestampRPCName + ".BroadCast/" + + target + " deadline_exceeded: " + err.Error()) + code = codes.DeadlineExceeded + default: + st, msg, err = status.ParseError(err, codes.NotFound, "error "+vald.GetTimestampRPCName+" API meta "+uuid+"'s uuid not found", + &errdetails.RequestInfo{ + RequestId: uuid, + ServingData: errdetails.Serialize(req), + }, + &errdetails.ResourceInfo{ + ResourceType: errdetails.ValdGRPCResourceTypePrefix + "/vald.v1." + vald.GetTimestampRPCName, + ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), + }) + if st != nil { + code = st.Code() + } else { + code = codes.NotFound + } + attrs = trace.FromGRPCStatus(code, msg) + } + if sspan != nil { + sspan.RecordError(err) + sspan.SetAttributes(attrs...) + sspan.SetStatus(trace.StatusError, err.Error()) + } + if err != nil && st != nil && + code != codes.Canceled && + code != codes.DeadlineExceeded && + code != codes.InvalidArgument && + code != codes.NotFound && + code != codes.OK && + code != codes.Unimplemented { + return err + } + return nil + } + if ots != nil && ots.GetId() != "" { + once.Do(func() { + tch <- ots + cancel(doneErr) + }) + } + return nil + }) + return nil + })) + select { + case <-ctx.Done(): + err = ctx.Err() + if errors.Is(err, context.Canceled) && errors.Is(context.Cause(ctx), doneErr) { + select { + case ts = <-tch: + if ts == nil || ts.GetId() == "" { + err = errors.ErrObjectNotFound(nil, uuid) + } else { + err = nil + } + default: + } + } + case ts = <-tch: + if ts == nil || ts.GetId() == "" { + err = errors.ErrObjectNotFound(nil, uuid) + } + case err = <-ech: + } + if err != nil { + reqInfo := &errdetails.RequestInfo{ + RequestId: uuid, + ServingData: errdetails.Serialize(req), + } + resInfo := &errdetails.ResourceInfo{ + ResourceType: errdetails.ValdGRPCResourceTypePrefix + "/vald.v1." + vald.GetTimestampRPCName, + ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), + } + var attrs trace.Attributes + switch { + case errors.Is(err, errors.ErrInvalidUUID(uuid)): + err = status.WrapWithInvalidArgument(vald.GetTimestampRPCName+" API invalid argument for uuid \""+uuid+"\" detected", err, reqInfo, resInfo, &errdetails.BadRequest{ + FieldViolations: []*errdetails.BadRequestFieldViolation{ + { + Field: "uuid", + Description: err.Error(), + }, + }, + }) + attrs = trace.StatusCodeInvalidArgument(err.Error()) + case errors.Is(err, errors.ErrObjectIDNotFound(uuid)), errors.Is(err, errors.ErrObjectNotFound(nil, uuid)): + err = status.WrapWithNotFound(vald.GetTimestampRPCName+" API id "+uuid+"'s object not found", err, reqInfo, resInfo) + attrs = trace.StatusCodeNotFound(err.Error()) + case errors.Is(err, errors.ErrGRPCClientConnNotFound("*")): + err = status.WrapWithInternal(vald.GetTimestampRPCName+" API connection not found", err, reqInfo, resInfo) + attrs = trace.StatusCodeInternal(err.Error()) + case errors.Is(err, context.Canceled): + err = status.WrapWithCanceled(vald.GetTimestampRPCName+" API canceled", err, reqInfo, resInfo) + attrs = trace.StatusCodeCancelled(err.Error()) + case errors.Is(err, context.DeadlineExceeded): + err = status.WrapWithDeadlineExceeded(vald.GetTimestampRPCName+" API deadline exceeded", err, reqInfo, resInfo) + attrs = trace.StatusCodeDeadlineExceeded(err.Error()) + default: + var ( + st *status.Status + msg string + ) + st, msg, err = status.ParseError(err, codes.Unknown, vald.GetTimestampRPCName+" API uuid "+uuid+"'s request returned error", reqInfo, resInfo) + attrs = trace.FromGRPCStatus(st.Code(), msg) + } + if span != nil { + span.RecordError(err) + span.SetAttributes(attrs...) + span.SetStatus(trace.StatusError, err.Error()) + } + return nil, err + } + return ts, nil +} + +func (s *server) IndexStatistics( + ctx context.Context, req *payload.Empty, +) (vec *payload.Info_Index_Statistics, err error) { + ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.IndexRPCServiceName+"/"+vald.IndexStatisticsRPCName), apiName+"/"+vald.IndexStatisticsRPCName) + defer func() { + if span != nil { + span.End() + } + }() + details, err := s.IndexStatisticsDetail(ctx, req) + if err != nil || details == nil { + resInfo := &errdetails.ResourceInfo{ + ResourceType: errdetails.ValdGRPCResourceTypePrefix + "/vald.v1." + vald.IndexStatisticsRPCName, + ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), + } + var attrs trace.Attributes + switch { + case errors.Is(err, errors.ErrGRPCClientConnNotFound("*")): + err = status.WrapWithInternal(vald.IndexStatisticsRPCName+" API connection not found", err, resInfo) + attrs = trace.StatusCodeInternal(err.Error()) + case errors.Is(err, context.Canceled): + err = status.WrapWithCanceled(vald.IndexStatisticsRPCName+" API canceled", err, resInfo) + attrs = trace.StatusCodeCancelled(err.Error()) + case errors.Is(err, context.DeadlineExceeded): + err = status.WrapWithDeadlineExceeded(vald.IndexStatisticsRPCName+" API deadline exceeded", err, resInfo) + attrs = trace.StatusCodeDeadlineExceeded(err.Error()) + default: + var ( + st *status.Status + msg string + ) + st, msg, err = status.ParseError(err, codes.Unknown, vald.IndexStatisticsRPCName+" API request returned error", resInfo) + attrs = trace.FromGRPCStatus(st.Code(), msg) + } + log.Debug(err) + if span != nil { + span.RecordError(err) + span.SetAttributes(attrs...) + span.SetStatus(trace.StatusError, err.Error()) + } + return nil, err + } + return mergeInfoIndexStatistics(details.GetDetails()), nil +} + +func (s *server) IndexStatisticsDetail( + ctx context.Context, _ *payload.Empty, +) (vec *payload.Info_Index_StatisticsDetail, err error) { + ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.IndexRPCServiceName+"/"+vald.IndexStatisticsDetailRPCName), apiName+"/"+vald.IndexStatisticsDetailRPCName) + defer func() { + if span != nil { + span.End() + } + }() + ech := make(chan error, 1) + var ( + mu sync.Mutex + detail = &payload.Info_Index_StatisticsDetail{ + Details: make(map[string]*payload.Info_Index_Statistics, s.gateway.GetAgentCount(ctx)), + } + ) + s.eg.Go(safety.RecoverFunc(func() error { + defer close(ech) + ech <- s.gateway.BroadCast(ctx, service.READ, func(ctx context.Context, target string, vc vald.Client, copts ...grpc.CallOption) error { + sctx, sspan := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "BroadCast/"+target), apiName+"/"+vald.IndexStatisticsDetailRPCName+"/"+target) + defer func() { + if sspan != nil { + sspan.End() + } + }() + var stats *payload.Info_Index_Statistics + stats, err = vc.IndexStatistics(sctx, new(payload.Empty), copts...) + if err != nil { + var ( + attrs trace.Attributes + st *status.Status + msg string + code codes.Code + ) + switch { + case errors.Is(err, context.Canceled), + errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): + attrs = trace.StatusCodeCancelled( + errdetails.ValdGRPCResourceTypePrefix + + "/vald.v1." + vald.IndexStatisticsDetailRPCName + ".BroadCast/" + + target + " canceled: " + err.Error()) + code = codes.Canceled + case errors.Is(err, context.DeadlineExceeded), + errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): + attrs = trace.StatusCodeDeadlineExceeded( + errdetails.ValdGRPCResourceTypePrefix + + "/vald.v1." + vald.IndexStatisticsDetailRPCName + ".BroadCast/" + + target + " deadline_exceeded: " + err.Error()) + code = codes.DeadlineExceeded + default: + st, msg, err = status.ParseError(err, codes.NotFound, "error "+vald.IndexStatisticsDetailRPCName+" API", + &errdetails.ResourceInfo{ + ResourceType: errdetails.ValdGRPCResourceTypePrefix + "/vald.v1." + vald.IndexStatisticsDetailRPCName + ".BroadCase/" + target, + ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), + }) + if st != nil { + code = st.Code() + } else { + code = codes.NotFound + } + attrs = trace.FromGRPCStatus(code, msg) + } + if sspan != nil { + sspan.RecordError(err) + sspan.SetAttributes(attrs...) + sspan.SetStatus(trace.StatusError, err.Error()) + } + if err != nil && st != nil && + code != codes.Canceled && + code != codes.DeadlineExceeded && + code != codes.InvalidArgument && + code != codes.NotFound && + code != codes.OK && + code != codes.Unimplemented { + return err + } + return nil + } + if stats != nil { + mu.Lock() + detail.Details[target] = stats + mu.Unlock() + } + return nil + }) + return nil + })) + select { + case <-ctx.Done(): + err = ctx.Err() + case err = <-ech: + } + if err != nil { + resInfo := &errdetails.ResourceInfo{ + ResourceType: errdetails.ValdGRPCResourceTypePrefix + "/vald.v1." + vald.IndexStatisticsDetailRPCName, + ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), + } + var attrs trace.Attributes + switch { + case errors.Is(err, errors.ErrGRPCClientConnNotFound("*")): + err = status.WrapWithInternal(vald.IndexStatisticsDetailRPCName+" API connection not found", err, resInfo) + attrs = trace.StatusCodeInternal(err.Error()) + case errors.Is(err, context.Canceled): + err = status.WrapWithCanceled(vald.IndexStatisticsDetailRPCName+" API canceled", err, resInfo) + attrs = trace.StatusCodeCancelled(err.Error()) + case errors.Is(err, context.DeadlineExceeded): + err = status.WrapWithDeadlineExceeded(vald.IndexStatisticsDetailRPCName+" API deadline exceeded", err, resInfo) + attrs = trace.StatusCodeDeadlineExceeded(err.Error()) + default: + var ( + st *status.Status + msg string + ) + st, msg, err = status.ParseError(err, codes.Unknown, vald.IndexStatisticsDetailRPCName+" API request returned error", resInfo) + attrs = trace.FromGRPCStatus(st.Code(), msg) + } + log.Debug(err) + if span != nil { + span.RecordError(err) + span.SetAttributes(attrs...) + span.SetStatus(trace.StatusError, err.Error()) + } + return nil, err + } + return detail, nil +} + +func calculateMedian(data []int32) int32 { + slices.Sort(data) + n := len(data) + if n%2 == 0 { + return (data[n/2-1] + data[n/2]) / 2 + } + return data[n/2] +} + +func sumHistograms(hist1, hist2 []uint64) []uint64 { + if len(hist1) < len(hist2) { + hist1, hist2 = hist2, hist1 + } + for i := range hist2 { + hist1[i] += hist2[i] + } + return hist1 +} + +func mergeInfoIndexStatistics( + stats map[string]*payload.Info_Index_Statistics, +) (merged *payload.Info_Index_Statistics) { + merged = new(payload.Info_Index_Statistics) + + if len(stats) == 0 { + return merged + } + + var indegrees, outdegrees []int32 + var indegreeCounts [][]int64 + var outdegreeHistograms, indegreeHistograms [][]uint64 + merged.Valid = true + + for _, stat := range stats { + if !stat.Valid { + continue + } + indegrees = append(indegrees, stat.MedianIndegree) + outdegrees = append(outdegrees, stat.MedianOutdegree) + + indegreeCounts = append(indegreeCounts, stat.IndegreeCount) + outdegreeHistograms = append(outdegreeHistograms, stat.OutdegreeHistogram) + indegreeHistograms = append(indegreeHistograms, stat.IndegreeHistogram) + + if stat.MaxNumberOfIndegree > merged.MaxNumberOfIndegree { + merged.MaxNumberOfIndegree = stat.MaxNumberOfIndegree + } + if stat.MaxNumberOfOutdegree > merged.MaxNumberOfOutdegree { + merged.MaxNumberOfOutdegree = stat.MaxNumberOfOutdegree + } + if stat.MinNumberOfIndegree < merged.MinNumberOfIndegree || merged.MinNumberOfIndegree == 0 { + merged.MinNumberOfIndegree = stat.MinNumberOfIndegree + } + if stat.MinNumberOfOutdegree < merged.MinNumberOfOutdegree || merged.MinNumberOfOutdegree == 0 { + merged.MinNumberOfOutdegree = stat.MinNumberOfOutdegree + } + merged.ModeIndegree += stat.ModeIndegree + merged.ModeOutdegree += stat.ModeOutdegree + merged.NodesSkippedFor10Edges += stat.NodesSkippedFor10Edges + merged.NodesSkippedForIndegreeDistance += stat.NodesSkippedForIndegreeDistance + merged.NumberOfEdges += stat.NumberOfEdges + merged.NumberOfIndexedObjects += stat.NumberOfIndexedObjects + merged.NumberOfNodes += stat.NumberOfNodes + merged.NumberOfNodesWithoutEdges += stat.NumberOfNodesWithoutEdges + merged.NumberOfNodesWithoutIndegree += stat.NumberOfNodesWithoutIndegree + merged.NumberOfObjects += stat.NumberOfObjects + merged.NumberOfRemovedObjects += stat.NumberOfRemovedObjects + merged.SizeOfObjectRepository += stat.SizeOfObjectRepository + merged.SizeOfRefinementObjectRepository += stat.SizeOfRefinementObjectRepository + + merged.VarianceOfIndegree += stat.VarianceOfIndegree + merged.VarianceOfOutdegree += stat.VarianceOfOutdegree + merged.MeanEdgeLength += stat.MeanEdgeLength + merged.MeanEdgeLengthFor10Edges += stat.MeanEdgeLengthFor10Edges + merged.MeanIndegreeDistanceFor10Edges += stat.MeanIndegreeDistanceFor10Edges + merged.MeanNumberOfEdgesPerNode += stat.MeanNumberOfEdgesPerNode + + merged.C1Indegree += stat.C1Indegree + merged.C5Indegree += stat.C5Indegree + merged.C95Outdegree += stat.C95Outdegree + merged.C99Outdegree += stat.C99Outdegree + } + + merged.MedianIndegree = calculateMedian(indegrees) + merged.MedianOutdegree = calculateMedian(outdegrees) + merged.IndegreeCount = make([]int64, len(indegreeCounts[0])) + for i := range merged.IndegreeCount { + var ( + alen int64 + sum int64 + ) + for _, count := range indegreeCounts { + if i < len(count) { + alen++ + sum += count[i] + } + } + merged.IndegreeCount[i] = sum / alen + } + + for _, hist := range outdegreeHistograms { + merged.OutdegreeHistogram = sumHistograms(merged.OutdegreeHistogram, hist) + } + + for _, hist := range indegreeHistograms { + merged.IndegreeHistogram = sumHistograms(merged.IndegreeHistogram, hist) + } + + merged.ModeIndegree /= uint64(len(stats)) + merged.ModeOutdegree /= uint64(len(stats)) + merged.VarianceOfIndegree /= float64(len(stats)) + merged.VarianceOfOutdegree /= float64(len(stats)) + merged.MeanEdgeLength /= float64(len(stats)) + merged.MeanEdgeLengthFor10Edges /= float64(len(stats)) + merged.MeanIndegreeDistanceFor10Edges /= float64(len(stats)) + merged.MeanNumberOfEdgesPerNode /= float64(len(stats)) + merged.C1Indegree /= float64(len(stats)) + merged.C5Indegree /= float64(len(stats)) + merged.C95Outdegree /= float64(len(stats)) + merged.C99Outdegree /= float64(len(stats)) + + return merged +} diff --git a/pkg/gateway/lb/handler/grpc/handler_test.go b/pkg/gateway/lb/handler/grpc/handler_test.go index 3f0cd1aa58..0d134da790 100644 --- a/pkg/gateway/lb/handler/grpc/handler_test.go +++ b/pkg/gateway/lb/handler/grpc/handler_test.go @@ -96,15 +96,14 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_Exists(t *testing.T) { +// func Test_server_exists(t *testing.T) { // type args struct { // ctx context.Context -// meta *payload.Object_ID +// uuid string // } // type fields struct { // eg errgroup.Group @@ -146,7 +145,7 @@ package grpc // name: "test_case_1", // args: args { // ctx:nil, -// meta:nil, +// uuid:"", // }, // fields: fields { // eg:nil, @@ -177,7 +176,7 @@ package grpc // name: "test_case_2", // args: args { // ctx:nil, -// meta:nil, +// uuid:"", // }, // fields: fields { // eg:nil, @@ -230,19 +229,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotId, err := s.Exists(test.args.ctx, test.args.meta) +// gotId, err := s.exists(test.args.ctx, test.args.uuid) // if err := checkFunc(test.want, gotId, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_Search(t *testing.T) { +// func Test_server_Exists(t *testing.T) { // type args struct { -// ctx context.Context -// req *payload.Search_Request +// ctx context.Context +// meta *payload.Object_ID // } // type fields struct { // eg errgroup.Group @@ -256,24 +254,24 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantRes *payload.Search_Response -// err error +// wantId *payload.Object_ID +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, *payload.Object_ID, 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, gotId *payload.Object_ID, 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(gotId, w.wantId) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotId, w.wantId) // } // return nil // } @@ -284,7 +282,7 @@ package grpc // name: "test_case_1", // args: args { // ctx:nil, -// req:nil, +// meta:nil, // }, // fields: fields { // eg:nil, @@ -315,7 +313,7 @@ package grpc // name: "test_case_2", // args: args { // ctx:nil, -// req:nil, +// meta:nil, // }, // fields: fields { // eg:nil, @@ -368,19 +366,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotRes, err := s.Search(test.args.ctx, test.args.req) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// gotId, err := s.Exists(test.args.ctx, test.args.meta) +// if err := checkFunc(test.want, gotId, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_SearchByID(t *testing.T) { +// func Test_server_Search(t *testing.T) { // type args struct { // ctx context.Context -// req *payload.Search_IDRequest +// req *payload.Search_Request // } // type fields struct { // eg errgroup.Group @@ -506,18 +503,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotRes, err := s.SearchByID(test.args.ctx, test.args.req) +// gotRes, err := s.Search(test.args.ctx, test.args.req) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_StreamSearch(t *testing.T) { +// func Test_server_SearchByID(t *testing.T) { // type args struct { -// stream vald.Search_StreamSearchServer +// ctx context.Context +// req *payload.Search_IDRequest // } // type fields struct { // eg errgroup.Group @@ -531,21 +528,25 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// err error +// wantRes *payload.Search_Response +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Search_Response, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, 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(gotRes, w.wantRes) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) +// } // return nil // } // tests := []test{ @@ -554,7 +555,8 @@ package grpc // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -584,7 +586,8 @@ package grpc // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -637,18 +640,19 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamSearch(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotRes, err := s.SearchByID(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_StreamSearchByID(t *testing.T) { +// func Test_server_calculateNum(t *testing.T) { // type args struct { -// stream vald.Search_StreamSearchByIDServer +// ctx context.Context +// num uint32 +// ratio float32 // } // type fields struct { // eg errgroup.Group @@ -662,20 +666,20 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// err error +// wantN uint32 // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, uint32) 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, gotN uint32) error { +// if !reflect.DeepEqual(gotN, w.wantN) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotN, w.wantN) // } // return nil // } @@ -685,7 +689,9 @@ package grpc // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// num:0, +// ratio:0, // }, // fields: fields { // eg:nil, @@ -715,7 +721,9 @@ package grpc // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// num:0, +// ratio:0, // }, // fields: fields { // eg:nil, @@ -768,19 +776,19 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamSearchByID(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotN := s.calculateNum(test.args.ctx, test.args.num, test.args.ratio) +// if err := checkFunc(test.want, gotN); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_MultiSearch(t *testing.T) { +// func Test_server_doSearch(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Search_MultiRequest +// ctx context.Context +// cfg *payload.Search_Config +// f func(ctx context.Context, cfg *payload.Search_Config, vc vald.Client, copts ...grpc.CallOption) (*payload.Search_Response, error) // } // type fields struct { // eg errgroup.Group @@ -794,7 +802,7 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantRes *payload.Search_Responses +// wantRes *payload.Search_Response // err error // } // type test struct { @@ -802,11 +810,11 @@ package grpc // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Responses, error) error +// checkFunc func(want, *payload.Search_Response, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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) // } @@ -822,7 +830,8 @@ package grpc // name: "test_case_1", // args: args { // ctx:nil, -// reqs:nil, +// cfg:nil, +// f:nil, // }, // fields: fields { // eg:nil, @@ -853,7 +862,8 @@ package grpc // name: "test_case_2", // args: args { // ctx:nil, -// reqs:nil, +// cfg:nil, +// f:nil, // }, // fields: fields { // eg:nil, @@ -906,50 +916,35 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotRes, err := s.MultiSearch(test.args.ctx, test.args.reqs) +// gotRes, err := s.doSearch(test.args.ctx, test.args.cfg, test.args.f) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_MultiSearchByID(t *testing.T) { +// func Test_selectAggregator(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Search_MultiIDRequest -// } -// type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// timeout time.Duration -// replica int -// streamConcurrency int -// multiConcurrency int -// name string -// ip string -// UnimplementedValdServer vald.UnimplementedValdServer +// algo payload.Search_AggregationAlgorithm +// num int +// fnum int +// replica int // } // type want struct { -// wantRes *payload.Search_Responses -// err error +// want Aggregator // } // type test struct { // name string // args args -// fields fields // want want -// checkFunc func(want, *payload.Search_Responses, error) error +// checkFunc func(want, Aggregator) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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) +// defaultCheckFunc := func(w want, got Aggregator) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -959,19 +954,10 @@ package grpc // { // name: "test_case_1", // args: args { -// ctx:nil, -// reqs:nil, -// }, -// fields: fields { -// eg:nil, -// gateway:nil, -// timeout:nil, +// algo:nil, +// num:0, +// fnum:0, // replica:0, -// streamConcurrency:0, -// multiConcurrency:0, -// name:"", -// ip:"", -// UnimplementedValdServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -990,19 +976,10 @@ package grpc // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// reqs:nil, -// }, -// fields: fields { -// eg:nil, -// gateway:nil, -// timeout:nil, +// algo:nil, +// num:0, +// fnum:0, // replica:0, -// streamConcurrency:0, -// multiConcurrency:0, -// name:"", -// ip:"", -// UnimplementedValdServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1032,31 +1009,18 @@ package grpc // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } -// s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// timeout: test.fields.timeout, -// replica: test.fields.replica, -// streamConcurrency: test.fields.streamConcurrency, -// multiConcurrency: test.fields.multiConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServer: test.fields.UnimplementedValdServer, -// } // -// gotRes, err := s.MultiSearchByID(test.args.ctx, test.args.reqs) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// got := selectAggregator(test.args.algo, test.args.num, test.args.fnum, test.args.replica) +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_LinearSearch(t *testing.T) { +// func Test_server_StreamSearch(t *testing.T) { // type args struct { -// ctx context.Context -// req *payload.Search_Request +// stream vald.Search_StreamSearchServer // } // type fields struct { // eg errgroup.Group @@ -1070,25 +1034,21 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantRes *payload.Search_Response -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, 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, 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 // } // tests := []test{ @@ -1097,8 +1057,7 @@ package grpc // { // name: "test_case_1", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -1128,8 +1087,7 @@ package grpc // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -1182,19 +1140,17 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotRes, err := s.LinearSearch(test.args.ctx, test.args.req) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// err := s.StreamSearch(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_LinearSearchByID(t *testing.T) { +// func Test_server_StreamSearchByID(t *testing.T) { // type args struct { -// ctx context.Context -// req *payload.Search_IDRequest +// stream vald.Search_StreamSearchByIDServer // } // type fields struct { // eg errgroup.Group @@ -1208,25 +1164,21 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantRes *payload.Search_Response -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, 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, 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 // } // tests := []test{ @@ -1235,8 +1187,7 @@ package grpc // { // name: "test_case_1", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -1266,8 +1217,7 @@ package grpc // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -1320,18 +1270,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotRes, err := s.LinearSearchByID(test.args.ctx, test.args.req) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// err := s.StreamSearchByID(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_StreamLinearSearch(t *testing.T) { +// func Test_server_MultiSearch(t *testing.T) { // type args struct { -// stream vald.Search_StreamLinearSearchServer +// ctx context.Context +// reqs *payload.Search_MultiRequest // } // type fields struct { // eg errgroup.Group @@ -1345,21 +1295,25 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// err error +// wantRes *payload.Search_Responses +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Search_Responses, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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 // } // tests := []test{ @@ -1368,7 +1322,8 @@ package grpc // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -1398,7 +1353,8 @@ package grpc // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -1451,18 +1407,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamLinearSearch(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotRes, err := s.MultiSearch(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_StreamLinearSearchByID(t *testing.T) { +// func Test_server_MultiSearchByID(t *testing.T) { // type args struct { -// stream vald.Search_StreamLinearSearchByIDServer +// ctx context.Context +// reqs *payload.Search_MultiIDRequest // } // type fields struct { // eg errgroup.Group @@ -1476,21 +1432,25 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// err error +// wantRes *payload.Search_Responses +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Search_Responses, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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 // } // tests := []test{ @@ -1499,7 +1459,8 @@ package grpc // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -1529,7 +1490,8 @@ package grpc // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -1582,19 +1544,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamLinearSearchByID(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotRes, err := s.MultiSearchByID(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_MultiLinearSearch(t *testing.T) { +// func Test_server_LinearSearch(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Search_MultiRequest +// ctx context.Context +// req *payload.Search_Request // } // type fields struct { // eg errgroup.Group @@ -1608,7 +1569,7 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantRes *payload.Search_Responses +// wantRes *payload.Search_Response // err error // } // type test struct { @@ -1616,11 +1577,11 @@ package grpc // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Responses, error) error +// checkFunc func(want, *payload.Search_Response, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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) // } @@ -1636,7 +1597,7 @@ package grpc // name: "test_case_1", // args: args { // ctx:nil, -// reqs:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -1667,7 +1628,7 @@ package grpc // name: "test_case_2", // args: args { // ctx:nil, -// reqs:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -1720,19 +1681,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotRes, err := s.MultiLinearSearch(test.args.ctx, test.args.reqs) +// gotRes, err := s.LinearSearch(test.args.ctx, test.args.req) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_MultiLinearSearchByID(t *testing.T) { +// func Test_server_LinearSearchByID(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Search_MultiIDRequest +// ctx context.Context +// req *payload.Search_IDRequest // } // type fields struct { // eg errgroup.Group @@ -1746,7 +1706,7 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantRes *payload.Search_Responses +// wantRes *payload.Search_Response // err error // } // type test struct { @@ -1754,11 +1714,11 @@ package grpc // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Responses, error) error +// checkFunc func(want, *payload.Search_Response, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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) // } @@ -1774,7 +1734,7 @@ package grpc // name: "test_case_1", // args: args { // ctx:nil, -// reqs:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -1805,7 +1765,7 @@ package grpc // name: "test_case_2", // args: args { // ctx:nil, -// reqs:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -1858,19 +1818,17 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotRes, err := s.MultiLinearSearchByID(test.args.ctx, test.args.reqs) +// gotRes, err := s.LinearSearchByID(test.args.ctx, test.args.req) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_Insert(t *testing.T) { +// func Test_server_StreamLinearSearch(t *testing.T) { // type args struct { -// ctx context.Context -// req *payload.Insert_Request +// stream vald.Search_StreamLinearSearchServer // } // type fields struct { // eg errgroup.Group @@ -1884,25 +1842,21 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantCe *payload.Object_Location -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Location, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotCe *payload.Object_Location, 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(gotCe, w.wantCe) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCe, w.wantCe) -// } // return nil // } // tests := []test{ @@ -1911,8 +1865,7 @@ package grpc // { // name: "test_case_1", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -1942,8 +1895,7 @@ package grpc // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -1996,18 +1948,17 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotCe, err := s.Insert(test.args.ctx, test.args.req) -// if err := checkFunc(test.want, gotCe, err); err != nil { +// err := s.StreamLinearSearch(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_StreamInsert(t *testing.T) { +// func Test_server_StreamLinearSearchByID(t *testing.T) { // type args struct { -// stream vald.Insert_StreamInsertServer +// stream vald.Search_StreamLinearSearchByIDServer // } // type fields struct { // eg errgroup.Group @@ -2127,19 +2078,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamInsert(test.args.stream) +// err := s.StreamLinearSearchByID(test.args.stream) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_MultiInsert(t *testing.T) { +// func Test_server_MultiLinearSearch(t *testing.T) { // type args struct { // ctx context.Context -// reqs *payload.Insert_MultiRequest +// reqs *payload.Search_MultiRequest // } // type fields struct { // eg errgroup.Group @@ -2153,24 +2103,24 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantLocs *payload.Object_Locations -// err error +// wantRes *payload.Search_Responses +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, *payload.Search_Responses, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, 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(gotLocs, w.wantLocs) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) +// if !reflect.DeepEqual(gotRes, w.wantRes) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) // } // return nil // } @@ -2265,19 +2215,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotLocs, err := s.MultiInsert(test.args.ctx, test.args.reqs) -// if err := checkFunc(test.want, gotLocs, err); err != nil { +// gotRes, err := s.MultiLinearSearch(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_Update(t *testing.T) { +// func Test_server_MultiLinearSearchByID(t *testing.T) { // type args struct { -// ctx context.Context -// req *payload.Update_Request +// ctx context.Context +// reqs *payload.Search_MultiIDRequest // } // type fields struct { // eg errgroup.Group @@ -2291,7 +2240,7 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantRes *payload.Object_Location +// wantRes *payload.Search_Responses // err error // } // type test struct { @@ -2299,11 +2248,11 @@ package grpc // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Location, error) error +// checkFunc func(want, *payload.Search_Responses, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Location, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Search_Responses, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -2319,7 +2268,7 @@ package grpc // name: "test_case_1", // args: args { // ctx:nil, -// req:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -2350,7 +2299,7 @@ package grpc // name: "test_case_2", // args: args { // ctx:nil, -// req:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -2403,18 +2352,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotRes, err := s.Update(test.args.ctx, test.args.req) +// gotRes, err := s.MultiLinearSearchByID(test.args.ctx, test.args.reqs) // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_StreamUpdate(t *testing.T) { +// func Test_server_Insert(t *testing.T) { // type args struct { -// stream vald.Update_StreamUpdateServer +// ctx context.Context +// req *payload.Insert_Request // } // type fields struct { // eg errgroup.Group @@ -2428,21 +2377,25 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// err error +// wantCe *payload.Object_Location +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotCe *payload.Object_Location, 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(gotCe, w.wantCe) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCe, w.wantCe) +// } // return nil // } // tests := []test{ @@ -2451,7 +2404,8 @@ package grpc // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -2481,7 +2435,8 @@ package grpc // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -2534,19 +2489,17 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamUpdate(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotCe, err := s.Insert(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotCe, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_MultiUpdate(t *testing.T) { +// func Test_server_StreamInsert(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Update_MultiRequest +// stream vald.Insert_StreamInsertServer // } // type fields struct { // eg errgroup.Group @@ -2560,25 +2513,21 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantLocs *payload.Object_Locations -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, 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(gotLocs, w.wantLocs) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) -// } // return nil // } // tests := []test{ @@ -2587,8 +2536,7 @@ package grpc // { // name: "test_case_1", // args: args { -// ctx:nil, -// reqs:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -2618,8 +2566,7 @@ package grpc // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// reqs:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -2672,19 +2619,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotLocs, err := s.MultiUpdate(test.args.ctx, test.args.reqs) -// if err := checkFunc(test.want, gotLocs, err); err != nil { +// err := s.StreamInsert(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_Upsert(t *testing.T) { +// func Test_server_MultiInsert(t *testing.T) { // type args struct { -// ctx context.Context -// req *payload.Upsert_Request +// ctx context.Context +// reqs *payload.Insert_MultiRequest // } // type fields struct { // eg errgroup.Group @@ -2698,24 +2644,24 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantLoc *payload.Object_Location -// err error +// wantLocs *payload.Object_Locations +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Location, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, err error) error { +// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, 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(gotLoc, w.wantLoc) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// if !reflect.DeepEqual(gotLocs, w.wantLocs) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) // } // return nil // } @@ -2726,7 +2672,7 @@ package grpc // name: "test_case_1", // args: args { // ctx:nil, -// req:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -2757,7 +2703,7 @@ package grpc // name: "test_case_2", // args: args { // ctx:nil, -// req:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -2810,18 +2756,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotLoc, err := s.Upsert(test.args.ctx, test.args.req) -// if err := checkFunc(test.want, gotLoc, err); err != nil { +// gotLocs, err := s.MultiInsert(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_StreamUpsert(t *testing.T) { +// func Test_server_Update(t *testing.T) { // type args struct { -// stream vald.Upsert_StreamUpsertServer +// ctx context.Context +// req *payload.Update_Request // } // type fields struct { // eg errgroup.Group @@ -2835,21 +2781,25 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// err error +// wantRes *payload.Object_Location +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Location, 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 // } // tests := []test{ @@ -2858,7 +2808,8 @@ package grpc // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -2888,7 +2839,8 @@ package grpc // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -2941,19 +2893,17 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamUpsert(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotRes, err := s.Update(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_MultiUpsert(t *testing.T) { +// func Test_server_StreamUpdate(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Upsert_MultiRequest +// stream vald.Update_StreamUpdateServer // } // type fields struct { // eg errgroup.Group @@ -2967,25 +2917,21 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantLocs *payload.Object_Locations -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, 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(gotLocs, w.wantLocs) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) -// } // return nil // } // tests := []test{ @@ -2994,8 +2940,7 @@ package grpc // { // name: "test_case_1", // args: args { -// ctx:nil, -// reqs:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -3025,8 +2970,7 @@ package grpc // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// reqs:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -3079,19 +3023,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotLocs, err := s.MultiUpsert(test.args.ctx, test.args.reqs) -// if err := checkFunc(test.want, gotLocs, err); err != nil { +// err := s.StreamUpdate(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_Remove(t *testing.T) { +// func Test_server_MultiUpdate(t *testing.T) { // type args struct { -// ctx context.Context -// req *payload.Remove_Request +// ctx context.Context +// reqs *payload.Update_MultiRequest // } // type fields struct { // eg errgroup.Group @@ -3105,7 +3048,7 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantLocs *payload.Object_Location +// wantLocs *payload.Object_Locations // err error // } // type test struct { @@ -3113,11 +3056,11 @@ package grpc // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Location, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotLocs *payload.Object_Location, err error) error { +// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -3133,7 +3076,7 @@ package grpc // name: "test_case_1", // args: args { // ctx:nil, -// req:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -3164,7 +3107,7 @@ package grpc // name: "test_case_2", // args: args { // ctx:nil, -// req:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -3217,18 +3160,154 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotLocs, err := s.Remove(test.args.ctx, test.args.req) +// gotLocs, err := s.MultiUpdate(test.args.ctx, test.args.reqs) // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_server_Upsert(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Upsert_Request +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantLoc *payload.Object_Location +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } // +// gotLoc, err := s.Upsert(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotLoc, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } // -// func Test_server_StreamRemove(t *testing.T) { +// func Test_server_StreamUpsert(t *testing.T) { // type args struct { -// stream vald.Remove_StreamRemoveServer +// stream vald.Upsert_StreamUpsertServer // } // type fields struct { // eg errgroup.Group @@ -3348,19 +3427,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamRemove(test.args.stream) +// err := s.StreamUpsert(test.args.stream) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_MultiRemove(t *testing.T) { +// func Test_server_MultiUpsert(t *testing.T) { // type args struct { // ctx context.Context -// reqs *payload.Remove_MultiRequest +// reqs *payload.Upsert_MultiRequest // } // type fields struct { // eg errgroup.Group @@ -3486,19 +3564,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotLocs, err := s.MultiRemove(test.args.ctx, test.args.reqs) +// gotLocs, err := s.MultiUpsert(test.args.ctx, test.args.reqs) // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_RemoveByTimestamp(t *testing.T) { +// func Test_server_Remove(t *testing.T) { // type args struct { // ctx context.Context -// req *payload.Remove_TimestampRequest +// req *payload.Remove_Request // } // type fields struct { // eg errgroup.Group @@ -3512,7 +3589,7 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantLocs *payload.Object_Locations +// wantLocs *payload.Object_Location // err error // } // type test struct { @@ -3520,11 +3597,11 @@ package grpc // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, err error) error { +// defaultCheckFunc := func(w want, gotLocs *payload.Object_Location, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -3624,19 +3701,17 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotLocs, err := s.RemoveByTimestamp(test.args.ctx, test.args.req) +// gotLocs, err := s.Remove(test.args.ctx, test.args.req) // if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_GetObject(t *testing.T) { +// func Test_server_StreamRemove(t *testing.T) { // type args struct { -// ctx context.Context -// req *payload.Object_VectorRequest +// stream vald.Remove_StreamRemoveServer // } // type fields struct { // eg errgroup.Group @@ -3650,25 +3725,21 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// wantVec *payload.Object_Vector -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Vector, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotVec *payload.Object_Vector, 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) -// } // return nil // } // tests := []test{ @@ -3677,8 +3748,7 @@ package grpc // { // name: "test_case_1", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -3708,8 +3778,7 @@ package grpc // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -3762,18 +3831,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// gotVec, err := s.GetObject(test.args.ctx, test.args.req) -// if err := checkFunc(test.want, gotVec, err); err != nil { +// err := s.StreamRemove(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_StreamGetObject(t *testing.T) { +// func Test_server_MultiRemove(t *testing.T) { // type args struct { -// stream vald.Object_StreamGetObjectServer +// ctx context.Context +// reqs *payload.Remove_MultiRequest // } // type fields struct { // eg errgroup.Group @@ -3787,21 +3856,25 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// err error +// wantLocs *payload.Object_Locations +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, 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(gotLocs, w.wantLocs) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) +// } // return nil // } // tests := []test{ @@ -3810,7 +3883,8 @@ package grpc // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -3840,7 +3914,8 @@ package grpc // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -3893,19 +3968,18 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamGetObject(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotLocs, err := s.MultiRemove(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_server_StreamListObject(t *testing.T) { +// func Test_server_RemoveByTimestamp(t *testing.T) { // type args struct { -// req *payload.Object_List_Request -// stream vald.Object_StreamListObjectServer +// ctx context.Context +// req *payload.Remove_TimestampRequest // } // type fields struct { // eg errgroup.Group @@ -3919,21 +3993,25 @@ package grpc // UnimplementedValdServer vald.UnimplementedValdServer // } // type want struct { -// err error +// wantLocs *payload.Object_Locations +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, 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(gotLocs, w.wantLocs) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) +// } // return nil // } // tests := []test{ @@ -3942,8 +4020,8 @@ package grpc // { // name: "test_case_1", // args: args { +// ctx:nil, // req:nil, -// stream:nil, // }, // fields: fields { // eg:nil, @@ -3973,8 +4051,8 @@ package grpc // return test { // name: "test_case_2", // args: args { +// ctx:nil, // req:nil, -// stream:nil, // }, // fields: fields { // eg:nil, @@ -4027,11 +4105,1627 @@ package grpc // UnimplementedValdServer: test.fields.UnimplementedValdServer, // } // -// err := s.StreamListObject(test.args.req, test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotLocs, err := s.RemoveByTimestamp(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotLocs, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func Test_server_getObject(t *testing.T) { +// type args struct { +// ctx context.Context +// uuid string +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantVec *payload.Object_Vector +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Vector, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotVec *payload.Object_Vector, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// uuid:"", +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// uuid:"", +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotVec, err := s.getObject(test.args.ctx, test.args.uuid) +// if err := checkFunc(test.want, gotVec, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_Flush(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Flush_Request +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantCnts *payload.Info_Index_Count +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Count, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCnts *payload.Info_Index_Count, 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(gotCnts, w.wantCnts) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCnts, w.wantCnts) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotCnts, err := s.Flush(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotCnts, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_GetObject(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Object_VectorRequest +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantVec *payload.Object_Vector +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Vector, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotVec *payload.Object_Vector, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotVec, err := s.GetObject(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotVec, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamGetObject(t *testing.T) { +// type args struct { +// stream vald.Object_StreamGetObjectServer +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamGetObject(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamListObject(t *testing.T) { +// type args struct { +// req *payload.Object_List_Request +// stream vald.Object_StreamListObjectServer +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// 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 { +// req:nil, +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// req:nil, +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// err := s.StreamListObject(test.args.req, test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_IndexInfo(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 *payload.Empty +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantVec *payload.Info_Index_Count +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Count, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotVec *payload.Info_Index_Count, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotVec, err := s.IndexInfo(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotVec, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_IndexDetail(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 *payload.Empty +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantVec *payload.Info_Index_Detail +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Detail, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotVec *payload.Info_Index_Detail, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotVec, err := s.IndexDetail(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotVec, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_GetTimestamp(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Object_TimestampRequest +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantTs *payload.Object_Timestamp +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Timestamp, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotTs *payload.Object_Timestamp, 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(gotTs, w.wantTs) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotTs, w.wantTs) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotTs, err := s.GetTimestamp(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotTs, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_IndexStatistics(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Empty +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantVec *payload.Info_Index_Statistics +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Statistics, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotVec *payload.Info_Index_Statistics, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotVec, err := s.IndexStatistics(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotVec, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_IndexStatisticsDetail(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 *payload.Empty +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// timeout time.Duration +// replica int +// streamConcurrency int +// multiConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// } +// type want struct { +// wantVec *payload.Info_Index_StatisticsDetail +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_StatisticsDetail, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotVec *payload.Info_Index_StatisticsDetail, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// timeout:nil, +// replica:0, +// streamConcurrency:0, +// multiConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// timeout: test.fields.timeout, +// replica: test.fields.replica, +// streamConcurrency: test.fields.streamConcurrency, +// multiConcurrency: test.fields.multiConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// } +// +// gotVec, err := s.IndexStatisticsDetail(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotVec, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_calculateMedian(t *testing.T) { +// type args struct { +// data []int32 +// } +// type want struct { +// want int32 +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, int32) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got int32) 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 { +// data: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 { +// data: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 := calculateMedian(test.args.data) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_sumHistograms(t *testing.T) { +// type args struct { +// hist1 []uint64 +// hist2 []uint64 +// } +// type want struct { +// want []uint64 +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, []uint64) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got []uint64) 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 { +// hist1:nil, +// hist2: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 { +// hist1:nil, +// hist2: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 := sumHistograms(test.args.hist1, test.args.hist2) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_mergeInfoIndexStatistics(t *testing.T) { +// type args struct { +// stats map[string]*payload.Info_Index_Statistics +// } +// type want struct { +// want *payload.Info_Index_Statistics +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, *payload.Info_Index_Statistics) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got *payload.Info_Index_Statistics) 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 { +// stats: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 { +// stats: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 := mergeInfoIndexStatistics(test.args.stats) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/gateway/lb/handler/grpc/option_test.go b/pkg/gateway/lb/handler/grpc/option_test.go index 994479ffb0..286f34c457 100644 --- a/pkg/gateway/lb/handler/grpc/option_test.go +++ b/pkg/gateway/lb/handler/grpc/option_test.go @@ -96,7 +96,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -440,7 +436,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +521,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -612,7 +606,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -698,7 +691,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/gateway/lb/handler/grpc/pairing_heap_test.go b/pkg/gateway/lb/handler/grpc/pairing_heap_test.go index 5ffccccb7c..3e83ee133e 100644 --- a/pkg/gateway/lb/handler/grpc/pairing_heap_test.go +++ b/pkg/gateway/lb/handler/grpc/pairing_heap_test.go @@ -192,7 +192,6 @@ func TestPairingHeap(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -295,7 +294,6 @@ func TestPairingHeap(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -398,7 +396,6 @@ func TestPairingHeap(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -495,7 +492,108 @@ func TestPairingHeap(t *testing.T) { // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func TestPairingHeap_mergePairs(t *testing.T) { +// type args struct { +// pairs []*PairingHeap +// } +// type fields struct { +// DistPayload *DistPayload +// Children []*PairingHeap +// } +// type want struct { +// want *PairingHeap +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *PairingHeap) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got *PairingHeap) 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 { +// pairs:nil, +// }, +// fields: fields { +// DistPayload:DistPayload{}, +// Children: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 { +// pairs:nil, +// }, +// fields: fields { +// DistPayload:DistPayload{}, +// Children: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 +// } +// ph := &PairingHeap{ +// DistPayload: test.fields.DistPayload, +// Children: test.fields.Children, +// } +// +// got := ph.mergePairs(test.args.pairs) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/gateway/lb/handler/grpc/search_benchmark_test.go b/pkg/gateway/lb/handler/grpc/search_benchmark_test.go index 7251d07273..06a2287980 100644 --- a/pkg/gateway/lb/handler/grpc/search_benchmark_test.go +++ b/pkg/gateway/lb/handler/grpc/search_benchmark_test.go @@ -86,7 +86,9 @@ func newRandomResponse() (res *payload.Search_Response) { return res } -func benchmark(b *testing.B, results []*payload.Search_Response, anew func(n, f, r int) Aggregator) { +func benchmark( + b *testing.B, results []*payload.Search_Response, anew func(n, f, r int) Aggregator, +) { ctx := context.Background() l := len(results) for k := 10; k < dataLength; k *= 10 { @@ -113,7 +115,10 @@ func benchmark(b *testing.B, results []*payload.Search_Response, anew func(n, f, } } -func doSearchWithAggregator(ctx context.Context, k, concurrency int, anew func(n, f, r int) Aggregator, +func doSearchWithAggregator( + ctx context.Context, + k, concurrency int, + anew func(n, f, r int) Aggregator, f func(ctx context.Context) *payload.Search_Response, ) (res *payload.Search_Response, err error) { eg, ectx := errgroup.New(ctx) diff --git a/pkg/gateway/lb/handler/rest/handler.go b/pkg/gateway/lb/handler/rest/handler.go index 83a7607453..49a6947209 100644 --- a/pkg/gateway/lb/handler/rest/handler.go +++ b/pkg/gateway/lb/handler/rest/handler.go @@ -63,141 +63,143 @@ func New(opts ...Option) Handler { } func (*handler) Index(w http.ResponseWriter, r *http.Request) (int, error) { - data := make(map[string]interface{}) - return json.Handler(w, r, &data, func() (interface{}, error) { + data := make(map[string]any) + return json.Handler(w, r, &data, func() (any, error) { return dump.Request(nil, data, r) }) } func (h *handler) Search(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Search(r.Context(), req) }) } func (h *handler) SearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.SearchByID(r.Context(), req) }) } func (h *handler) MultiSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiSearch(r.Context(), req) }) } func (h *handler) MultiSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiIDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiSearchByID(r.Context(), req) }) } func (h *handler) LinearSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.LinearSearch(r.Context(), req) }) } func (h *handler) LinearSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.LinearSearchByID(r.Context(), req) }) } func (h *handler) MultiLinearSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiLinearSearch(r.Context(), req) }) } -func (h *handler) MultiLinearSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { +func (h *handler) MultiLinearSearchByID( + w http.ResponseWriter, r *http.Request, +) (code int, err error) { var req *payload.Search_MultiIDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiLinearSearchByID(r.Context(), req) }) } func (h *handler) Insert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Insert(r.Context(), req) }) } func (h *handler) MultiInsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiInsert(r.Context(), req) }) } func (h *handler) Update(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Update(r.Context(), req) }) } func (h *handler) MultiUpdate(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiUpdate(r.Context(), req) }) } func (h *handler) Upsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Upsert_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Upsert(r.Context(), req) }) } func (h *handler) MultiUpsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Upsert_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiUpsert(r.Context(), req) }) } func (h *handler) Remove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Remove(r.Context(), req) }) } func (h *handler) MultiRemove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiRemove(r.Context(), req) }) } func (h *handler) Flush(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Flush_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Flush(r.Context(), req) }) } func (h *handler) GetObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_VectorRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.GetObject(r.Context(), req) }) } func (h *handler) Exists(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_ID - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Exists(r.Context(), req) }) } diff --git a/pkg/gateway/lb/handler/rest/handler_test.go b/pkg/gateway/lb/handler/rest/handler_test.go new file mode 100644 index 0000000000..07699533f9 --- /dev/null +++ b/pkg/gateway/lb/handler/rest/handler_test.go @@ -0,0 +1,2201 @@ +// 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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Index(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// want int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// got, err := h.Index(test.args.w, test.args.r) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Search(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Search(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_SearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.SearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.LinearSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.LinearSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiLinearSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiLinearSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiLinearSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiLinearSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Insert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Insert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiInsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiInsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Update(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Update(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpdate(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiUpdate(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Upsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Upsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiUpsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Remove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Remove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiRemove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiRemove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Flush(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Flush(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_GetObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.GetObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Exists(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald vald.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Exists(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/lb/handler/rest/option_test.go b/pkg/gateway/lb/handler/rest/option_test.go new file mode 100644 index 0000000000..dda27221fd --- /dev/null +++ b/pkg/gateway/lb/handler/rest/option_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestWithVald(t *testing.T) { +// type args struct { +// v vald.Server +// } +// 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 { +// v: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 { +// v: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 := WithVald(test.args.v) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/lb/router/option.go b/pkg/gateway/lb/router/option.go index 4c67a79325..e10f854aa6 100644 --- a/pkg/gateway/lb/router/option.go +++ b/pkg/gateway/lb/router/option.go @@ -17,9 +17,7 @@ // Package router provides implementation of Go API for routing http Handler wrapped by rest.Func package router -import ( - "github.com/vdaas/vald/pkg/gateway/lb/handler/rest" -) +import "github.com/vdaas/vald/pkg/gateway/lb/handler/rest" type Option func(*router) diff --git a/pkg/gateway/lb/router/option_test.go b/pkg/gateway/lb/router/option_test.go new file mode 100644 index 0000000000..c39d90a7bc --- /dev/null +++ b/pkg/gateway/lb/router/option_test.go @@ -0,0 +1,186 @@ +// 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 router + +// NOT IMPLEMENTED BELOW +// +// func TestWithHandler(t *testing.T) { +// type args struct { +// h rest.Handler +// } +// 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 { +// h: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 { +// h: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 := WithHandler(test.args.h) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTimeout(t *testing.T) { +// type args struct { +// timeout 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 { +// timeout:"", +// }, +// 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 { +// timeout:"", +// }, +// 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 := WithTimeout(test.args.timeout) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/lb/router/router_test.go b/pkg/gateway/lb/router/router_test.go new file mode 100644 index 0000000000..e9e3069588 --- /dev/null +++ b/pkg/gateway/lb/router/router_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 router + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want http.Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, http.Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got http.Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/lb/service/gateway.go b/pkg/gateway/lb/service/gateway.go index 8ae522c9ff..53c259c9e1 100644 --- a/pkg/gateway/lb/service/gateway.go +++ b/pkg/gateway/lb/service/gateway.go @@ -67,7 +67,9 @@ func (g *gateway) Start(ctx context.Context) (<-chan error, error) { return g.client.Start(ctx) } -func (g *gateway) BroadCast(ctx context.Context, kind BroadCastKind, +func (g *gateway) BroadCast( + ctx context.Context, + kind BroadCastKind, f func(ctx context.Context, target string, ac vald.Client, copts ...grpc.CallOption) error, ) (err error) { fctx, span := trace.StartSpan(ctx, "vald/gateway-lb/service/Gateway.BroadCast") @@ -101,7 +103,9 @@ func (g *gateway) BroadCast(ctx context.Context, kind BroadCastKind, }) } -func (g *gateway) DoMulti(ctx context.Context, num int, +func (g *gateway) DoMulti( + ctx context.Context, + num int, f func(ctx context.Context, target string, ac vald.Client, copts ...grpc.CallOption) error, ) (err error) { sctx, span := trace.StartSpan(ctx, "vald/gateway-lb/service/Gateway.DoMulti") diff --git a/pkg/gateway/lb/service/gateway_test.go b/pkg/gateway/lb/service/gateway_test.go index fd2aa12d82..57dccb0532 100644 --- a/pkg/gateway/lb/service/gateway_test.go +++ b/pkg/gateway/lb/service/gateway_test.go @@ -104,7 +104,6 @@ package service // if err := checkFunc(test.want, gotGw, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -211,15 +210,15 @@ package service // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // // func Test_gateway_BroadCast(t *testing.T) { // type args struct { -// ctx context.Context -// f func(ctx context.Context, target string, ac vald.Client, copts ...grpc.CallOption) error +// ctx context.Context +// kind BroadCastKind +// f func(ctx context.Context, target string, ac vald.Client, copts ...grpc.CallOption) error // } // type fields struct { // client discoverer.Client @@ -250,6 +249,7 @@ package service // name: "test_case_1", // args: args { // ctx:nil, +// kind:nil, // f:nil, // }, // fields: fields { @@ -274,6 +274,7 @@ package service // name: "test_case_2", // args: args { // ctx:nil, +// kind:nil, // f:nil, // }, // fields: fields { @@ -313,11 +314,10 @@ package service // eg: test.fields.eg, // } // -// err := g.BroadCast(test.args.ctx, test.args.f) +// err := g.BroadCast(test.args.ctx, test.args.kind, test.args.f) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -426,7 +426,6 @@ package service // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -529,7 +528,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -632,7 +630,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/gateway/lb/service/option_test.go b/pkg/gateway/lb/service/option_test.go index a865a431cb..415dad2f3e 100644 --- a/pkg/gateway/lb/service/option_test.go +++ b/pkg/gateway/lb/service/option_test.go @@ -100,7 +100,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/gateway/lb/usecase/vald.go b/pkg/gateway/lb/usecase/vald.go index b348b66639..66b0474415 100644 --- a/pkg/gateway/lb/usecase/vald.go +++ b/pkg/gateway/lb/usecase/vald.go @@ -46,7 +46,9 @@ type run struct { gateway service.Gateway } -func discovererClient(cfg *config.Data, dopts, aopts []grpc.Option, eg errgroup.Group) (discoverer.Client, error) { +func discovererClient( + cfg *config.Data, dopts, aopts []grpc.Option, eg errgroup.Group, +) (discoverer.Client, error) { var discovererOpts []discoverer.Option discovererOpts = append(discovererOpts, discoverer.WithAutoConnect(true), diff --git a/pkg/gateway/lb/usecase/vald_test.go b/pkg/gateway/lb/usecase/vald_test.go index f8a60a09d5..97f72478a1 100644 --- a/pkg/gateway/lb/usecase/vald_test.go +++ b/pkg/gateway/lb/usecase/vald_test.go @@ -195,7 +195,580 @@ func Test_discovererClient(t *testing.T) { // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// gateway service.Gateway +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// gateway: test.fields.gateway, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// gateway service.Gateway +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// gateway: test.fields.gateway, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// gateway service.Gateway +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// gateway: test.fields.gateway, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// gateway service.Gateway +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// gateway: test.fields.gateway, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// gateway service.Gateway +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// gateway: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// gateway: test.fields.gateway, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/gateway/mirror/config/config_test.go b/pkg/gateway/mirror/config/config_test.go new file mode 100644 index 0000000000..aed7f2d165 --- /dev/null +++ b/pkg/gateway/mirror/config/config_test.go @@ -0,0 +1,105 @@ +// 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 config + +// NOT IMPLEMENTED BELOW +// +// func TestNewConfig(t *testing.T) { +// type args struct { +// path string +// } +// type want struct { +// wantCfg *Data +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, *Data, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCfg *Data, 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(gotCfg, w.wantCfg) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCfg, w.wantCfg) +// } +// 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 +// } +// +// gotCfg, err := NewConfig(test.args.path) +// if err := checkFunc(test.want, gotCfg, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/handler/grpc/handler.go b/pkg/gateway/mirror/handler/grpc/handler.go index edafb8e872..45226b4806 100644 --- a/pkg/gateway/mirror/handler/grpc/handler.go +++ b/pkg/gateway/mirror/handler/grpc/handler.go @@ -75,7 +75,9 @@ func New(opts ...Option) (Server, error) { // Register handles the registration of mirror targets. // The function connects to the mirror using the provided targets, and if successful, // returns the addresses of connected Mirror gateways. -func (s *server) Register(ctx context.Context, req *payload.Mirror_Targets) (*payload.Mirror_Targets, error) { +func (s *server) Register( + ctx context.Context, req *payload.Mirror_Targets, +) (*payload.Mirror_Targets, error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+mirror.RPCServiceName+"/"+mirror.RegisterRPCName), apiName+"/"+mirror.RegisterRPCName) defer func() { if span != nil { @@ -164,7 +166,9 @@ func (s *server) Register(ctx context.Context, req *payload.Mirror_Targets) (*pa } // Exists bypasses the incoming Exist request to Vald gateway (LB gateway) in its own cluster. -func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *payload.Object_ID, err error) { +func (s *server) Exists( + ctx context.Context, meta *payload.Object_ID, +) (id *payload.Object_ID, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.ObjectRPCServiceName+"/"+vald.ExistsRPCName), apiName+"/"+vald.ExistsRPCName) defer func() { if span != nil { @@ -172,7 +176,7 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *paylo } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { id, err = vc.Exists(ctx, meta, copts...) return id, err }) @@ -229,7 +233,9 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *paylo } // Search bypasses the incoming Search request to Vald gateway (LB gateway) in its own cluster. -func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) Search( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.SearchRPCName), apiName+"/"+vald.SearchRPCName) defer func() { if span != nil { @@ -237,7 +243,7 @@ func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res * } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { res, err = vc.Search(ctx, req, copts...) return res, err }) @@ -295,9 +301,9 @@ func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res * } // SearchByID bypasses the incoming SearchByID request to Vald gateway (LB gateway) in its own cluster. -func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) ( - res *payload.Search_Response, err error, -) { +func (s *server) SearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.SearchByIDRPCName), apiName+"/"+vald.SearchByIDRPCName) defer func() { if span != nil { @@ -305,7 +311,7 @@ func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { res, err = vc.SearchByID(ctx, req, copts...) return res, err }) @@ -463,7 +469,9 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er } // MultiSearch bypasses the incoming MultiSearch request to Vald gateway (LB gateway) in its own cluster. -func (s *server) MultiSearch(ctx context.Context, req *payload.Search_MultiRequest) (res *payload.Search_Responses, err error) { +func (s *server) MultiSearch( + ctx context.Context, req *payload.Search_MultiRequest, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.MultiSearchRPCName), apiName+"/"+vald.MultiSearchRPCName) defer func() { if span != nil { @@ -471,7 +479,7 @@ func (s *server) MultiSearch(ctx context.Context, req *payload.Search_MultiReque } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { res, err = vc.MultiSearch(ctx, req, copts...) return res, err }) @@ -528,7 +536,9 @@ func (s *server) MultiSearch(ctx context.Context, req *payload.Search_MultiReque } // MultiSearchByID bypasses the incoming MultiSearchByID request to Vald gateway (LB gateway) in its own cluster. -func (s *server) MultiSearchByID(ctx context.Context, req *payload.Search_MultiIDRequest) (res *payload.Search_Responses, err error) { +func (s *server) MultiSearchByID( + ctx context.Context, req *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.MultiSearchByIDRPCName), apiName+"/"+vald.MultiSearchByIDRPCName) defer func() { if span != nil { @@ -536,7 +546,7 @@ func (s *server) MultiSearchByID(ctx context.Context, req *payload.Search_MultiI } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { res, err = vc.MultiSearchByID(ctx, req, copts...) return res, err }) @@ -593,7 +603,9 @@ func (s *server) MultiSearchByID(ctx context.Context, req *payload.Search_MultiI } // LinearSearch bypasses the incoming LinearSearch request to Vald gateway (LB gateway) in its own cluster. -func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) (res *payload.Search_Response, err error) { +func (s *server) LinearSearch( + ctx context.Context, req *payload.Search_Request, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.LinearSearchRPCName), apiName+"/"+vald.LinearSearchRPCName) defer func() { if span != nil { @@ -601,7 +613,7 @@ func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { res, err = vc.LinearSearch(ctx, req, copts...) return res, err }) @@ -659,9 +671,9 @@ func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) } // LinearSearchByID bypasses the incoming LinearSearchByID request to Vald gateway (LB gateway) in its own cluster. -func (s *server) LinearSearchByID(ctx context.Context, req *payload.Search_IDRequest) ( - res *payload.Search_Response, err error, -) { +func (s *server) LinearSearchByID( + ctx context.Context, req *payload.Search_IDRequest, +) (res *payload.Search_Response, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.LinearSearchByIDRPCName), apiName+"/"+vald.LinearSearchByIDRPCName) defer func() { if span != nil { @@ -669,7 +681,7 @@ func (s *server) LinearSearchByID(ctx context.Context, req *payload.Search_IDReq } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { res, err = vc.LinearSearchByID(ctx, req, copts...) return res, err }) @@ -777,7 +789,9 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) } // StreamLinearSearchByID bypasses it as a LinearSearchByID request to Vald gateway (LB gateway) in its own cluster. -func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByIDServer) (err error) { +func (s *server) StreamLinearSearchByID( + stream vald.Search_StreamLinearSearchByIDServer, +) (err error) { ctx, span := trace.StartSpan( grpc.WithGRPCMethod(stream.Context(), vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.StreamLinearSearchByIDRPCName), apiName+"/"+vald.StreamLinearSearchByIDRPCName, @@ -830,7 +844,9 @@ func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByI } // MultiLinearSearch bypasses the incoming MultiLinearSearch request to Vald gateway (LB gateway) in its own cluster. -func (s *server) MultiLinearSearch(ctx context.Context, req *payload.Search_MultiRequest) (res *payload.Search_Responses, err error) { +func (s *server) MultiLinearSearch( + ctx context.Context, req *payload.Search_MultiRequest, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.MultiLinearSearchRPCName), apiName+"/"+vald.MultiLinearSearchRPCName) defer func() { if span != nil { @@ -838,7 +854,7 @@ func (s *server) MultiLinearSearch(ctx context.Context, req *payload.Search_Mult } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { res, err = vc.MultiLinearSearch(ctx, req, copts...) return res, err }) @@ -895,7 +911,9 @@ func (s *server) MultiLinearSearch(ctx context.Context, req *payload.Search_Mult } // MultiLinearSearchByID bypasses the incoming MultiLinearSearchByID request to Vald gateway (LB gateway) in its own cluster. -func (s *server) MultiLinearSearchByID(ctx context.Context, req *payload.Search_MultiIDRequest) (res *payload.Search_Responses, err error) { +func (s *server) MultiLinearSearchByID( + ctx context.Context, req *payload.Search_MultiIDRequest, +) (res *payload.Search_Responses, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.SearchRPCServiceName+"/"+vald.MultiLinearSearchByIDRPCName), apiName+"/"+vald.MultiLinearSearchByIDRPCName) defer func() { if span != nil { @@ -903,7 +921,7 @@ func (s *server) MultiLinearSearchByID(ctx context.Context, req *payload.Search_ } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { res, err = vc.MultiLinearSearchByID(ctx, req, copts...) return res, err }) @@ -963,7 +981,9 @@ func (s *server) MultiLinearSearchByID(ctx context.Context, req *payload.Search_ // If the request is proxied from another Mirror gateway, the request is forwarded to the Vald gateway (LB gateway) of its own cluster. // If the request is from a user, it is sent to other Mirror gateways and the Vald gateway (LB gateway) of its own cluster. // The result is a location of the inserted object. -func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (loc *payload.Object_Location, err error) { +func (s *server) Insert( + ctx context.Context, req *payload.Insert_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.InsertRPCServiceName+"/"+vald.InsertRPCName), apiName+"/"+vald.InsertRPCName) defer func() { if span != nil { @@ -975,7 +995,7 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (loc * // So this component sends requests only to the Vald gateway (LB gateway) of its own cluster. if s.isProxied(ctx) { loc, err = s.doInsert(ctx, req, func(ctx context.Context) (*payload.Object_Location, error) { - _, derr := s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, derr := s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { loc, err = vc.Insert(ctx, req, copts...) return loc, err }) @@ -1009,7 +1029,9 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (loc * return s.handleInsert(ctx, req) } -func (s *server) handleInsert(ctx context.Context, req *payload.Insert_Request) (loc *payload.Object_Location, err error) { // skipcq: GO-R1005 +func (s *server) handleInsert( + ctx context.Context, req *payload.Insert_Request, +) (loc *payload.Object_Location, err error) { // skipcq: GO-R1005 ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, "handleInsert"), apiName+"/handleInsert") defer func() { if span != nil { @@ -1168,7 +1190,8 @@ func (s *server) handleInsert(ctx context.Context, req *payload.Insert_Request) return loc, nil } -func (s *server) handleInsertResult( // skipcq: GO-R1005 +func (s *server) handleInsertResult( + // skipcq: GO-R1005 ctx context.Context, alreadyExistsTgts []string, req *payload.Update_Request, @@ -1318,7 +1341,11 @@ func (s *server) handleInsertResult( // skipcq: GO-R1005 return loc, nil } -func (s *server) doInsert(ctx context.Context, req *payload.Insert_Request, f func(ctx context.Context) (*payload.Object_Location, error)) (loc *payload.Object_Location, err error) { +func (s *server) doInsert( + ctx context.Context, + req *payload.Insert_Request, + f func(ctx context.Context) (*payload.Object_Location, error), +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "doInsert"), apiName+"/doInsert") defer func() { if span != nil { @@ -1435,7 +1462,9 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) // MultiInsert handles the insertion of multiple objects with the given requests. // For each request in parallel, it calls the Insert function to insert an object. // If an error occurs during any of the insertions, it accumulates the errors and returns them along with the successfully inserted locations. -func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequest) (res *payload.Object_Locations, errs error) { +func (s *server) MultiInsert( + ctx context.Context, reqs *payload.Insert_MultiRequest, +) (res *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.InsertRPCServiceName+"/"+vald.MultiInsertRPCName), apiName+"/"+vald.MultiInsertRPCName) defer func() { if span != nil { @@ -1507,7 +1536,9 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ // If the request is proxied from another Mirror gateway, it sends the request only to the Vald gateway (LB gateway) of its own cluster. // If the request is from a user, it sends requests to other Mirror gateways and the Vald gateway (LB gateway) of its own cluster. // The result is a location of the updated object. -func (s *server) Update(ctx context.Context, req *payload.Update_Request) (loc *payload.Object_Location, err error) { +func (s *server) Update( + ctx context.Context, req *payload.Update_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.UpdateRPCServiceName+"/"+vald.UpdateRPCName), apiName+"/"+vald.UpdateRPCName) defer func() { if span != nil { @@ -1519,7 +1550,7 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (loc * // So this component sends requests only to the Vald gateway (LB gateway) of its own cluster. if s.isProxied(ctx) { loc, err = s.doUpdate(ctx, req, func(ctx context.Context) (*payload.Object_Location, error) { - _, derr := s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, derr := s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { loc, err = vc.Update(ctx, req, copts...) return loc, err }) @@ -1553,7 +1584,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (loc * return s.handleUpdate(ctx, req) } -func (s *server) handleUpdate(ctx context.Context, req *payload.Update_Request) (loc *payload.Object_Location, err error) { // skipcq: GO-R1005 +func (s *server) handleUpdate( + ctx context.Context, req *payload.Update_Request, +) (loc *payload.Object_Location, err error) { // skipcq: GO-R1005 ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, "handleUpdate"), apiName+"/handleUpdate") defer func() { if span != nil { @@ -1727,7 +1760,8 @@ func (s *server) handleUpdate(ctx context.Context, req *payload.Update_Request) return loc, nil } -func (s *server) handleUpdateResult( // skipcq: GO-R1005 +func (s *server) handleUpdateResult( + // skipcq: GO-R1005 ctx context.Context, notFoundTgts []string, req *payload.Insert_Request, @@ -1892,7 +1926,11 @@ func (s *server) handleUpdateResult( // skipcq: GO-R1005 return loc, nil } -func (s *server) doUpdate(ctx context.Context, req *payload.Update_Request, f func(ctx context.Context) (*payload.Object_Location, error)) (loc *payload.Object_Location, err error) { +func (s *server) doUpdate( + ctx context.Context, + req *payload.Update_Request, + f func(ctx context.Context) (*payload.Object_Location, error), +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "doUpdate"), apiName+"/doUpdate") defer func() { if span != nil { @@ -2009,7 +2047,9 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) // MultiUpdate handles the update of multiple objects with the given requests. // For each request in parallel, it calls the Update function to update an object. // If an error occurs during any of the insertions, it accumulates the errors and returns them along with the successfully updated locations. -func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequest) (res *payload.Object_Locations, errs error) { +func (s *server) MultiUpdate( + ctx context.Context, reqs *payload.Update_MultiRequest, +) (res *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.UpdateRPCServiceName+"/"+vald.MultiUpdateRPCName), apiName+"/"+vald.MultiUpdateRPCName) defer func() { if span != nil { @@ -2081,7 +2121,9 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ // If the request is proxied from another Mirror gateway, the request is forwarded to the Vald gateway (LB gateway) of its own cluster. // If the request is from a user, it is sent to other Mirror gateways and the Vald gateway (LB gateway) of its own cluster. // The result is a location of the upserted object. -func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc *payload.Object_Location, err error) { +func (s *server) Upsert( + ctx context.Context, req *payload.Upsert_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.UpsertRPCServiceName+"/"+vald.UpsertRPCName), apiName+"/"+vald.UpsertRPCName) defer func() { if span != nil { @@ -2093,7 +2135,7 @@ func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc * // So this component sends requests only to the Vald gateway (LB gateway) of its own cluster. if s.isProxied(ctx) { loc, err = s.doUpsert(ctx, req, func(ctx context.Context) (*payload.Object_Location, error) { - s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { loc, err = vc.Upsert(ctx, req, copts...) return loc, err }) @@ -2128,7 +2170,9 @@ func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc * return s.handleUpsert(ctx, req) } -func (s *server) handleUpsert(ctx context.Context, req *payload.Upsert_Request) (loc *payload.Object_Location, err error) { // skipcq: GO-R1005 +func (s *server) handleUpsert( + ctx context.Context, req *payload.Upsert_Request, +) (loc *payload.Object_Location, err error) { // skipcq: GO-R1005 ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, "handleUpsert"), apiName+"/handleUpsert") defer func() { if span != nil { @@ -2272,7 +2316,11 @@ func (s *server) handleUpsert(ctx context.Context, req *payload.Upsert_Request) } } -func (s *server) doUpsert(ctx context.Context, req *payload.Upsert_Request, f func(ctx context.Context) (*payload.Object_Location, error)) (loc *payload.Object_Location, err error) { +func (s *server) doUpsert( + ctx context.Context, + req *payload.Upsert_Request, + f func(ctx context.Context) (*payload.Object_Location, error), +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "doUpsert"), apiName+"/doUpsert") defer func() { if span != nil { @@ -2389,7 +2437,9 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) // MultiUpsert handles the upsert of multiple objects with the given requests. // For each request in parallel, it calls the Upsert function to upsert an object. // If an error occurs during any of the insertions, it accumulates the errors and returns them along with the successfully upserted locations. -func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequest) (res *payload.Object_Locations, errs error) { +func (s *server) MultiUpsert( + ctx context.Context, reqs *payload.Upsert_MultiRequest, +) (res *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.UpsertRPCServiceName+"/"+vald.MultiUpsertRPCName), apiName+"/"+vald.MultiUpsertRPCName) defer func() { if span != nil { @@ -2461,7 +2511,9 @@ func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequ // If the request is proxied from another Mirror gateway, the request is forwarded to the Vald gateway (LB gateway) of its own cluster. // If the request is from a user, it is sent to other Mirror gateways and the Vald gateway (LB gateway) of its own cluster. // The result is a location of the removed object. -func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (loc *payload.Object_Location, err error) { +func (s *server) Remove( + ctx context.Context, req *payload.Remove_Request, +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.RemoveRPCServiceName+"/"+vald.RemoveRPCName), apiName+"/"+vald.RemoveRPCName) defer func() { if span != nil { @@ -2473,7 +2525,7 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (loc * // So this component sends requests only to the Vald gateway (LB gateway) of its own cluster. if s.isProxied(ctx) { loc, err = s.doRemove(ctx, req, func(ctx context.Context) (*payload.Object_Location, error) { - s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { loc, err = vc.Remove(ctx, req, copts...) return loc, err }) @@ -2507,7 +2559,9 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (loc * return s.handleRemove(ctx, req) } -func (s *server) handleRemove(ctx context.Context, req *payload.Remove_Request) (loc *payload.Object_Location, err error) { // skipcq: GO-R1005 +func (s *server) handleRemove( + ctx context.Context, req *payload.Remove_Request, +) (loc *payload.Object_Location, err error) { // skipcq: GO-R1005 ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, "handleRemove"), apiName+"/handleRemove") defer func() { if span != nil { @@ -2648,7 +2702,11 @@ func (s *server) handleRemove(ctx context.Context, req *payload.Remove_Request) } } -func (s *server) doRemove(ctx context.Context, req *payload.Remove_Request, f func(ctx context.Context) (*payload.Object_Location, error)) (loc *payload.Object_Location, err error) { +func (s *server) doRemove( + ctx context.Context, + req *payload.Remove_Request, + f func(ctx context.Context) (*payload.Object_Location, error), +) (loc *payload.Object_Location, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "doRemove"), apiName+"/doRemove") defer func() { if span != nil { @@ -2764,7 +2822,9 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) // MultiRemove handles the remove of multiple objects with the given requests. // For each request in parallel, it calls the Remove function to insert an object. // If an error occurs during any of the insertions, it accumulates the errors and returns them along with the successfully removed locations. -func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequest) (res *payload.Object_Locations, errs error) { +func (s *server) MultiRemove( + ctx context.Context, reqs *payload.Remove_MultiRequest, +) (res *payload.Object_Locations, errs error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.RemoveRPCServiceName+"/"+vald.MultiRemoveRPCName), apiName+"/"+vald.MultiRemoveRPCName) defer func() { if span != nil { @@ -2836,7 +2896,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ // If the request is proxied from another Mirror gateway, the request is forwarded to the Vald gateway (LB gateway) of its own cluster. // If the request is from a user, it is sent to other Mirror gateways and the Vald gateway (LB gateway) of its own cluster. // The result is a location of the removed object. -func (s *server) RemoveByTimestamp(ctx context.Context, req *payload.Remove_TimestampRequest) (locs *payload.Object_Locations, err error) { +func (s *server) RemoveByTimestamp( + ctx context.Context, req *payload.Remove_TimestampRequest, +) (locs *payload.Object_Locations, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.RemoveRPCServiceName+"/"+vald.RemoveByTimestampRPCName), apiName+"/"+vald.RemoveByTimestampRPCName) defer func() { if span != nil { @@ -2848,7 +2910,7 @@ func (s *server) RemoveByTimestamp(ctx context.Context, req *payload.Remove_Time // So this component sends requests only to the Vald gateway (LB gateway) of its own cluster. if s.isProxied(ctx) { locs, err = s.doRemoveByTimestamp(ctx, req, func(ctx context.Context) (*payload.Object_Locations, error) { - _, derr := s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, derr := s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { locs, err = vc.RemoveByTimestamp(ctx, req, copts...) return locs, err }) @@ -2882,7 +2944,9 @@ func (s *server) RemoveByTimestamp(ctx context.Context, req *payload.Remove_Time return s.handleRemoveByTimestamp(ctx, req) } -func (s *server) handleRemoveByTimestamp(ctx context.Context, req *payload.Remove_TimestampRequest) (locs *payload.Object_Locations, err error) { // skipcq: GO-R1005 +func (s *server) handleRemoveByTimestamp( + ctx context.Context, req *payload.Remove_TimestampRequest, +) (locs *payload.Object_Locations, err error) { // skipcq: GO-R1005 ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, "handleRemoveByTimestamp"), apiName+"/handleRemoveByTimestamp") defer func() { if span != nil { @@ -3084,7 +3148,9 @@ func (s *server) doRemoveByTimestamp( } // GetObject bypasses the incoming GetObject request to Vald LB gateway in its own cluster. -func (s *server) GetObject(ctx context.Context, req *payload.Object_VectorRequest) (vec *payload.Object_Vector, err error) { +func (s *server) GetObject( + ctx context.Context, req *payload.Object_VectorRequest, +) (vec *payload.Object_Vector, err error) { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+vald.ObjectRPCServiceName+"/"+vald.GetObjectRPCName), apiName+"/"+vald.GetObjectRPCName) defer func() { if span != nil { @@ -3092,7 +3158,7 @@ func (s *server) GetObject(ctx context.Context, req *payload.Object_VectorReques } }() - _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (interface{}, error) { + _, err = s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, _ string, vc service.MirrorClient, copts ...grpc.CallOption) (any, error) { vec, err = vc.GetObject(ctx, req, copts...) return vec, err }) @@ -3199,7 +3265,9 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err } // StreamListObject bypasses it as a StreamListObject request to the Vald gateway (LB gateway) in its own cluster. -func (s *server) StreamListObject(req *payload.Object_List_Request, stream vald.Object_StreamListObjectServer) error { +func (s *server) StreamListObject( + req *payload.Object_List_Request, stream vald.Object_StreamListObjectServer, +) error { ctx, span := trace.StartSpan(grpc.WithGRPCMethod(stream.Context(), vald.PackageName+"."+vald.ObjectRPCServiceName+"/"+vald.StreamListObjectRPCName), apiName+"/"+vald.StreamListObjectRPCName) defer func() { if span != nil { @@ -3207,7 +3275,7 @@ func (s *server) StreamListObject(req *payload.Object_List_Request, stream vald. } }() - _, err := s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, target string, vc service.MirrorClient, copts ...grpc.CallOption) (obj interface{}, err error) { + _, err := s.gateway.Do(ctx, s.vAddr, func(ctx context.Context, target string, vc service.MirrorClient, copts ...grpc.CallOption) (obj any, err error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "Do/"+target), apiName+"/"+vald.StreamListObjectRPCName+"/"+target) defer func() { if span != nil { @@ -3232,7 +3300,11 @@ func (s *server) StreamListObject(req *payload.Object_List_Request, stream vald. return nil } -func (s *server) doStreamListObject(ctx context.Context, client vald.Object_StreamListObjectClient, server vald.Object_StreamListObjectServer) (err error) { // skipcq: GO-R1005 +func (s *server) doStreamListObject( + ctx context.Context, + client vald.Object_StreamListObjectClient, + server vald.Object_StreamListObjectServer, +) (err error) { // skipcq: GO-R1005 cctx, cancel := context.WithCancel(ctx) defer cancel() eg, egctx := errgroup.WithContext(cctx) @@ -3341,8 +3413,10 @@ func (s *server) doStreamListObject(ctx context.Context, client vald.Object_Stre } } -// TODO: implement Flush handler -func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (*payload.Info_Index_Count, error) { +// TODO: implement Flush handler. +func (s *server) Flush( + ctx context.Context, req *payload.Flush_Request, +) (*payload.Info_Index_Count, error) { return s.UnimplementedFlushServer.Flush(ctx, req) } diff --git a/pkg/gateway/mirror/handler/grpc/handler_test.go b/pkg/gateway/mirror/handler/grpc/handler_test.go index 84a24a1dd3..569a4a1f38 100644 --- a/pkg/gateway/mirror/handler/grpc/handler_test.go +++ b/pkg/gateway/mirror/handler/grpc/handler_test.go @@ -2340,25 +2340,24 @@ func Test_server_RemoveByTimestamp(t *testing.T) { } // NOT IMPLEMENTED BELOW - +// // func TestNew(t *testing.T) { -// t.Parallel() // type args struct { // opts []Option // } // type want struct { -// want vald.ServerWithMirror +// want Server // err error // } // type test struct { // name string // args args // want want -// checkFunc func(want, vald.Server, error) error +// checkFunc func(want, Server, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got vald.Server, err error) error { +// defaultCheckFunc := func(w want, got Server, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -2432,20 +2431,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_Register(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // req *payload.Mirror_Targets // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // want *payload.Mirror_Targets @@ -2486,7 +2485,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2516,7 +2516,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2547,14 +2548,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // got, err := s.Register(test.args.ctx, test.args.req) @@ -2566,20 +2568,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_Exists(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // meta *payload.Object_ID // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // wantId *payload.Object_ID @@ -2594,12 +2596,12 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotID *payload.Object_ID, err error) error { +// defaultCheckFunc := func(w want, gotId *payload.Object_ID, 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(gotID, w.wantId) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotID, w.wantId) +// if !reflect.DeepEqual(gotId, w.wantId) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotId, w.wantId) // } // return nil // } @@ -2620,7 +2622,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2650,7 +2653,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2681,18 +2685,19 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, -// } -// -// gotID, err := s.Exists(test.args.ctx, test.args.meta) -// if err := checkFunc(test.want, gotID, err); err != nil { +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotId, err := s.Exists(test.args.ctx, test.args.meta) +// if err := checkFunc(test.want, gotId, err); err != nil { // tt.Errorf("error = %v", err) // } // }) @@ -2700,20 +2705,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_Search(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // req *payload.Search_Request // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // wantRes *payload.Search_Response @@ -2754,7 +2759,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2784,7 +2790,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2815,14 +2822,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // gotRes, err := s.Search(test.args.ctx, test.args.req) @@ -2834,20 +2842,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_SearchByID(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // req *payload.Search_IDRequest // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // wantRes *payload.Search_Response @@ -2888,7 +2896,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2918,7 +2927,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -2949,14 +2959,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // gotRes, err := s.SearchByID(test.args.ctx, test.args.req) @@ -2968,19 +2979,19 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_StreamSearch(t *testing.T) { -// t.Parallel() // type args struct { // stream vald.Search_StreamSearchServer // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // err error @@ -3016,7 +3027,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3045,7 +3057,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3076,14 +3089,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // err := s.StreamSearch(test.args.stream) @@ -3095,19 +3109,19 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_StreamSearchByID(t *testing.T) { -// t.Parallel() // type args struct { // stream vald.Search_StreamSearchByIDServer // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // err error @@ -3143,7 +3157,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3172,7 +3187,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3203,14 +3219,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // err := s.StreamSearchByID(test.args.stream) @@ -3222,20 +3239,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_MultiSearch(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // req *payload.Search_MultiRequest // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // wantRes *payload.Search_Responses @@ -3276,7 +3293,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3306,7 +3324,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3337,14 +3356,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // gotRes, err := s.MultiSearch(test.args.ctx, test.args.req) @@ -3356,20 +3376,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_MultiSearchByID(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // req *payload.Search_MultiIDRequest // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // wantRes *payload.Search_Responses @@ -3410,7 +3430,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3440,7 +3461,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3471,14 +3493,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // gotRes, err := s.MultiSearchByID(test.args.ctx, test.args.req) @@ -3490,20 +3513,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_LinearSearch(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // req *payload.Search_Request // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // wantRes *payload.Search_Response @@ -3544,7 +3567,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3574,7 +3598,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3605,14 +3630,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // gotRes, err := s.LinearSearch(test.args.ctx, test.args.req) @@ -3624,20 +3650,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_LinearSearchByID(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // req *payload.Search_IDRequest // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // wantRes *payload.Search_Response @@ -3678,7 +3704,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3708,7 +3735,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3739,14 +3767,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // gotRes, err := s.LinearSearchByID(test.args.ctx, test.args.req) @@ -3758,19 +3787,19 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_StreamLinearSearch(t *testing.T) { -// t.Parallel() // type args struct { // stream vald.Search_StreamLinearSearchServer // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // err error @@ -3806,7 +3835,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3835,7 +3865,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3866,14 +3897,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // err := s.StreamLinearSearch(test.args.stream) @@ -3885,19 +3917,19 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_StreamLinearSearchByID(t *testing.T) { -// t.Parallel() // type args struct { // stream vald.Search_StreamLinearSearchByIDServer // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // err error @@ -3933,7 +3965,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3962,7 +3995,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -3993,14 +4027,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // err := s.StreamLinearSearchByID(test.args.stream) @@ -4012,20 +4047,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_MultiLinearSearch(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // req *payload.Search_MultiRequest // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // wantRes *payload.Search_Responses @@ -4066,7 +4101,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4096,7 +4132,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4127,14 +4164,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // gotRes, err := s.MultiLinearSearch(test.args.ctx, test.args.req) @@ -4146,20 +4184,20 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // // func Test_server_MultiLinearSearchByID(t *testing.T) { -// t.Parallel() // type args struct { // ctx context.Context // req *payload.Search_MultiIDRequest // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { // wantRes *payload.Search_Responses @@ -4200,7 +4238,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4230,7 +4269,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4261,14 +4301,15 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // // gotRes, err := s.MultiLinearSearchByID(test.args.ctx, test.args.req) @@ -4279,37 +4320,42 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // } // } // -// func Test_server_StreamInsert(t *testing.T) { -// t.Parallel() +// func Test_server_handleInsert(t *testing.T) { // type args struct { -// stream vald.Insert_StreamInsertServer +// ctx context.Context +// req *payload.Insert_Request // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// err error +// wantLoc *payload.Object_Location +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } // return nil // } // tests := []test{ @@ -4318,7 +4364,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -4328,7 +4375,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4347,7 +4395,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -4357,7 +4406,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4388,42 +4438,45 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// err := s.StreamInsert(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotLoc, err := s.handleInsert(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_server_MultiInsert(t *testing.T) { -// t.Parallel() +// func Test_server_handleInsertResult(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Insert_MultiRequest +// ctx context.Context +// alreadyExistsTgts []string +// req *payload.Update_Request +// result *sync.Map[string, *errorState] // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// wantRes *payload.Object_Locations +// wantLoc *payload.Object_Location // err error // } // type test struct { @@ -4431,16 +4484,16 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) // } // return nil // } @@ -4451,7 +4504,9 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, -// reqs:nil, +// alreadyExistsTgts:nil, +// req:nil, +// result:nil, // }, // fields: fields { // eg:nil, @@ -4461,7 +4516,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4481,7 +4537,9 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, -// reqs:nil, +// alreadyExistsTgts:nil, +// req:nil, +// result:nil, // }, // fields: fields { // eg:nil, @@ -4491,7 +4549,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4522,55 +4581,62 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// gotRes, err := s.MultiInsert(test.args.ctx, test.args.reqs) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// gotLoc, err := s.handleInsertResult(test.args.ctx, test.args.alreadyExistsTgts, test.args.req, test.args.result) +// if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_server_StreamUpdate(t *testing.T) { -// t.Parallel() +// func Test_server_doInsert(t *testing.T) { // type args struct { -// stream vald.Update_StreamUpdateServer +// ctx context.Context +// req *payload.Insert_Request +// f func(ctx context.Context) (*payload.Object_Location, error) // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// err error +// wantLoc *payload.Object_Location +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } // return nil // } // tests := []test{ @@ -4579,7 +4645,9 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, +// f:nil, // }, // fields: fields { // eg:nil, @@ -4589,7 +4657,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4608,7 +4677,9 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// req:nil, +// f:nil, // }, // fields: fields { // eg:nil, @@ -4618,7 +4689,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4649,60 +4721,56 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// err := s.StreamUpdate(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotLoc, err := s.doInsert(test.args.ctx, test.args.req, test.args.f) +// if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_server_MultiUpdate(t *testing.T) { -// t.Parallel() +// func Test_server_StreamInsert(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Update_MultiRequest +// stream vald.Insert_StreamInsertServer // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// wantRes *payload.Object_Locations -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, 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(gotRes, w.wantRes) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) -// } // return nil // } // tests := []test{ @@ -4711,8 +4779,7 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // { // name: "test_case_1", // args: args { -// ctx:nil, -// reqs:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -4722,7 +4789,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4741,8 +4809,7 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// reqs:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -4752,7 +4819,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4783,55 +4851,61 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// gotRes, err := s.MultiUpdate(test.args.ctx, test.args.reqs) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// err := s.StreamInsert(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_server_StreamUpsert(t *testing.T) { -// t.Parallel() +// func Test_server_MultiInsert(t *testing.T) { // type args struct { -// stream vald.Upsert_StreamUpsertServer +// ctx context.Context +// reqs *payload.Insert_MultiRequest // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// err error +// wantRes *payload.Object_Locations +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, 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 // } // tests := []test{ @@ -4840,7 +4914,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -4850,7 +4925,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4869,7 +4945,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -4879,7 +4956,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -4910,42 +4988,43 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// err := s.StreamUpsert(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotRes, err := s.MultiInsert(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_server_MultiUpsert(t *testing.T) { -// t.Parallel() +// func Test_server_handleUpdate(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Upsert_MultiRequest +// ctx context.Context +// req *payload.Update_Request // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// wantRes *payload.Object_Locations +// wantLoc *payload.Object_Location // err error // } // type test struct { @@ -4953,16 +5032,16 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) // } // return nil // } @@ -4973,7 +5052,7 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, -// reqs:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -4983,7 +5062,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5003,7 +5083,7 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, -// reqs:nil, +// req:nil, // }, // fields: fields { // eg:nil, @@ -5013,7 +5093,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5044,55 +5125,63 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// gotRes, err := s.MultiUpsert(test.args.ctx, test.args.reqs) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// gotLoc, err := s.handleUpdate(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_server_StreamRemove(t *testing.T) { -// t.Parallel() +// func Test_server_handleUpdateResult(t *testing.T) { // type args struct { -// stream vald.Remove_StreamRemoveServer +// ctx context.Context +// notFoundTgts []string +// req *payload.Insert_Request +// result *sync.Map[string, *errorState] // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// err error +// wantLoc *payload.Object_Location +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } // return nil // } // tests := []test{ @@ -5101,7 +5190,10 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// notFoundTgts:nil, +// req:nil, +// result:nil, // }, // fields: fields { // eg:nil, @@ -5111,7 +5203,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5130,7 +5223,10 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// notFoundTgts:nil, +// req:nil, +// result:nil, // }, // fields: fields { // eg:nil, @@ -5140,7 +5236,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5171,42 +5268,44 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// err := s.StreamRemove(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotLoc, err := s.handleUpdateResult(test.args.ctx, test.args.notFoundTgts, test.args.req, test.args.result) +// if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_server_MultiRemove(t *testing.T) { -// t.Parallel() +// func Test_server_doUpdate(t *testing.T) { // type args struct { -// ctx context.Context -// reqs *payload.Remove_MultiRequest +// ctx context.Context +// req *payload.Update_Request +// f func(ctx context.Context) (*payload.Object_Location, error) // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// wantRes *payload.Object_Locations +// wantLoc *payload.Object_Location // err error // } // type test struct { @@ -5214,16 +5313,16 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Locations, error) error +// checkFunc func(want, *payload.Object_Location, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, err error) error { +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) // } // return nil // } @@ -5234,7 +5333,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, -// reqs:nil, +// req:nil, +// f:nil, // }, // fields: fields { // eg:nil, @@ -5244,7 +5344,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5264,7 +5365,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, -// reqs:nil, +// req:nil, +// f:nil, // }, // fields: fields { // eg:nil, @@ -5274,7 +5376,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5305,60 +5408,56 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// gotRes, err := s.MultiRemove(test.args.ctx, test.args.reqs) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// gotLoc, err := s.doUpdate(test.args.ctx, test.args.req, test.args.f) +// if err := checkFunc(test.want, gotLoc, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_server_GetObject(t *testing.T) { -// t.Parallel() +// func Test_server_StreamUpdate(t *testing.T) { // type args struct { -// ctx context.Context -// req *payload.Object_VectorRequest +// stream vald.Update_StreamUpdateServer // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// wantVec *payload.Object_Vector -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, *payload.Object_Vector, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotVec *payload.Object_Vector, 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) -// } // return nil // } // tests := []test{ @@ -5367,8 +5466,7 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // { // name: "test_case_1", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -5378,7 +5476,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5397,8 +5496,7 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// req:nil, +// stream:nil, // }, // fields: fields { // eg:nil, @@ -5408,7 +5506,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5439,55 +5538,61 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// gotVec, err := s.GetObject(test.args.ctx, test.args.req) -// if err := checkFunc(test.want, gotVec, err); err != nil { +// err := s.StreamUpdate(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_server_StreamGetObject(t *testing.T) { -// t.Parallel() +// func Test_server_MultiUpdate(t *testing.T) { // type args struct { -// stream vald.Object_StreamGetObjectServer +// ctx context.Context +// reqs *payload.Update_MultiRequest // } // type fields struct { -// eg errgroup.Group -// gateway service.Gateway -// mirror service.Mirror -// vAddr string -// streamConcurrency int -// name string -// ip string -// UnimplementedValdServerWithMirror vald.UnimplementedValdServerWithMirror +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer // } // type want struct { -// err error +// wantRes *payload.Object_Locations +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, *payload.Object_Locations, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, 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 // } // tests := []test{ @@ -5496,7 +5601,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // { // name: "test_case_1", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -5506,7 +5612,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5525,7 +5632,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // return test { // name: "test_case_2", // args: args { -// stream:nil, +// ctx:nil, +// reqs:nil, // }, // fields: fields { // eg:nil, @@ -5535,7 +5643,8 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // streamConcurrency:0, // name:"", // ip:"", -// UnimplementedValdServerWithMirror:nil, +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -5566,18 +5675,2187 @@ func Test_server_RemoveByTimestamp(t *testing.T) { // checkFunc = defaultCheckFunc // } // s := &server{ -// eg: test.fields.eg, -// gateway: test.fields.gateway, -// mirror: test.fields.mirror, -// vAddr: test.fields.vAddr, -// streamConcurrency: test.fields.streamConcurrency, -// name: test.fields.name, -// ip: test.fields.ip, -// UnimplementedValdServerWithMirror: test.fields.UnimplementedValdServerWithMirror, +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, // } // -// err := s.StreamGetObject(test.args.stream) -// if err := checkFunc(test.want, err); err != nil { +// gotRes, err := s.MultiUpdate(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_handleUpsert(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Upsert_Request +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// wantLoc *payload.Object_Location +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotLoc, err := s.handleUpsert(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotLoc, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_doUpsert(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Upsert_Request +// f func(ctx context.Context) (*payload.Object_Location, error) +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// wantLoc *payload.Object_Location +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// f:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// req:nil, +// f:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotLoc, err := s.doUpsert(test.args.ctx, test.args.req, test.args.f) +// if err := checkFunc(test.want, gotLoc, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamUpsert(t *testing.T) { +// type args struct { +// stream vald.Upsert_StreamUpsertServer +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// err := s.StreamUpsert(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiUpsert(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Upsert_MultiRequest +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// wantRes *payload.Object_Locations +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotRes, err := s.MultiUpsert(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_handleRemove(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Remove_Request +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// wantLoc *payload.Object_Location +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotLoc, err := s.handleRemove(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotLoc, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_doRemove(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Remove_Request +// f func(ctx context.Context) (*payload.Object_Location, error) +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// wantLoc *payload.Object_Location +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Location, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLoc *payload.Object_Location, 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(gotLoc, w.wantLoc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoc, w.wantLoc) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// f:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// req:nil, +// f:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotLoc, err := s.doRemove(test.args.ctx, test.args.req, test.args.f) +// if err := checkFunc(test.want, gotLoc, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamRemove(t *testing.T) { +// type args struct { +// stream vald.Remove_StreamRemoveServer +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// err := s.StreamRemove(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_MultiRemove(t *testing.T) { +// type args struct { +// ctx context.Context +// reqs *payload.Remove_MultiRequest +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// wantRes *payload.Object_Locations +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Object_Locations, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// reqs:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotRes, err := s.MultiRemove(test.args.ctx, test.args.reqs) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_handleRemoveByTimestamp(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Remove_TimestampRequest +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// wantLocs *payload.Object_Locations +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, 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(gotLocs, w.wantLocs) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotLocs, err := s.handleRemoveByTimestamp(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotLocs, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_doRemoveByTimestamp(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Remove_TimestampRequest +// f func(ctx context.Context) (*payload.Object_Locations, error) +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// wantLocs *payload.Object_Locations +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Locations, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotLocs *payload.Object_Locations, 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(gotLocs, w.wantLocs) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLocs, w.wantLocs) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// f:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// req:nil, +// f:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotLocs, err := s.doRemoveByTimestamp(test.args.ctx, test.args.req, test.args.f) +// if err := checkFunc(test.want, gotLocs, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_GetObject(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Object_VectorRequest +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// wantVec *payload.Object_Vector +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Object_Vector, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotVec *payload.Object_Vector, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// gotVec, err := s.GetObject(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, gotVec, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamGetObject(t *testing.T) { +// type args struct { +// stream vald.Object_StreamGetObjectServer +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// 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 { +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// err := s.StreamGetObject(test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_StreamListObject(t *testing.T) { +// type args struct { +// req *payload.Object_List_Request +// stream vald.Object_StreamListObjectServer +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// 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 { +// req:nil, +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// req:nil, +// stream:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// err := s.StreamListObject(test.args.req, test.args.stream) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_doStreamListObject(t *testing.T) { +// type args struct { +// ctx context.Context +// client vald.Object_StreamListObjectClient +// server vald.Object_StreamListObjectServer +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// 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 { +// ctx:nil, +// client:nil, +// server:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// client:nil, +// server:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// err := s.doStreamListObject(test.args.ctx, test.args.client, test.args.server) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_Flush(t *testing.T) { +// type args struct { +// ctx context.Context +// req *payload.Flush_Request +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// want *payload.Info_Index_Count +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Count, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got *payload.Info_Index_Count, 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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// got, err := s.Flush(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_isProxied(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// gateway service.Gateway +// mirror service.Mirror +// vAddr string +// streamConcurrency int +// name string +// ip string +// UnimplementedValdServer vald.UnimplementedValdServer +// UnimplementedMirrorServer mirror.UnimplementedMirrorServer +// } +// type want struct { +// want bool +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, bool) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// gateway:nil, +// mirror:nil, +// vAddr:"", +// streamConcurrency:0, +// name:"", +// ip:"", +// UnimplementedValdServer:nil, +// UnimplementedMirrorServer: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 +// } +// s := &server{ +// eg: test.fields.eg, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// vAddr: test.fields.vAddr, +// streamConcurrency: test.fields.streamConcurrency, +// name: test.fields.name, +// ip: test.fields.ip, +// UnimplementedValdServer: test.fields.UnimplementedValdServer, +// UnimplementedMirrorServer: test.fields.UnimplementedMirrorServer, +// } +// +// got := s.isProxied(test.args.ctx) +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } // }) diff --git a/pkg/gateway/mirror/handler/grpc/mock_test.go b/pkg/gateway/mirror/handler/grpc/mock_test.go index 59ab5564a4..cc14471d7f 100644 --- a/pkg/gateway/mirror/handler/grpc/mock_test.go +++ b/pkg/gateway/mirror/handler/grpc/mock_test.go @@ -40,13 +40,16 @@ func (gm *gatewayMock) FromForwardedContext(ctx context.Context) string { return gm.FromForwardedContextFunc(ctx) } -func (gm *gatewayMock) BroadCast(ctx context.Context, +func (gm *gatewayMock) BroadCast( + ctx context.Context, f func(ctx context.Context, target string, vc service.MirrorClient, copts ...grpc.CallOption) error, ) error { return gm.BroadCastFunc(ctx, f) } -func (gm *gatewayMock) DoMulti(ctx context.Context, targets []string, +func (gm *gatewayMock) DoMulti( + ctx context.Context, + targets []string, f func(ctx context.Context, target string, vc service.MirrorClient, copts ...grpc.CallOption) error, ) error { return gm.DoMultiFunc(ctx, targets, f) diff --git a/pkg/gateway/mirror/handler/grpc/option_test.go b/pkg/gateway/mirror/handler/grpc/option_test.go new file mode 100644 index 0000000000..f9e4698975 --- /dev/null +++ b/pkg/gateway/mirror/handler/grpc/option_test.go @@ -0,0 +1,611 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func TestWithIP(t *testing.T) { +// type args struct { +// ip 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 { +// ip:"", +// }, +// 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 { +// ip:"", +// }, +// 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 := WithIP(test.args.ip) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithName(t *testing.T) { +// type args struct { +// name 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 { +// name:"", +// }, +// 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 { +// name:"", +// }, +// 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 := WithName(test.args.name) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithGateway(t *testing.T) { +// type args struct { +// g service.Gateway +// } +// 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 { +// g: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 { +// g: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 := WithGateway(test.args.g) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithMirror(t *testing.T) { +// type args struct { +// m service.Mirror +// } +// 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 { +// m: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 { +// m: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 := WithMirror(test.args.m) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithStreamConcurrency(t *testing.T) { +// type args struct { +// c 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 { +// c: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 { +// c: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 := WithStreamConcurrency(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithValdAddr(t *testing.T) { +// type args struct { +// addr 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 { +// addr:"", +// }, +// 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:"", +// }, +// 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 := WithValdAddr(test.args.addr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/handler/rest/handler.go b/pkg/gateway/mirror/handler/rest/handler.go index 105cd3ec6f..777938a4ee 100644 --- a/pkg/gateway/mirror/handler/rest/handler.go +++ b/pkg/gateway/mirror/handler/rest/handler.go @@ -67,7 +67,7 @@ func New(opts ...Option) Handler { // The response is written to the http.ResponseWriter. func (h *handler) Register(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Mirror_Targets - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Register(r.Context(), req) }) } @@ -76,8 +76,8 @@ func (h *handler) Register(w http.ResponseWriter, r *http.Request) (code int, er // It returns an HTTP status code and an error. It creates a map to store data, // then uses json.Handler to process the request, extract data, and log the request using dump.Request. func (*handler) Index(w http.ResponseWriter, r *http.Request) (int, error) { - data := make(map[string]interface{}) - return json.Handler(w, r, &data, func() (interface{}, error) { + data := make(map[string]any) + return json.Handler(w, r, &data, func() (any, error) { return dump.Request(nil, data, r) }) } @@ -87,7 +87,7 @@ func (*handler) Index(w http.ResponseWriter, r *http.Request) (int, error) { // then invokes the vald.Search method to handle the search logic. func (h *handler) Search(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Search(r.Context(), req) }) } @@ -97,7 +97,7 @@ func (h *handler) Search(w http.ResponseWriter, r *http.Request) (code int, err // then invokes the vald.SearchByID method to handle the search by ID logic. func (h *handler) SearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.SearchByID(r.Context(), req) }) } @@ -107,7 +107,7 @@ func (h *handler) SearchByID(w http.ResponseWriter, r *http.Request) (code int, // then invokes the vald.MultiSearch method to handle the multi-search logic. func (h *handler) MultiSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiSearch(r.Context(), req) }) } @@ -117,7 +117,7 @@ func (h *handler) MultiSearch(w http.ResponseWriter, r *http.Request) (code int, // then invokes the vald.MultiSearchByID method to handle the multi-search by ID logic. func (h *handler) MultiSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiIDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiSearchByID(r.Context(), req) }) } @@ -127,7 +127,7 @@ func (h *handler) MultiSearchByID(w http.ResponseWriter, r *http.Request) (code // then invokes the vald.LinearSearch method to handle the linear search logic. func (h *handler) LinearSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.LinearSearch(r.Context(), req) }) } @@ -137,7 +137,7 @@ func (h *handler) LinearSearch(w http.ResponseWriter, r *http.Request) (code int // then invokes the vald.LinearSearchByID method to handle the linear search by ID logic. func (h *handler) LinearSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_IDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.LinearSearchByID(r.Context(), req) }) } @@ -147,7 +147,7 @@ func (h *handler) LinearSearchByID(w http.ResponseWriter, r *http.Request) (code // then invokes the vald.MultiLinearSearch method to handle the multi-linear search logic. func (h *handler) MultiLinearSearch(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Search_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiLinearSearch(r.Context(), req) }) } @@ -155,9 +155,11 @@ func (h *handler) MultiLinearSearch(w http.ResponseWriter, r *http.Request) (cod // MultiLinearSearchByID is an HTTP handler function that processes multi-linear search by ID requests. // It decodes the incoming JSON payload into a payload.Search_MultiIDRequest struct, // then invokes the vald.MultiLinearSearchByID method to handle the multi-linear search by ID logic. -func (h *handler) MultiLinearSearchByID(w http.ResponseWriter, r *http.Request) (code int, err error) { +func (h *handler) MultiLinearSearchByID( + w http.ResponseWriter, r *http.Request, +) (code int, err error) { var req *payload.Search_MultiIDRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiLinearSearchByID(r.Context(), req) }) } @@ -167,7 +169,7 @@ func (h *handler) MultiLinearSearchByID(w http.ResponseWriter, r *http.Request) // then invokes the vald.Insert method to handle the insert logic. func (h *handler) Insert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Insert(r.Context(), req) }) } @@ -177,7 +179,7 @@ func (h *handler) Insert(w http.ResponseWriter, r *http.Request) (code int, err // then invokes the vald.MultiInsert method to handle the multi-insert logic. func (h *handler) MultiInsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Insert_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiInsert(r.Context(), req) }) } @@ -187,7 +189,7 @@ func (h *handler) MultiInsert(w http.ResponseWriter, r *http.Request) (code int, // then invokes the vald.Update method to handle the update logic. func (h *handler) Update(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Update(r.Context(), req) }) } @@ -197,7 +199,7 @@ func (h *handler) Update(w http.ResponseWriter, r *http.Request) (code int, err // then invokes the vald.MultiUpdate method to handle the multi-update logic. func (h *handler) MultiUpdate(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Update_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiUpdate(r.Context(), req) }) } @@ -207,7 +209,7 @@ func (h *handler) MultiUpdate(w http.ResponseWriter, r *http.Request) (code int, // then invokes the vald.Upsert method to handle the upsert logic. func (h *handler) Upsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Upsert_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Upsert(r.Context(), req) }) } @@ -217,7 +219,7 @@ func (h *handler) Upsert(w http.ResponseWriter, r *http.Request) (code int, err // then invokes the vald.MultiUpsert method to handle the multi-upsert logic. func (h *handler) MultiUpsert(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Upsert_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiUpsert(r.Context(), req) }) } @@ -227,7 +229,7 @@ func (h *handler) MultiUpsert(w http.ResponseWriter, r *http.Request) (code int, // then invokes the vald.Remove method to handle the remove logic. func (h *handler) Remove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_Request - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Remove(r.Context(), req) }) } @@ -237,7 +239,7 @@ func (h *handler) Remove(w http.ResponseWriter, r *http.Request) (code int, err // then invokes the vald.RemoveByTimestamp method to handle the remove-by-timestamp logic. func (h *handler) RemoveByTimestamp(w http.ResponseWriter, r *http.Request) (int, error) { var req *payload.Remove_TimestampRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.RemoveByTimestamp(r.Context(), req) }) } @@ -247,7 +249,7 @@ func (h *handler) RemoveByTimestamp(w http.ResponseWriter, r *http.Request) (int // then invokes the vald.MultiRemove method to handle the multi-remove logic. func (h *handler) MultiRemove(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Remove_MultiRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.MultiRemove(r.Context(), req) }) } @@ -257,7 +259,7 @@ func (h *handler) MultiRemove(w http.ResponseWriter, r *http.Request) (code int, // then invokes the vald.GetObject method to handle the get-object logic. func (h *handler) GetObject(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_VectorRequest - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.GetObject(r.Context(), req) }) } @@ -267,7 +269,7 @@ func (h *handler) GetObject(w http.ResponseWriter, r *http.Request) (code int, e // then invokes the vald.Exists method to handle the exists logic. func (h *handler) Exists(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Object_ID - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.vald.Exists(r.Context(), req) }) } diff --git a/pkg/gateway/mirror/handler/rest/handler_test.go b/pkg/gateway/mirror/handler/rest/handler_test.go new file mode 100644 index 0000000000..fde26792e2 --- /dev/null +++ b/pkg/gateway/mirror/handler/rest/handler_test.go @@ -0,0 +1,2306 @@ +// 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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Register(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Register(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Index(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// want int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// got, err := h.Index(test.args.w, test.args.r) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Search(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Search(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_SearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.SearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.LinearSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_LinearSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.LinearSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiLinearSearch(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiLinearSearch(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiLinearSearchByID(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiLinearSearchByID(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Insert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Insert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiInsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiInsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Update(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Update(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpdate(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiUpdate(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Upsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Upsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiUpsert(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiUpsert(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Remove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Remove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_RemoveByTimestamp(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// want int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// got, err := h.RemoveByTimestamp(test.args.w, test.args.r) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_MultiRemove(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.MultiRemove(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_GetObject(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.GetObject(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Exists(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// vald grpc.Server +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// vald: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 +// } +// h := &handler{ +// vald: test.fields.vald, +// } +// +// gotCode, err := h.Exists(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/handler/rest/option_test.go b/pkg/gateway/mirror/handler/rest/option_test.go new file mode 100644 index 0000000000..bb925a0d1d --- /dev/null +++ b/pkg/gateway/mirror/handler/rest/option_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestWithVald(t *testing.T) { +// type args struct { +// v grpc.Server +// } +// 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 { +// v: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 { +// v: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 := WithVald(test.args.v) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/router/option.go b/pkg/gateway/mirror/router/option.go index 7b3e7d1782..ce38a5e3b3 100644 --- a/pkg/gateway/mirror/router/option.go +++ b/pkg/gateway/mirror/router/option.go @@ -13,9 +13,7 @@ // limitations under the License. package router -import ( - "github.com/vdaas/vald/pkg/gateway/mirror/handler/rest" -) +import "github.com/vdaas/vald/pkg/gateway/mirror/handler/rest" type Option func(*router) diff --git a/pkg/gateway/mirror/router/option_test.go b/pkg/gateway/mirror/router/option_test.go new file mode 100644 index 0000000000..c39d90a7bc --- /dev/null +++ b/pkg/gateway/mirror/router/option_test.go @@ -0,0 +1,186 @@ +// 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 router + +// NOT IMPLEMENTED BELOW +// +// func TestWithHandler(t *testing.T) { +// type args struct { +// h rest.Handler +// } +// 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 { +// h: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 { +// h: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 := WithHandler(test.args.h) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTimeout(t *testing.T) { +// type args struct { +// timeout 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 { +// timeout:"", +// }, +// 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 { +// timeout:"", +// }, +// 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 := WithTimeout(test.args.timeout) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/router/router_test.go b/pkg/gateway/mirror/router/router_test.go new file mode 100644 index 0000000000..e9e3069588 --- /dev/null +++ b/pkg/gateway/mirror/router/router_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 router + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want http.Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, http.Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got http.Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/service/discovery.go b/pkg/gateway/mirror/service/discovery.go index c5e41ad8fe..43c2929d30 100644 --- a/pkg/gateway/mirror/service/discovery.go +++ b/pkg/gateway/mirror/service/discovery.go @@ -171,7 +171,9 @@ type deletedTarget struct { port uint32 } -func (d *discovery) startSync(ctx context.Context, prev map[string]target.Target) (current map[string]target.Target, errs error) { +func (d *discovery) startSync( + ctx context.Context, prev map[string]target.Target, +) (current map[string]target.Target, errs error) { current = d.loadTargets() curAddrs := map[string]string{} // map[addr: metadata.name] @@ -222,7 +224,9 @@ func (d *discovery) startSync(ctx context.Context, prev map[string]target.Target return current, d.syncWithAddr(ctx, current, curAddrs) } -func (d *discovery) syncWithAddr(ctx context.Context, current map[string]target.Target, curAddrs map[string]string) (errs error) { +func (d *discovery) syncWithAddr( + ctx context.Context, current map[string]target.Target, curAddrs map[string]string, +) (errs error) { for addr, name := range curAddrs { // When the status code of a regularly running Register RPC is Unimplemented, the connection to the target will be disconnected // so the status of the resource (CR) may be misaligned. To prevent this, change the status of the resource to Disconnected. @@ -276,7 +280,9 @@ func (d *discovery) connectTarget(ctx context.Context, req map[string]*createdTa return errs } -func (d *discovery) createMirrorTargetResource(ctx context.Context, name, host string, port int) error { +func (d *discovery) createMirrorTargetResource( + ctx context.Context, name, host string, port int, +) error { mt, err := target.NewMirrorTargetTemplate( target.WithMirrorTargetName(name), target.WithMirrorTargetNamespace(d.namespace), @@ -294,7 +300,9 @@ func (d *discovery) createMirrorTargetResource(ctx context.Context, name, host s return d.ctrl.GetManager().GetClient().Create(ctx, mt) } -func (d *discovery) disconnectTarget(ctx context.Context, req map[string]*deletedTarget) (errs error) { +func (d *discovery) disconnectTarget( + ctx context.Context, req map[string]*deletedTarget, +) (errs error) { for _, deleted := range req { phase := target.MirrorTargetPhaseDisconnected err := d.mirr.Disconnect(ctx, &payload.Mirror_Target{ @@ -310,7 +318,9 @@ func (d *discovery) disconnectTarget(ctx context.Context, req map[string]*delete return errs } -func (d *discovery) updateMirrorTargetPhase(ctx context.Context, name string, phase target.MirrorTargetPhase) error { +func (d *discovery) updateMirrorTargetPhase( + ctx context.Context, name string, phase target.MirrorTargetPhase, +) error { c := d.ctrl.GetManager().GetClient() mt := &target.MirrorTarget{} err := c.Get(ctx, k8s.ObjectKey{ diff --git a/pkg/gateway/mirror/service/discovery_option_test.go b/pkg/gateway/mirror/service/discovery_option_test.go new file mode 100644 index 0000000000..5dc9a78ddf --- /dev/null +++ b/pkg/gateway/mirror/service/discovery_option_test.go @@ -0,0 +1,781 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func TestWithDiscoveryMirror(t *testing.T) { +// type args struct { +// m Mirror +// } +// type want struct { +// want DiscoveryOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, DiscoveryOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got DiscoveryOption) 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 { +// m: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 { +// m: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 := WithDiscoveryMirror(test.args.m) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDiscoveryDialer(t *testing.T) { +// type args struct { +// der net.Dialer +// } +// type want struct { +// want DiscoveryOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, DiscoveryOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got DiscoveryOption) 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 { +// der: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 { +// der: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 := WithDiscoveryDialer(test.args.der) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDiscoveryNamespace(t *testing.T) { +// type args struct { +// ns string +// } +// type want struct { +// want DiscoveryOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, DiscoveryOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got DiscoveryOption) 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 { +// ns:"", +// }, +// 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 { +// ns:"", +// }, +// 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 := WithDiscoveryNamespace(test.args.ns) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDiscoveryGroup(t *testing.T) { +// type args struct { +// g string +// } +// type want struct { +// want DiscoveryOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, DiscoveryOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got DiscoveryOption) 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 { +// g:"", +// }, +// 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 { +// g:"", +// }, +// 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 := WithDiscoveryGroup(test.args.g) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDiscoveryColocation(t *testing.T) { +// type args struct { +// loc string +// } +// type want struct { +// want DiscoveryOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, DiscoveryOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got DiscoveryOption) 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 { +// loc:"", +// }, +// 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 { +// loc:"", +// }, +// 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 := WithDiscoveryColocation(test.args.loc) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDiscoveryDuration(t *testing.T) { +// type args struct { +// s string +// } +// type want struct { +// want DiscoveryOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, DiscoveryOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got DiscoveryOption) 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 { +// s:"", +// }, +// 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 { +// s:"", +// }, +// 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 := WithDiscoveryDuration(test.args.s) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDiscoveryErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// type want struct { +// want DiscoveryOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, DiscoveryOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got DiscoveryOption) 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 { +// eg: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 { +// eg: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 := WithDiscoveryErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDiscoverySelfMirrorAddrs(t *testing.T) { +// type args struct { +// addrs []string +// } +// type want struct { +// want DiscoveryOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, DiscoveryOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got DiscoveryOption) 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 { +// addrs: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 { +// addrs: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 := WithDiscoverySelfMirrorAddrs(test.args.addrs...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDiscoveryController(t *testing.T) { +// type args struct { +// ctrl k8s.Controller +// } +// type want struct { +// want DiscoveryOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, DiscoveryOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got DiscoveryOption) 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 { +// ctrl: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 { +// ctrl: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 := WithDiscoveryController(test.args.ctrl) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/service/discovery_test.go b/pkg/gateway/mirror/service/discovery_test.go index cc4665bbe7..f2242c2ce2 100644 --- a/pkg/gateway/mirror/service/discovery_test.go +++ b/pkg/gateway/mirror/service/discovery_test.go @@ -572,8 +572,1296 @@ func Test_discovery_syncWithAddr(t *testing.T) { // if err := checkFunc(test.want, gotDsc, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_discovery_onReconcile(t *testing.T) { +// type args struct { +// in0 context.Context +// list map[string]target.Target +// } +// type fields struct { +// namespace string +// labels map[string]string +// colocation string +// der net.Dialer +// targetsByName atomic.Pointer[map[string]target.Target] +// ctrl k8s.Controller +// dur time.Duration +// selfMirrAddrs []string +// selfMirrAddrStr string +// mirr Mirror +// eg errgroup.Group +// } +// 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 { +// in0:nil, +// list:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 { +// in0:nil, +// list:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 +// } +// d := &discovery{ +// namespace: test.fields.namespace, +// labels: test.fields.labels, +// colocation: test.fields.colocation, +// der: test.fields.der, +// targetsByName: test.fields.targetsByName, +// ctrl: test.fields.ctrl, +// dur: test.fields.dur, +// selfMirrAddrs: test.fields.selfMirrAddrs, +// selfMirrAddrStr: test.fields.selfMirrAddrStr, +// mirr: test.fields.mirr, +// eg: test.fields.eg, +// } +// +// d.onReconcile(test.args.in0, test.args.list) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_discovery_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// namespace string +// labels map[string]string +// colocation string +// der net.Dialer +// targetsByName atomic.Pointer[map[string]target.Target] +// ctrl k8s.Controller +// dur time.Duration +// selfMirrAddrs []string +// selfMirrAddrStr string +// mirr Mirror +// eg errgroup.Group +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 { +// ctx:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 +// } +// d := &discovery{ +// namespace: test.fields.namespace, +// labels: test.fields.labels, +// colocation: test.fields.colocation, +// der: test.fields.der, +// targetsByName: test.fields.targetsByName, +// ctrl: test.fields.ctrl, +// dur: test.fields.dur, +// selfMirrAddrs: test.fields.selfMirrAddrs, +// selfMirrAddrStr: test.fields.selfMirrAddrStr, +// mirr: test.fields.mirr, +// eg: test.fields.eg, +// } +// +// got, err := d.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_discovery_loadTargets(t *testing.T) { +// type fields struct { +// namespace string +// labels map[string]string +// colocation string +// der net.Dialer +// targetsByName atomic.Pointer[map[string]target.Target] +// ctrl k8s.Controller +// dur time.Duration +// selfMirrAddrs []string +// selfMirrAddrStr string +// mirr Mirror +// eg errgroup.Group +// } +// type want struct { +// want map[string]target.Target +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, map[string]target.Target) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got map[string]target.Target) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 := &discovery{ +// namespace: test.fields.namespace, +// labels: test.fields.labels, +// colocation: test.fields.colocation, +// der: test.fields.der, +// targetsByName: test.fields.targetsByName, +// ctrl: test.fields.ctrl, +// dur: test.fields.dur, +// selfMirrAddrs: test.fields.selfMirrAddrs, +// selfMirrAddrStr: test.fields.selfMirrAddrStr, +// mirr: test.fields.mirr, +// eg: test.fields.eg, +// } +// +// got := d.loadTargets() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_discovery_connectTarget(t *testing.T) { +// type args struct { +// ctx context.Context +// req map[string]*createdTarget +// } +// type fields struct { +// namespace string +// labels map[string]string +// colocation string +// der net.Dialer +// targetsByName atomic.Pointer[map[string]target.Target] +// ctrl k8s.Controller +// dur time.Duration +// selfMirrAddrs []string +// selfMirrAddrStr string +// mirr Mirror +// eg errgroup.Group +// } +// 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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 +// } +// d := &discovery{ +// namespace: test.fields.namespace, +// labels: test.fields.labels, +// colocation: test.fields.colocation, +// der: test.fields.der, +// targetsByName: test.fields.targetsByName, +// ctrl: test.fields.ctrl, +// dur: test.fields.dur, +// selfMirrAddrs: test.fields.selfMirrAddrs, +// selfMirrAddrStr: test.fields.selfMirrAddrStr, +// mirr: test.fields.mirr, +// eg: test.fields.eg, +// } +// +// err := d.connectTarget(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_discovery_createMirrorTargetResource(t *testing.T) { +// type args struct { +// ctx context.Context +// name string +// host string +// port int +// } +// type fields struct { +// namespace string +// labels map[string]string +// colocation string +// der net.Dialer +// targetsByName atomic.Pointer[map[string]target.Target] +// ctrl k8s.Controller +// dur time.Duration +// selfMirrAddrs []string +// selfMirrAddrStr string +// mirr Mirror +// eg errgroup.Group +// } +// 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 { +// ctx:nil, +// name:"", +// host:"", +// port:0, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 { +// ctx:nil, +// name:"", +// host:"", +// port:0, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 +// } +// d := &discovery{ +// namespace: test.fields.namespace, +// labels: test.fields.labels, +// colocation: test.fields.colocation, +// der: test.fields.der, +// targetsByName: test.fields.targetsByName, +// ctrl: test.fields.ctrl, +// dur: test.fields.dur, +// selfMirrAddrs: test.fields.selfMirrAddrs, +// selfMirrAddrStr: test.fields.selfMirrAddrStr, +// mirr: test.fields.mirr, +// eg: test.fields.eg, +// } +// +// err := d.createMirrorTargetResource(test.args.ctx, test.args.name, test.args.host, test.args.port) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_discovery_disconnectTarget(t *testing.T) { +// type args struct { +// ctx context.Context +// req map[string]*deletedTarget +// } +// type fields struct { +// namespace string +// labels map[string]string +// colocation string +// der net.Dialer +// targetsByName atomic.Pointer[map[string]target.Target] +// ctrl k8s.Controller +// dur time.Duration +// selfMirrAddrs []string +// selfMirrAddrStr string +// mirr Mirror +// eg errgroup.Group +// } +// 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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 +// } +// d := &discovery{ +// namespace: test.fields.namespace, +// labels: test.fields.labels, +// colocation: test.fields.colocation, +// der: test.fields.der, +// targetsByName: test.fields.targetsByName, +// ctrl: test.fields.ctrl, +// dur: test.fields.dur, +// selfMirrAddrs: test.fields.selfMirrAddrs, +// selfMirrAddrStr: test.fields.selfMirrAddrStr, +// mirr: test.fields.mirr, +// eg: test.fields.eg, +// } +// +// err := d.disconnectTarget(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_discovery_updateMirrorTargetPhase(t *testing.T) { +// type args struct { +// ctx context.Context +// name string +// phase target.MirrorTargetPhase +// } +// type fields struct { +// namespace string +// labels map[string]string +// colocation string +// der net.Dialer +// targetsByName atomic.Pointer[map[string]target.Target] +// ctrl k8s.Controller +// dur time.Duration +// selfMirrAddrs []string +// selfMirrAddrStr string +// mirr Mirror +// eg errgroup.Group +// } +// 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 { +// ctx:nil, +// name:"", +// phase:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 { +// ctx:nil, +// name:"", +// phase:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 +// } +// d := &discovery{ +// namespace: test.fields.namespace, +// labels: test.fields.labels, +// colocation: test.fields.colocation, +// der: test.fields.der, +// targetsByName: test.fields.targetsByName, +// ctrl: test.fields.ctrl, +// dur: test.fields.dur, +// selfMirrAddrs: test.fields.selfMirrAddrs, +// selfMirrAddrStr: test.fields.selfMirrAddrStr, +// mirr: test.fields.mirr, +// eg: test.fields.eg, +// } +// +// err := d.updateMirrorTargetPhase(test.args.ctx, test.args.name, test.args.phase) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_discovery_updateTarget(t *testing.T) { +// type args struct { +// ctx context.Context +// req map[string]*updatedTarget +// } +// type fields struct { +// namespace string +// labels map[string]string +// colocation string +// der net.Dialer +// targetsByName atomic.Pointer[map[string]target.Target] +// ctrl k8s.Controller +// dur time.Duration +// selfMirrAddrs []string +// selfMirrAddrStr string +// mirr Mirror +// eg errgroup.Group +// } +// 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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 { +// ctx:nil, +// req:nil, +// }, +// fields: fields { +// namespace:"", +// labels:nil, +// colocation:"", +// der:nil, +// targetsByName:nil, +// ctrl:nil, +// dur:nil, +// selfMirrAddrs:nil, +// selfMirrAddrStr:"", +// mirr:nil, +// eg: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 +// } +// d := &discovery{ +// namespace: test.fields.namespace, +// labels: test.fields.labels, +// colocation: test.fields.colocation, +// der: test.fields.der, +// targetsByName: test.fields.targetsByName, +// ctrl: test.fields.ctrl, +// dur: test.fields.dur, +// selfMirrAddrs: test.fields.selfMirrAddrs, +// selfMirrAddrStr: test.fields.selfMirrAddrStr, +// mirr: test.fields.mirr, +// eg: test.fields.eg, +// } +// +// err := d.updateTarget(test.args.ctx, test.args.req) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_isConnectedPhase(t *testing.T) { +// type args struct { +// phase target.MirrorTargetPhase +// } +// type want struct { +// want bool +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, bool) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// phase: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 { +// phase: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 := isConnectedPhase(test.args.phase) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } // +// func Test_isDisconnectedPhase(t *testing.T) { +// type args struct { +// phase target.MirrorTargetPhase +// } +// type want struct { +// want bool +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, bool) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// phase: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 { +// phase: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 := isDisconnectedPhase(test.args.phase) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/service/gateway.go b/pkg/gateway/mirror/service/gateway.go index d2a8b9dbd8..674f7b93aa 100644 --- a/pkg/gateway/mirror/service/gateway.go +++ b/pkg/gateway/mirror/service/gateway.go @@ -37,7 +37,7 @@ type Gateway interface { BroadCast(ctx context.Context, f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) error) error Do(ctx context.Context, target string, - f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) (interface{}, error)) (interface{}, error) + f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) (any, error)) (any, error) DoMulti(ctx context.Context, targets []string, f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) error) error GRPCClient() grpc.Client @@ -103,7 +103,8 @@ func (*gateway) FromForwardedContext(ctx context.Context) string { // BroadCast performs a broadcast operation using the provided function // to interact with gRPC clients for multiple targets. // The provided function should handle the communication logic for a target. -func (g *gateway) BroadCast(ctx context.Context, +func (g *gateway) BroadCast( + ctx context.Context, f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) error, ) (err error) { ctx, span := trace.StartSpan(ctx, "vald/gateway/mirror/service/Gateway.BroadCast") @@ -127,9 +128,11 @@ func (g *gateway) BroadCast(ctx context.Context, // Do performs a gRPC operation on a single target using the provided function. // It returns the result of the operation and any associated error. // The provided function should handle the communication logic for a target. -func (g *gateway) Do(ctx context.Context, target string, - f func(ctx context.Context, addr string, vc MirrorClient, copts ...grpc.CallOption) (interface{}, error), -) (res interface{}, err error) { +func (g *gateway) Do( + ctx context.Context, + target string, + f func(ctx context.Context, addr string, vc MirrorClient, copts ...grpc.CallOption) (any, error), +) (res any, err error) { ctx, span := trace.StartSpan(ctx, "vald/gateway/mirror/service/Gateway.Do") defer func() { if span != nil { @@ -141,7 +144,7 @@ func (g *gateway) Do(ctx context.Context, target string, return nil, errors.ErrTargetNotFound } return g.client.GRPCClient().Do(g.ForwardedContext(ctx, g.podName), target, - func(ictx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) { + func(ictx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (any, error) { return f(ictx, target, NewMirrorClient(conn), copts...) }, ) @@ -150,7 +153,9 @@ func (g *gateway) Do(ctx context.Context, target string, // DoMulti performs a gRPC operation on multiple targets using the provided function. // It returns an error if any of the operations fails. // The provided function should handle the communication logic for a target. -func (g *gateway) DoMulti(ctx context.Context, targets []string, +func (g *gateway) DoMulti( + ctx context.Context, + targets []string, f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) error, ) error { ctx, span := trace.StartSpan(ctx, "vald/gateway/mirror/service/Gateway.DoMulti") diff --git a/pkg/gateway/mirror/service/gateway_mock_test.go b/pkg/gateway/mirror/service/gateway_mock_test.go index baaed0ae4c..d0c8c924f9 100644 --- a/pkg/gateway/mirror/service/gateway_mock_test.go +++ b/pkg/gateway/mirror/service/gateway_mock_test.go @@ -27,7 +27,7 @@ type GatewayMock struct { BroadCastFunc func(ctx context.Context, f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) error) error DoFunc func(ctx context.Context, target string, - f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) (interface{}, error)) (interface{}, error) + f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) (any, error)) (any, error) DoMultiFunc func(ctx context.Context, targets []string, f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) error) error GRPCClientFunc func() grpc.Client @@ -44,21 +44,26 @@ func (gm *GatewayMock) FromForwardedContext(ctx context.Context) string { } // BroadCast calls BroadCastFunc object. -func (gm *GatewayMock) BroadCast(ctx context.Context, +func (gm *GatewayMock) BroadCast( + ctx context.Context, f func(_ context.Context, _ string, _ MirrorClient, _ ...grpc.CallOption) error, ) error { return gm.BroadCastFunc(ctx, f) } // Do calls DoFunc object. -func (gm *GatewayMock) Do(ctx context.Context, target string, - f func(_ context.Context, _ string, _ MirrorClient, _ ...grpc.CallOption) (interface{}, error), -) (interface{}, error) { +func (gm *GatewayMock) Do( + ctx context.Context, + target string, + f func(_ context.Context, _ string, _ MirrorClient, _ ...grpc.CallOption) (any, error), +) (any, error) { return gm.DoFunc(ctx, target, f) } // DoMulti calls DoMultiFunc object. -func (gm *GatewayMock) DoMulti(ctx context.Context, targets []string, +func (gm *GatewayMock) DoMulti( + ctx context.Context, + targets []string, f func(_ context.Context, _ string, _ MirrorClient, _ ...grpc.CallOption) error, ) error { return gm.DoMultiFunc(ctx, targets, f) diff --git a/pkg/gateway/mirror/service/gateway_test.go b/pkg/gateway/mirror/service/gateway_test.go new file mode 100644 index 0000000000..526132ecd0 --- /dev/null +++ b/pkg/gateway/mirror/service/gateway_test.go @@ -0,0 +1,753 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func TestNewGateway(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Gateway +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Gateway, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Gateway, 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 := NewGateway(test.args.opts...) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_gateway_GRPCClient(t *testing.T) { +// type fields struct { +// client mirror.Client +// eg errgroup.Group +// podName string +// } +// type want struct { +// want grpc.Client +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, grpc.Client) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got grpc.Client) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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 { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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 +// } +// g := &gateway{ +// client: test.fields.client, +// eg: test.fields.eg, +// podName: test.fields.podName, +// } +// +// got := g.GRPCClient() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_gateway_ForwardedContext(t *testing.T) { +// type args struct { +// ctx context.Context +// podName string +// } +// type fields struct { +// client mirror.Client +// eg errgroup.Group +// podName string +// } +// type want struct { +// want context.Context +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, context.Context) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got context.Context) 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 { +// ctx:nil, +// podName:"", +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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, +// podName:"", +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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 := &gateway{ +// client: test.fields.client, +// eg: test.fields.eg, +// podName: test.fields.podName, +// } +// +// got := g.ForwardedContext(test.args.ctx, test.args.podName) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_gateway_FromForwardedContext(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// client mirror.Client +// eg errgroup.Group +// podName string +// } +// type want struct { +// want string +// } +// type test struct { +// name string +// args args +// fields fields +// 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 { +// ctx:nil, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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 := &gateway{ +// client: test.fields.client, +// eg: test.fields.eg, +// podName: test.fields.podName, +// } +// +// got := g.FromForwardedContext(test.args.ctx) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_gateway_BroadCast(t *testing.T) { +// type args struct { +// ctx context.Context +// f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) error +// } +// type fields struct { +// client mirror.Client +// eg errgroup.Group +// podName string +// } +// 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 { +// ctx:nil, +// f:nil, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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, +// f:nil, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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 := &gateway{ +// client: test.fields.client, +// eg: test.fields.eg, +// podName: test.fields.podName, +// } +// +// err := g.BroadCast(test.args.ctx, test.args.f) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_gateway_Do(t *testing.T) { +// type args struct { +// ctx context.Context +// target string +// f func(ctx context.Context, addr string, vc MirrorClient, copts ...grpc.CallOption) (any, error) +// } +// type fields struct { +// client mirror.Client +// eg errgroup.Group +// podName string +// } +// type want struct { +// wantRes any +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, any, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes any, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// target:"", +// f:nil, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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, +// target:"", +// f:nil, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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 := &gateway{ +// client: test.fields.client, +// eg: test.fields.eg, +// podName: test.fields.podName, +// } +// +// gotRes, err := g.Do(test.args.ctx, test.args.target, test.args.f) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_gateway_DoMulti(t *testing.T) { +// type args struct { +// ctx context.Context +// targets []string +// f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) error +// } +// type fields struct { +// client mirror.Client +// eg errgroup.Group +// podName string +// } +// 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 { +// ctx:nil, +// targets:nil, +// f:nil, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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, +// targets:nil, +// f:nil, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// podName:"", +// }, +// 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 := &gateway{ +// client: test.fields.client, +// eg: test.fields.eg, +// podName: test.fields.podName, +// } +// +// err := g.DoMulti(test.args.ctx, test.args.targets, test.args.f) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/service/mirror.go b/pkg/gateway/mirror/service/mirror.go index c23eb8d510..b5ab31609b 100644 --- a/pkg/gateway/mirror/service/mirror.go +++ b/pkg/gateway/mirror/service/mirror.go @@ -168,7 +168,9 @@ func (m *mirr) Start(ctx context.Context) <-chan error { // skipcq: GO-R1005 return ech } -func (m *mirr) registers(ctx context.Context, tgts *payload.Mirror_Targets) ([]*payload.Mirror_Target, error) { // skipcq: GO-R1005 +func (m *mirr) registers( + ctx context.Context, tgts *payload.Mirror_Targets, +) ([]*payload.Mirror_Target, error) { // skipcq: GO-R1005 ctx, span := trace.StartSpan(grpc.WithGRPCMethod(ctx, vald.PackageName+"."+mirror.RPCServiceName+"/"+mirror.RegisterRPCName), "vald/gateway/mirror/service/Mirror.registers") defer func() { if span != nil { diff --git a/pkg/gateway/mirror/service/mirror_option_test.go b/pkg/gateway/mirror/service/mirror_option_test.go new file mode 100644 index 0000000000..2b84c32ee0 --- /dev/null +++ b/pkg/gateway/mirror/service/mirror_option_test.go @@ -0,0 +1,441 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func TestWithErrorGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// type want struct { +// want MirrorOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, MirrorOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got MirrorOption) 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 { +// eg: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 { +// eg: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 := WithErrorGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithGatewayAddrs(t *testing.T) { +// type args struct { +// addrs []string +// } +// type want struct { +// want MirrorOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, MirrorOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got MirrorOption) 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 { +// addrs: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 { +// addrs: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 := WithGatewayAddrs(test.args.addrs...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithSelfMirrorAddrs(t *testing.T) { +// type args struct { +// addrs []string +// } +// type want struct { +// want MirrorOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, MirrorOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got MirrorOption) 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 { +// addrs: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 { +// addrs: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 := WithSelfMirrorAddrs(test.args.addrs...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithGateway(t *testing.T) { +// type args struct { +// g Gateway +// } +// type want struct { +// want MirrorOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, MirrorOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got MirrorOption) 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 { +// g: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 { +// g: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 := WithGateway(test.args.g) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithRegisterDuration(t *testing.T) { +// type args struct { +// s string +// } +// type want struct { +// want MirrorOption +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, MirrorOption) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got MirrorOption) 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 { +// s:"", +// }, +// 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 { +// s:"", +// }, +// 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 := WithRegisterDuration(test.args.s) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/service/mirror_test.go b/pkg/gateway/mirror/service/mirror_test.go index 598a3b1841..d23f204fcd 100644 --- a/pkg/gateway/mirror/service/mirror_test.go +++ b/pkg/gateway/mirror/service/mirror_test.go @@ -555,6 +555,91 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // NOT IMPLEMENTED BELOW // +// func TestNewMirrorClient(t *testing.T) { +// type args struct { +// conn *grpc.ClientConn +// } +// type want struct { +// want MirrorClient +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, MirrorClient) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got MirrorClient) 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 { +// conn: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 { +// conn: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 := NewMirrorClient(test.args.conn) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func TestNewMirror(t *testing.T) { // type args struct { // opts []MirrorOption @@ -640,7 +725,6 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -763,15 +847,14 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_mirr_Disconnect(t *testing.T) { +// func Test_mirr_registers(t *testing.T) { // type args struct { -// ctx context.Context -// targets []*payload.Mirror_Target +// ctx context.Context +// tgts *payload.Mirror_Targets // } // type fields struct { // addrl sync.Map[string, any] @@ -783,21 +866,25 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // gateway Gateway // } // type want struct { -// err error +// want []*payload.Mirror_Target +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, []*payload.Mirror_Target, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, got []*payload.Mirror_Target, 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{ @@ -807,7 +894,7 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, -// targets:nil, +// tgts:nil, // }, // fields: fields { // addrl:nil, @@ -836,7 +923,7 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, -// targets:nil, +// tgts:nil, // }, // fields: fields { // addrl:nil, @@ -885,11 +972,10 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // gateway: test.fields.gateway, // } // -// err := m.Disconnect(test.args.ctx, test.args.targets...) -// if err := checkFunc(test.want, err); err != nil { +// got, err := m.registers(test.args.ctx, test.args.tgts) +// if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1015,14 +1101,135 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func Test_mirr_isSelfMirrorAddr(t *testing.T) { +// type args struct { +// addr string +// } +// type fields struct { +// addrl sync.Map[string, any] +// selfMirrTgts []*payload.Mirror_Target +// selfMirrAddrl sync.Map[string, any] +// gwAddrl sync.Map[string, any] +// eg errgroup.Group +// registerDur time.Duration +// gateway Gateway +// } +// type want struct { +// want bool +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, bool) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// addr:"", +// }, +// fields: fields { +// addrl:nil, +// selfMirrTgts:nil, +// selfMirrAddrl:nil, +// gwAddrl:nil, +// eg:nil, +// registerDur:nil, +// gateway: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:"", +// }, +// fields: fields { +// addrl:nil, +// selfMirrTgts:nil, +// selfMirrAddrl:nil, +// gwAddrl:nil, +// eg:nil, +// registerDur:nil, +// gateway: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 +// } +// m := &mirr{ +// addrl: test.fields.addrl, +// selfMirrTgts: test.fields.selfMirrTgts, +// selfMirrAddrl: test.fields.selfMirrAddrl, +// gwAddrl: test.fields.gwAddrl, +// eg: test.fields.eg, +// registerDur: test.fields.registerDur, +// gateway: test.fields.gateway, +// } +// +// got := m.isSelfMirrorAddr(test.args.addr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } // -// func Test_mirr_RangeAllMirrorAddr(t *testing.T) { +// func Test_mirr_isGatewayAddr(t *testing.T) { // type args struct { -// f func(addr string, _ any) bool +// addr string // } // type fields struct { // addrl sync.Map[string, any] @@ -1034,7 +1241,128 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // gateway Gateway // } // type want struct { +// want bool +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, bool) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// addr:"", +// }, +// fields: fields { +// addrl:nil, +// selfMirrTgts:nil, +// selfMirrAddrl:nil, +// gwAddrl:nil, +// eg:nil, +// registerDur:nil, +// gateway: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:"", +// }, +// fields: fields { +// addrl:nil, +// selfMirrTgts:nil, +// selfMirrAddrl:nil, +// gwAddrl:nil, +// eg:nil, +// registerDur:nil, +// gateway: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 +// } +// m := &mirr{ +// addrl: test.fields.addrl, +// selfMirrTgts: test.fields.selfMirrTgts, +// selfMirrAddrl: test.fields.selfMirrAddrl, +// gwAddrl: test.fields.gwAddrl, +// eg: test.fields.eg, +// registerDur: test.fields.registerDur, +// gateway: test.fields.gateway, +// } +// +// got := m.isGatewayAddr(test.args.addr) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_mirr_RangeMirrorAddr(t *testing.T) { +// type args struct { +// f func(addr string, _ any) bool +// } +// type fields struct { +// addrl sync.Map[string, any] +// selfMirrTgts []*payload.Mirror_Target +// selfMirrAddrl sync.Map[string, any] +// gwAddrl sync.Map[string, any] +// eg errgroup.Group +// registerDur time.Duration +// gateway Gateway // } +// type want struct{} // type test struct { // name string // args args @@ -1130,7 +1458,7 @@ func Test_mirr_connectedOtherMirrorAddrs(t *testing.T) { // gateway: test.fields.gateway, // } // -// m.RangeAllMirrorAddr(test.args.f) +// m.RangeMirrorAddr(test.args.f) // if err := checkFunc(test.want); err != nil { // tt.Errorf("error = %v", err) // } diff --git a/pkg/gateway/mirror/service/option_test.go b/pkg/gateway/mirror/service/option_test.go new file mode 100644 index 0000000000..b3e47b1491 --- /dev/null +++ b/pkg/gateway/mirror/service/option_test.go @@ -0,0 +1,271 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func TestWithMirrorClient(t *testing.T) { +// type args struct { +// c mirror.Client +// } +// 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 { +// 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 := WithMirrorClient(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithPodName(t *testing.T) { +// type args struct { +// s 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 { +// s:"", +// }, +// 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 { +// s:"", +// }, +// 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 := WithPodName(test.args.s) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/gateway/mirror/usecase/vald_test.go b/pkg/gateway/mirror/usecase/vald_test.go new file mode 100644 index 0000000000..9dcd59e136 --- /dev/null +++ b/pkg/gateway/mirror/usecase/vald_test.go @@ -0,0 +1,759 @@ +// 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 usecase + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// cfg *config.Data +// } +// type want struct { +// wantR runner.Runner +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, runner.Runner, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotR runner.Runner, 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(gotR, w.wantR) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotR, w.wantR) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// cfg: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 { +// cfg: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 +// } +// +// gotR, err := New(test.args.cfg) +// if err := checkFunc(test.want, gotR, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// dialer net.Dialer +// cfg *config.Data +// server starter.Server +// client client.Client +// gateway service.Gateway +// mirror service.Mirror +// discover service.Discovery +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// dialer: test.fields.dialer, +// cfg: test.fields.cfg, +// server: test.fields.server, +// client: test.fields.client, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// discover: test.fields.discover, +// observability: test.fields.observability, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// dialer net.Dialer +// cfg *config.Data +// server starter.Server +// client client.Client +// gateway service.Gateway +// mirror service.Mirror +// discover service.Discovery +// observability observability.Observability +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// dialer: test.fields.dialer, +// cfg: test.fields.cfg, +// server: test.fields.server, +// client: test.fields.client, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// discover: test.fields.discover, +// observability: test.fields.observability, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// dialer net.Dialer +// cfg *config.Data +// server starter.Server +// client client.Client +// gateway service.Gateway +// mirror service.Mirror +// discover service.Discovery +// observability observability.Observability +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// dialer: test.fields.dialer, +// cfg: test.fields.cfg, +// server: test.fields.server, +// client: test.fields.client, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// discover: test.fields.discover, +// observability: test.fields.observability, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// dialer net.Dialer +// cfg *config.Data +// server starter.Server +// client client.Client +// gateway service.Gateway +// mirror service.Mirror +// discover service.Discovery +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// dialer: test.fields.dialer, +// cfg: test.fields.cfg, +// server: test.fields.server, +// client: test.fields.client, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// discover: test.fields.discover, +// observability: test.fields.observability, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// dialer net.Dialer +// cfg *config.Data +// server starter.Server +// client client.Client +// gateway service.Gateway +// mirror service.Mirror +// discover service.Discovery +// observability observability.Observability +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// dialer:nil, +// cfg:nil, +// server:nil, +// client:nil, +// gateway:nil, +// mirror:nil, +// discover:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// dialer: test.fields.dialer, +// cfg: test.fields.cfg, +// server: test.fields.server, +// client: test.fields.client, +// gateway: test.fields.gateway, +// mirror: test.fields.mirror, +// discover: test.fields.discover, +// observability: test.fields.observability, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/index/job/correction/config/config_test.go b/pkg/index/job/correction/config/config_test.go index 231463a4a1..aed7f2d165 100644 --- a/pkg/index/job/correction/config/config_test.go +++ b/pkg/index/job/correction/config/config_test.go @@ -100,7 +100,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); 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 0ea917a8fb..073bf39e02 100644 --- a/pkg/index/job/correction/service/corrector.go +++ b/pkg/index/job/correction/service/corrector.go @@ -24,7 +24,6 @@ import ( "sync/atomic" "time" - agent "github.com/vdaas/vald/apis/grpc/v1/agent/core" "github.com/vdaas/vald/apis/grpc/v1/payload" "github.com/vdaas/vald/apis/grpc/v1/vald" "github.com/vdaas/vald/internal/client/v1/client/discoverer" @@ -306,7 +305,9 @@ type vectorReplica struct { } // Validate len(addrs) >= 2 before calling this function. -func (c *correct) checkConsistency(ctx context.Context, targetReplica *vectorReplica, targetAgentIdx int) error { +func (c *correct) checkConsistency( + ctx context.Context, targetReplica *vectorReplica, targetAgentIdx int, +) error { // leftAgentAddrs is the agents' addr that hasn't been corrected yet. leftAgentAddrs := c.sortedByIndexCntAddrs[targetAgentIdx+1:] @@ -321,7 +322,7 @@ func (c *correct) checkConsistency(ctx context.Context, targetReplica *vectorRep var mu sync.Mutex if err := c.discoverer.GetClient().OrderedRangeConcurrent(ctx, leftAgentAddrs, len(leftAgentAddrs), func(ctx context.Context, addr string, conn *grpc.ClientConn, copts ...grpc.CallOption) error { - vecMeta, err := agent.NewAgentClient(conn).GetTimestamp(ctx, &payload.Object_GetTimestampRequest{ + vecMeta, err := vald.NewValdClient(conn).GetTimestamp(ctx, &payload.Object_TimestampRequest{ Id: &payload.Object_ID{ Id: targetReplica.vec.GetId(), }, @@ -379,7 +380,9 @@ func (c *correct) checkConsistency(ctx context.Context, targetReplica *vectorRep return nil } -func (c *correct) correctTimestamp(ctx context.Context, targetReplica *vectorReplica, foundReplicas []*vectorReplica) error { +func (c *correct) correctTimestamp( + ctx context.Context, targetReplica *vectorReplica, foundReplicas []*vectorReplica, +) error { if len(foundReplicas) == 0 { // no replica found. nothing to do about timestamp return nil @@ -421,9 +424,7 @@ func (c *correct) correctTimestamp(ctx context.Context, targetReplica *vectorRep // correctReplica corrects the number of replicas of the target vector. // skipcq: GO-R1005 func (c *correct) correctReplica( - ctx context.Context, - targetReplica *vectorReplica, - foundReplicas []*vectorReplica, + ctx context.Context, targetReplica *vectorReplica, foundReplicas []*vectorReplica, ) error { // diff < 0 means there is less replica than the correct number existReplica := len(foundReplicas) + 1 @@ -514,7 +515,7 @@ func (c *correct) updateObject(ctx context.Context, dest, src *vectorReplica) er } res, err := c.discoverer.GetClient(). - Do(grpc.WithGRPCMethod(ctx, updateMethod), dest.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) { + Do(grpc.WithGRPCMethod(ctx, updateMethod), dest.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (any, error) { // TODO: use UpdateTimestamp when it's implemented because here we just want to update only the timestamp but not the vector return vald.NewUpdateClient(conn).Update(ctx, &payload.Update_Request{ Vector: src.vec, @@ -540,7 +541,7 @@ func (c *correct) updateObject(ctx context.Context, dest, src *vectorReplica) er func (c *correct) fillVectorField(ctx context.Context, replica *vectorReplica) error { res, err := c.discoverer.GetClient(). - Do(grpc.WithGRPCMethod(ctx, "core.v1.Vald/GetObject"), replica.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) { + Do(grpc.WithGRPCMethod(ctx, "core.v1.Vald/GetObject"), replica.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (any, error) { return vald.NewValdClient(conn).GetObject(ctx, &payload.Object_VectorRequest{ Id: &payload.Object_ID{ Id: replica.vec.GetId(), @@ -562,9 +563,11 @@ func (c *correct) fillVectorField(ctx context.Context, replica *vectorReplica) e return nil } -func (c *correct) insertObject(ctx context.Context, addr string, vector *payload.Object_Vector) error { +func (c *correct) insertObject( + ctx context.Context, addr string, vector *payload.Object_Vector, +) error { res, err := c.discoverer.GetClient(). - Do(grpc.WithGRPCMethod(ctx, insertMethod), addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) { + Do(grpc.WithGRPCMethod(ctx, insertMethod), addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (any, error) { return vald.NewInsertClient(conn).Insert(ctx, &payload.Insert_Request{ Vector: vector, // TODO: this should be deleted after Config.Timestamp deprecation @@ -584,9 +587,11 @@ func (c *correct) insertObject(ctx context.Context, addr string, vector *payload return nil } -func (c *correct) deleteObject(ctx context.Context, addr string, vector *payload.Object_Vector) error { +func (c *correct) deleteObject( + ctx context.Context, addr string, vector *payload.Object_Vector, +) error { res, err := c.discoverer.GetClient(). - Do(grpc.WithGRPCMethod(ctx, deleteMethod), addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) { + Do(grpc.WithGRPCMethod(ctx, deleteMethod), addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (any, error) { return vald.NewRemoveClient(conn).Remove(ctx, &payload.Remove_Request{ Id: &payload.Object_ID{ Id: vector.GetId(), @@ -619,7 +624,7 @@ func (c *correct) loadAgentIndexInfo(ctx context.Context) (err error) { case <-ctx.Done(): return nil default: - info, err := agent.NewAgentClient(conn).IndexInfo(ctx, new(payload.Empty), copts...) + info, err := vald.NewValdClient(conn).IndexInfo(ctx, new(payload.Empty), copts...) if err != nil { log.Warnf("an error occurred while calling IndexInfo of %s: %s", addr, err) return nil diff --git a/pkg/index/job/correction/service/corrector_test.go b/pkg/index/job/correction/service/corrector_test.go index 2329cbc2e8..458ad5d12c 100644 --- a/pkg/index/job/correction/service/corrector_test.go +++ b/pkg/index/job/correction/service/corrector_test.go @@ -553,7 +553,138 @@ func Test_correct_correctReplica(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_correct_bboltInit(t *testing.T) { +// type fields struct { +// discoverer discoverer.Client +// agentAddrs []string +// sortedByIndexCntAddrs []string +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// checkedID bbolt.Bbolt +// checkedIndexCount atomic.Uint64 +// correctedOldIndexCount atomic.Uint64 +// correctedReplicationCount atomic.Uint64 +// indexReplica int +// streamListConcurrency int +// bboltAsyncWriteConcurrency int +// } +// 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 { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency:0, +// }, +// 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 { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency:0, +// }, +// 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 +// } +// c := &correct{ +// discoverer: test.fields.discoverer, +// agentAddrs: test.fields.agentAddrs, +// sortedByIndexCntAddrs: test.fields.sortedByIndexCntAddrs, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// checkedID: test.fields.checkedID, +// checkedIndexCount: test.fields.checkedIndexCount, +// correctedOldIndexCount: test.fields.correctedOldIndexCount, +// correctedReplicationCount: test.fields.correctedReplicationCount, +// indexReplica: test.fields.indexReplica, +// streamListConcurrency: test.fields.streamListConcurrency, +// bboltAsyncWriteConcurrency: test.fields.bboltAsyncWriteConcurrency, +// } +// +// err := c.bboltInit() +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -700,7 +831,6 @@ func Test_correct_correctReplica(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -843,7 +973,6 @@ func Test_correct_correctReplica(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -986,7 +1115,6 @@ func Test_correct_correctReplica(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1119,7 +1247,6 @@ func Test_correct_correctReplica(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1252,7 +1379,6 @@ func Test_correct_correctReplica(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1385,7 +1511,1201 @@ func Test_correct_correctReplica(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_correct_correct(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// discoverer discoverer.Client +// agentAddrs []string +// sortedByIndexCntAddrs []string +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// checkedID bbolt.Bbolt +// checkedIndexCount atomic.Uint64 +// correctedOldIndexCount atomic.Uint64 +// correctedReplicationCount atomic.Uint64 +// indexReplica int +// streamListConcurrency int +// bboltAsyncWriteConcurrency int +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 { +// ctx:nil, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 +// } +// c := &correct{ +// discoverer: test.fields.discoverer, +// agentAddrs: test.fields.agentAddrs, +// sortedByIndexCntAddrs: test.fields.sortedByIndexCntAddrs, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// checkedID: test.fields.checkedID, +// checkedIndexCount: test.fields.checkedIndexCount, +// correctedOldIndexCount: test.fields.correctedOldIndexCount, +// correctedReplicationCount: test.fields.correctedReplicationCount, +// indexReplica: test.fields.indexReplica, +// streamListConcurrency: test.fields.streamListConcurrency, +// bboltAsyncWriteConcurrency: test.fields.bboltAsyncWriteConcurrency, +// } +// +// err := c.correct(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_correct_checkConsistency(t *testing.T) { +// type args struct { +// ctx context.Context +// targetReplica *vectorReplica +// targetAgentIdx int +// } +// type fields struct { +// discoverer discoverer.Client +// agentAddrs []string +// sortedByIndexCntAddrs []string +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// checkedID bbolt.Bbolt +// checkedIndexCount atomic.Uint64 +// correctedOldIndexCount atomic.Uint64 +// correctedReplicationCount atomic.Uint64 +// indexReplica int +// streamListConcurrency int +// bboltAsyncWriteConcurrency int +// } +// 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 { +// ctx:nil, +// targetReplica:vectorReplica{}, +// targetAgentIdx:0, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 { +// ctx:nil, +// targetReplica:vectorReplica{}, +// targetAgentIdx:0, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 +// } +// c := &correct{ +// discoverer: test.fields.discoverer, +// agentAddrs: test.fields.agentAddrs, +// sortedByIndexCntAddrs: test.fields.sortedByIndexCntAddrs, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// checkedID: test.fields.checkedID, +// checkedIndexCount: test.fields.checkedIndexCount, +// correctedOldIndexCount: test.fields.correctedOldIndexCount, +// correctedReplicationCount: test.fields.correctedReplicationCount, +// indexReplica: test.fields.indexReplica, +// streamListConcurrency: test.fields.streamListConcurrency, +// bboltAsyncWriteConcurrency: test.fields.bboltAsyncWriteConcurrency, +// } +// +// err := c.checkConsistency(test.args.ctx, test.args.targetReplica, test.args.targetAgentIdx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_correct_updateObject(t *testing.T) { +// type args struct { +// ctx context.Context +// dest *vectorReplica +// src *vectorReplica +// } +// type fields struct { +// discoverer discoverer.Client +// agentAddrs []string +// sortedByIndexCntAddrs []string +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// checkedID bbolt.Bbolt +// checkedIndexCount atomic.Uint64 +// correctedOldIndexCount atomic.Uint64 +// correctedReplicationCount atomic.Uint64 +// indexReplica int +// streamListConcurrency int +// bboltAsyncWriteConcurrency int +// } +// 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 { +// ctx:nil, +// dest:vectorReplica{}, +// src:vectorReplica{}, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 { +// ctx:nil, +// dest:vectorReplica{}, +// src:vectorReplica{}, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 +// } +// c := &correct{ +// discoverer: test.fields.discoverer, +// agentAddrs: test.fields.agentAddrs, +// sortedByIndexCntAddrs: test.fields.sortedByIndexCntAddrs, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// checkedID: test.fields.checkedID, +// checkedIndexCount: test.fields.checkedIndexCount, +// correctedOldIndexCount: test.fields.correctedOldIndexCount, +// correctedReplicationCount: test.fields.correctedReplicationCount, +// indexReplica: test.fields.indexReplica, +// streamListConcurrency: test.fields.streamListConcurrency, +// bboltAsyncWriteConcurrency: test.fields.bboltAsyncWriteConcurrency, +// } +// +// err := c.updateObject(test.args.ctx, test.args.dest, test.args.src) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_correct_fillVectorField(t *testing.T) { +// type args struct { +// ctx context.Context +// replica *vectorReplica +// } +// type fields struct { +// discoverer discoverer.Client +// agentAddrs []string +// sortedByIndexCntAddrs []string +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// checkedID bbolt.Bbolt +// checkedIndexCount atomic.Uint64 +// correctedOldIndexCount atomic.Uint64 +// correctedReplicationCount atomic.Uint64 +// indexReplica int +// streamListConcurrency int +// bboltAsyncWriteConcurrency int +// } +// 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 { +// ctx:nil, +// replica:vectorReplica{}, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 { +// ctx:nil, +// replica:vectorReplica{}, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 +// } +// c := &correct{ +// discoverer: test.fields.discoverer, +// agentAddrs: test.fields.agentAddrs, +// sortedByIndexCntAddrs: test.fields.sortedByIndexCntAddrs, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// checkedID: test.fields.checkedID, +// checkedIndexCount: test.fields.checkedIndexCount, +// correctedOldIndexCount: test.fields.correctedOldIndexCount, +// correctedReplicationCount: test.fields.correctedReplicationCount, +// indexReplica: test.fields.indexReplica, +// streamListConcurrency: test.fields.streamListConcurrency, +// bboltAsyncWriteConcurrency: test.fields.bboltAsyncWriteConcurrency, +// } +// +// err := c.fillVectorField(test.args.ctx, test.args.replica) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_correct_insertObject(t *testing.T) { +// type args struct { +// ctx context.Context +// addr string +// vector *payload.Object_Vector +// } +// type fields struct { +// discoverer discoverer.Client +// agentAddrs []string +// sortedByIndexCntAddrs []string +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// checkedID bbolt.Bbolt +// checkedIndexCount atomic.Uint64 +// correctedOldIndexCount atomic.Uint64 +// correctedReplicationCount atomic.Uint64 +// indexReplica int +// streamListConcurrency int +// bboltAsyncWriteConcurrency int +// } +// 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 { +// ctx:nil, +// addr:"", +// vector:nil, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 { +// ctx:nil, +// addr:"", +// vector:nil, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 +// } +// c := &correct{ +// discoverer: test.fields.discoverer, +// agentAddrs: test.fields.agentAddrs, +// sortedByIndexCntAddrs: test.fields.sortedByIndexCntAddrs, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// checkedID: test.fields.checkedID, +// checkedIndexCount: test.fields.checkedIndexCount, +// correctedOldIndexCount: test.fields.correctedOldIndexCount, +// correctedReplicationCount: test.fields.correctedReplicationCount, +// indexReplica: test.fields.indexReplica, +// streamListConcurrency: test.fields.streamListConcurrency, +// bboltAsyncWriteConcurrency: test.fields.bboltAsyncWriteConcurrency, +// } +// +// err := c.insertObject(test.args.ctx, test.args.addr, test.args.vector) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_correct_deleteObject(t *testing.T) { +// type args struct { +// ctx context.Context +// addr string +// vector *payload.Object_Vector +// } +// type fields struct { +// discoverer discoverer.Client +// agentAddrs []string +// sortedByIndexCntAddrs []string +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// checkedID bbolt.Bbolt +// checkedIndexCount atomic.Uint64 +// correctedOldIndexCount atomic.Uint64 +// correctedReplicationCount atomic.Uint64 +// indexReplica int +// streamListConcurrency int +// bboltAsyncWriteConcurrency int +// } +// 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 { +// ctx:nil, +// addr:"", +// vector:nil, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 { +// ctx:nil, +// addr:"", +// vector:nil, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 +// } +// c := &correct{ +// discoverer: test.fields.discoverer, +// agentAddrs: test.fields.agentAddrs, +// sortedByIndexCntAddrs: test.fields.sortedByIndexCntAddrs, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// checkedID: test.fields.checkedID, +// checkedIndexCount: test.fields.checkedIndexCount, +// correctedOldIndexCount: test.fields.correctedOldIndexCount, +// correctedReplicationCount: test.fields.correctedReplicationCount, +// indexReplica: test.fields.indexReplica, +// streamListConcurrency: test.fields.streamListConcurrency, +// bboltAsyncWriteConcurrency: test.fields.bboltAsyncWriteConcurrency, +// } +// +// err := c.deleteObject(test.args.ctx, test.args.addr, test.args.vector) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_correct_loadAgentIndexInfo(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// discoverer discoverer.Client +// agentAddrs []string +// sortedByIndexCntAddrs []string +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// checkedID bbolt.Bbolt +// checkedIndexCount atomic.Uint64 +// correctedOldIndexCount atomic.Uint64 +// correctedReplicationCount atomic.Uint64 +// indexReplica int +// streamListConcurrency int +// bboltAsyncWriteConcurrency int +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 { +// ctx:nil, +// }, +// fields: fields { +// discoverer:nil, +// agentAddrs:nil, +// sortedByIndexCntAddrs:nil, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// checkedID:nil, +// checkedIndexCount:nil, +// correctedOldIndexCount:nil, +// correctedReplicationCount:nil, +// indexReplica:0, +// streamListConcurrency:0, +// bboltAsyncWriteConcurrency: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 +// } +// c := &correct{ +// discoverer: test.fields.discoverer, +// agentAddrs: test.fields.agentAddrs, +// sortedByIndexCntAddrs: test.fields.sortedByIndexCntAddrs, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// checkedID: test.fields.checkedID, +// checkedIndexCount: test.fields.checkedIndexCount, +// correctedOldIndexCount: test.fields.correctedOldIndexCount, +// correctedReplicationCount: test.fields.correctedReplicationCount, +// indexReplica: test.fields.indexReplica, +// streamListConcurrency: test.fields.streamListConcurrency, +// bboltAsyncWriteConcurrency: test.fields.bboltAsyncWriteConcurrency, +// } +// +// err := c.loadAgentIndexInfo(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_embedTime(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type want struct { +// want context.Context +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, context.Context) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got context.Context) 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 { +// ctx: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 { +// ctx: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 := embedTime(test.args.ctx) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_correctionStartTime(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type want struct { +// want time.Time +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, time.Time, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got time.Time, 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 { +// ctx: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 { +// ctx: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 := correctionStartTime(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/index/job/correction/service/options.go b/pkg/index/job/correction/service/options.go index f8350eef97..3913271e6b 100644 --- a/pkg/index/job/correction/service/options.go +++ b/pkg/index/job/correction/service/options.go @@ -22,10 +22,8 @@ import ( type Option func(*correct) error var defaultOpts = []Option{ - //nolint:gomnd - WithStreamListConcurrency(200), - //nolint:gomnd - WithKvsAsyncWriteConcurrency(2048), + WithStreamListConcurrency(200), //nolint:gomnd + WithKvsAsyncWriteConcurrency(2048), //nolint:gomnd } // WithIndexReplica returns Option that sets index replica. diff --git a/pkg/index/job/correction/service/options_test.go b/pkg/index/job/correction/service/options_test.go index 5caa49c463..59f3bf2707 100644 --- a/pkg/index/job/correction/service/options_test.go +++ b/pkg/index/job/correction/service/options_test.go @@ -96,7 +96,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/index/job/correction/usecase/corrector_test.go b/pkg/index/job/correction/usecase/corrector_test.go index 65653df3e5..fbb7300578 100644 --- a/pkg/index/job/correction/usecase/corrector_test.go +++ b/pkg/index/job/correction/usecase/corrector_test.go @@ -100,7 +100,580 @@ package usecase // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// corrector service.Corrector +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// corrector: test.fields.corrector, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// corrector service.Corrector +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// corrector: test.fields.corrector, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// corrector service.Corrector +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// corrector: test.fields.corrector, +// } +// +// err := r.PreStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// corrector service.Corrector +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// corrector: test.fields.corrector, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// corrector service.Corrector +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// corrector: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// corrector: test.fields.corrector, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/index/job/creation/config/config_test.go b/pkg/index/job/creation/config/config_test.go index 231463a4a1..aed7f2d165 100644 --- a/pkg/index/job/creation/config/config_test.go +++ b/pkg/index/job/creation/config/config_test.go @@ -100,7 +100,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/index/job/creation/service/indexer.go b/pkg/index/job/creation/service/indexer.go index 83ac1eb4e8..87a0159116 100644 --- a/pkg/index/job/creation/service/indexer.go +++ b/pkg/index/job/creation/service/indexer.go @@ -136,7 +136,10 @@ func (idx *index) Start(ctx context.Context) error { } // skipcq: GO-R1005 -func (idx *index) doCreateIndex(ctx context.Context, fn func(_ context.Context, _ agent.AgentClient, _ ...grpc.CallOption) (*payload.Empty, error)) (errs error) { +func (idx *index) doCreateIndex( + ctx context.Context, + fn func(_ context.Context, _ agent.AgentClient, _ ...grpc.CallOption) (*payload.Empty, error), +) (errs error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, grpcMethodName), apiName+"/service/index.doCreateIndex") defer func() { if span != nil { diff --git a/pkg/index/job/creation/service/indexer_test.go b/pkg/index/job/creation/service/indexer_test.go index aec44fdbc9..6e67e4e769 100644 --- a/pkg/index/job/creation/service/indexer_test.go +++ b/pkg/index/job/creation/service/indexer_test.go @@ -302,7 +302,91 @@ func Test_index_Start(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_delDuplicateAddrs(t *testing.T) { +// type args struct { +// targetAddrs []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 { +// targetAddrs: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 { +// targetAddrs: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 := delDuplicateAddrs(test.args.targetAddrs) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -417,7 +501,119 @@ func Test_index_Start(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_index_doCreateIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// fn func(_ context.Context, _ agent.AgentClient, _ ...grpc.CallOption) (*payload.Empty, error) +// } +// type fields struct { +// client discoverer.Client +// targetAddrs []string +// creationPoolSize uint32 +// concurrency int +// } +// 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 { +// ctx:nil, +// fn:nil, +// }, +// fields: fields { +// client:nil, +// targetAddrs:nil, +// creationPoolSize:0, +// concurrency: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 { +// ctx:nil, +// fn:nil, +// }, +// fields: fields { +// client:nil, +// targetAddrs:nil, +// creationPoolSize:0, +// concurrency: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 +// } +// idx := &index{ +// client: test.fields.client, +// targetAddrs: test.fields.targetAddrs, +// creationPoolSize: test.fields.creationPoolSize, +// concurrency: test.fields.concurrency, +// } // +// err := idx.doCreateIndex(test.args.ctx, test.args.fn) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/index/job/creation/service/options_test.go b/pkg/index/job/creation/service/options_test.go index 39423001ba..250bab2f1a 100644 --- a/pkg/index/job/creation/service/options_test.go +++ b/pkg/index/job/creation/service/options_test.go @@ -96,7 +96,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/index/job/creation/usecase/creation_test.go b/pkg/index/job/creation/usecase/creation_test.go index b22780682f..a870303ca6 100644 --- a/pkg/index/job/creation/usecase/creation_test.go +++ b/pkg/index/job/creation/usecase/creation_test.go @@ -100,7 +100,580 @@ package usecase // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/index/job/readreplica/rotate/config/config_test.go b/pkg/index/job/readreplica/rotate/config/config_test.go index 231463a4a1..aed7f2d165 100644 --- a/pkg/index/job/readreplica/rotate/config/config_test.go +++ b/pkg/index/job/readreplica/rotate/config/config_test.go @@ -100,7 +100,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/index/job/readreplica/rotate/service/options_test.go b/pkg/index/job/readreplica/rotate/service/options_test.go index 74eb949bcb..e9e9aacf86 100644 --- a/pkg/index/job/readreplica/rotate/service/options_test.go +++ b/pkg/index/job/readreplica/rotate/service/options_test.go @@ -96,7 +96,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/index/job/readreplica/rotate/service/rotator.go b/pkg/index/job/readreplica/rotate/service/rotator.go index e3c8bfec6b..9975e31b1a 100644 --- a/pkg/index/job/readreplica/rotate/service/rotator.go +++ b/pkg/index/job/readreplica/rotate/service/rotator.go @@ -183,7 +183,9 @@ func (s *subProcess) rotate(ctx context.Context) error { return nil } -func (s *subProcess) createSnapshot(ctx context.Context, deployment *k8s.Deployment) (newSnap, oldSnap *k8s.VolumeSnapshot, err error) { +func (s *subProcess) createSnapshot( + ctx context.Context, deployment *k8s.Deployment, +) (newSnap, oldSnap *k8s.VolumeSnapshot, err error) { list := k8s.VolumeSnapshotList{} if err := s.client.List(ctx, &list, &s.listOpts); err != nil { return nil, nil, fmt.Errorf("failed to get snapshot: %w", err) @@ -227,7 +229,9 @@ func (s *subProcess) createSnapshot(ctx context.Context, deployment *k8s.Deploym return newSnap, oldSnap, nil } -func (s *subProcess) createPVC(ctx context.Context, newSnapShot string, deployment *k8s.Deployment) (newPvc, oldPvc *k8s.PersistentVolumeClaim, err error) { +func (s *subProcess) createPVC( + ctx context.Context, newSnapShot string, deployment *k8s.Deployment, +) (newPvc, oldPvc *k8s.PersistentVolumeClaim, err error) { list := k8s.PersistentVolumeClaimList{} if err := s.client.List(ctx, &list, &s.listOpts); err != nil { return nil, nil, fmt.Errorf("failed to get PVC: %w", err) @@ -293,7 +297,9 @@ func (s *subProcess) getDeployment(ctx context.Context) (*k8s.Deployment, error) return &list.Items[0], nil } -func (s *subProcess) updateDeployment(ctx context.Context, newPVC string, deployment *k8s.Deployment, snapshotTime time.Time) error { +func (s *subProcess) updateDeployment( + ctx context.Context, newPVC string, deployment *k8s.Deployment, snapshotTime time.Time, +) error { if deployment.Spec.Template.ObjectMeta.Annotations == nil { deployment.Spec.Template.ObjectMeta.Annotations = map[string]string{} } diff --git a/pkg/index/job/readreplica/rotate/service/rotator_test.go b/pkg/index/job/readreplica/rotate/service/rotator_test.go index 36e0f4d83e..f6f7bda6c0 100644 --- a/pkg/index/job/readreplica/rotate/service/rotator_test.go +++ b/pkg/index/job/readreplica/rotate/service/rotator_test.go @@ -276,7 +276,6 @@ func Test_parseReplicaID(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -289,9 +288,7 @@ func Test_parseReplicaID(t *testing.T) { // namespace string // volumeName string // readReplicaLabelKey string -// readReplicaID string -// client client.Client -// listOpts client.ListOptions +// subProcesses []subProcess // } // type want struct { // err error @@ -323,9 +320,7 @@ func Test_parseReplicaID(t *testing.T) { // namespace:"", // volumeName:"", // readReplicaLabelKey:"", -// readReplicaID:"", -// client:nil, -// listOpts:nil, +// subProcesses:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -350,9 +345,7 @@ func Test_parseReplicaID(t *testing.T) { // namespace:"", // volumeName:"", // readReplicaLabelKey:"", -// readReplicaID:"", -// client:nil, -// listOpts:nil, +// subProcesses:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -386,16 +379,1033 @@ func Test_parseReplicaID(t *testing.T) { // namespace: test.fields.namespace, // volumeName: test.fields.volumeName, // readReplicaLabelKey: test.fields.readReplicaLabelKey, -// readReplicaID: test.fields.readReplicaID, -// client: test.fields.client, -// listOpts: test.fields.listOpts, +// subProcesses: test.fields.subProcesses, // } // // err := r.Start(test.args.ctx) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_rotator_newSubprocess(t *testing.T) { +// type args struct { +// c client.Client +// replicaID string +// } +// type fields struct { +// namespace string +// volumeName string +// readReplicaLabelKey string +// subProcesses []subProcess +// } +// type want struct { +// want subProcess +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, subProcess, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got subProcess, 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 { +// c:nil, +// replicaID:"", +// }, +// fields: fields { +// namespace:"", +// volumeName:"", +// readReplicaLabelKey:"", +// subProcesses: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, +// replicaID:"", +// }, +// fields: fields { +// namespace:"", +// volumeName:"", +// readReplicaLabelKey:"", +// subProcesses: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 +// } +// r := &rotator{ +// namespace: test.fields.namespace, +// volumeName: test.fields.volumeName, +// readReplicaLabelKey: test.fields.readReplicaLabelKey, +// subProcesses: test.fields.subProcesses, +// } +// +// got, err := r.newSubprocess(test.args.c, test.args.replicaID) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_subProcess_rotate(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// listOpts k8s.ListOptions +// client client.Client +// volumeName string +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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 +// } +// s := &subProcess{ +// listOpts: test.fields.listOpts, +// client: test.fields.client, +// volumeName: test.fields.volumeName, +// } +// +// err := s.rotate(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_subProcess_createSnapshot(t *testing.T) { +// type args struct { +// ctx context.Context +// deployment *k8s.Deployment +// } +// type fields struct { +// listOpts k8s.ListOptions +// client client.Client +// volumeName string +// } +// type want struct { +// wantNewSnap *k8s.VolumeSnapshot +// wantOldSnap *k8s.VolumeSnapshot +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *k8s.VolumeSnapshot, *k8s.VolumeSnapshot, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotNewSnap *k8s.VolumeSnapshot, gotOldSnap *k8s.VolumeSnapshot, 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(gotNewSnap, w.wantNewSnap) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotNewSnap, w.wantNewSnap) +// } +// if !reflect.DeepEqual(gotOldSnap, w.wantOldSnap) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOldSnap, w.wantOldSnap) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// deployment:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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, +// deployment:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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 +// } +// s := &subProcess{ +// listOpts: test.fields.listOpts, +// client: test.fields.client, +// volumeName: test.fields.volumeName, +// } +// +// gotNewSnap, gotOldSnap, err := s.createSnapshot(test.args.ctx, test.args.deployment) +// if err := checkFunc(test.want, gotNewSnap, gotOldSnap, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_subProcess_createPVC(t *testing.T) { +// type args struct { +// ctx context.Context +// newSnapShot string +// deployment *k8s.Deployment +// } +// type fields struct { +// listOpts k8s.ListOptions +// client client.Client +// volumeName string +// } +// type want struct { +// wantNewPvc *k8s.PersistentVolumeClaim +// wantOldPvc *k8s.PersistentVolumeClaim +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *k8s.PersistentVolumeClaim, *k8s.PersistentVolumeClaim, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotNewPvc *k8s.PersistentVolumeClaim, gotOldPvc *k8s.PersistentVolumeClaim, 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(gotNewPvc, w.wantNewPvc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotNewPvc, w.wantNewPvc) +// } +// if !reflect.DeepEqual(gotOldPvc, w.wantOldPvc) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOldPvc, w.wantOldPvc) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// newSnapShot:"", +// deployment:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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, +// newSnapShot:"", +// deployment:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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 +// } +// s := &subProcess{ +// listOpts: test.fields.listOpts, +// client: test.fields.client, +// volumeName: test.fields.volumeName, +// } +// +// gotNewPvc, gotOldPvc, err := s.createPVC(test.args.ctx, test.args.newSnapShot, test.args.deployment) +// if err := checkFunc(test.want, gotNewPvc, gotOldPvc, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_subProcess_getDeployment(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// listOpts k8s.ListOptions +// client client.Client +// volumeName string +// } +// type want struct { +// want *k8s.Deployment +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *k8s.Deployment, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got *k8s.Deployment, 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 { +// ctx:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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 +// } +// s := &subProcess{ +// listOpts: test.fields.listOpts, +// client: test.fields.client, +// volumeName: test.fields.volumeName, +// } +// +// got, err := s.getDeployment(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_subProcess_updateDeployment(t *testing.T) { +// type args struct { +// ctx context.Context +// newPVC string +// deployment *k8s.Deployment +// snapshotTime time.Time +// } +// type fields struct { +// listOpts k8s.ListOptions +// client client.Client +// volumeName string +// } +// 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 { +// ctx:nil, +// newPVC:"", +// deployment:nil, +// snapshotTime:time.Time{}, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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, +// newPVC:"", +// deployment:nil, +// snapshotTime:time.Time{}, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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 +// } +// s := &subProcess{ +// listOpts: test.fields.listOpts, +// client: test.fields.client, +// volumeName: test.fields.volumeName, +// } +// +// err := s.updateDeployment(test.args.ctx, test.args.newPVC, test.args.deployment, test.args.snapshotTime) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_subProcess_deleteSnapshot(t *testing.T) { +// type args struct { +// ctx context.Context +// snapshot *k8s.VolumeSnapshot +// } +// type fields struct { +// listOpts k8s.ListOptions +// client client.Client +// volumeName string +// } +// 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 { +// ctx:nil, +// snapshot:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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, +// snapshot:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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 +// } +// s := &subProcess{ +// listOpts: test.fields.listOpts, +// client: test.fields.client, +// volumeName: test.fields.volumeName, +// } +// +// err := s.deleteSnapshot(test.args.ctx, test.args.snapshot) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_subProcess_deletePVC(t *testing.T) { +// type args struct { +// ctx context.Context +// pvc *k8s.PersistentVolumeClaim +// } +// type fields struct { +// listOpts k8s.ListOptions +// client client.Client +// volumeName string +// } +// 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 { +// ctx:nil, +// pvc:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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, +// pvc:nil, +// }, +// fields: fields { +// listOpts:nil, +// client:nil, +// volumeName:"", +// }, +// 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 +// } +// s := &subProcess{ +// listOpts: test.fields.listOpts, +// client: test.fields.client, +// volumeName: test.fields.volumeName, +// } +// +// err := s.deletePVC(test.args.ctx, test.args.pvc) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_rotator_parseReplicaID(t *testing.T) { +// type args struct { +// replicaID string +// c client.Client +// } +// type fields struct { +// namespace string +// volumeName string +// readReplicaLabelKey string +// subProcesses []subProcess +// } +// type want struct { +// want []string +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, []string, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got []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(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 { +// replicaID:"", +// c:nil, +// }, +// fields: fields { +// namespace:"", +// volumeName:"", +// readReplicaLabelKey:"", +// subProcesses: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 { +// replicaID:"", +// c:nil, +// }, +// fields: fields { +// namespace:"", +// volumeName:"", +// readReplicaLabelKey:"", +// subProcesses: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 +// } +// r := &rotator{ +// namespace: test.fields.namespace, +// volumeName: test.fields.volumeName, +// readReplicaLabelKey: test.fields.readReplicaLabelKey, +// subProcesses: test.fields.subProcesses, +// } +// +// got, err := r.parseReplicaID(test.args.replicaID, test.args.c) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/index/job/readreplica/rotate/usecase/rotate_test.go b/pkg/index/job/readreplica/rotate/usecase/rotate_test.go index b22780682f..9e50824c5f 100644 --- a/pkg/index/job/readreplica/rotate/usecase/rotate_test.go +++ b/pkg/index/job/readreplica/rotate/usecase/rotate_test.go @@ -100,7 +100,580 @@ package usecase // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// rotator service.Rotator +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// rotator: test.fields.rotator, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// rotator service.Rotator +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// rotator: test.fields.rotator, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// rotator service.Rotator +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// rotator: test.fields.rotator, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// rotator service.Rotator +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// rotator: test.fields.rotator, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// rotator service.Rotator +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// rotator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// rotator: test.fields.rotator, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/index/job/save/config/config_test.go b/pkg/index/job/save/config/config_test.go index 231463a4a1..aed7f2d165 100644 --- a/pkg/index/job/save/config/config_test.go +++ b/pkg/index/job/save/config/config_test.go @@ -100,7 +100,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/index/job/save/service/indexer.go b/pkg/index/job/save/service/indexer.go index a3e8325ba4..192caa0fb5 100644 --- a/pkg/index/job/save/service/indexer.go +++ b/pkg/index/job/save/service/indexer.go @@ -133,7 +133,10 @@ func (idx *index) Start(ctx context.Context) error { } // skipcq: GO-R1005 -func (idx *index) doSaveIndex(ctx context.Context, fn func(_ context.Context, _ agent.AgentClient, _ ...grpc.CallOption) (*payload.Empty, error)) (errs error) { +func (idx *index) doSaveIndex( + ctx context.Context, + fn func(_ context.Context, _ agent.AgentClient, _ ...grpc.CallOption) (*payload.Empty, error), +) (errs error) { ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, grpcMethodName), apiName+"/service/index.doSaveIndex") defer func() { if span != nil { diff --git a/pkg/index/job/save/service/indexer_test.go b/pkg/index/job/save/service/indexer_test.go index ed05353bbe..b15437a155 100644 --- a/pkg/index/job/save/service/indexer_test.go +++ b/pkg/index/job/save/service/indexer_test.go @@ -300,7 +300,91 @@ func Test_index_Start(t *testing.T) { // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func Test_delDuplicateAddrs(t *testing.T) { +// type args struct { +// targetAddrs []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 { +// targetAddrs: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 { +// targetAddrs: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 := delDuplicateAddrs(test.args.targetAddrs) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -310,9 +394,9 @@ func Test_index_Start(t *testing.T) { // ctx context.Context // } // type fields struct { -// client discoverer.Client -// targetAddrs []string -// concurrency int +// client discoverer.Client +// targetAddrs []string +// concurrency int // } // type want struct { // want <-chan error @@ -402,16 +486,124 @@ func Test_index_Start(t *testing.T) { // checkFunc = defaultCheckFunc // } // idx := &index{ -// client: test.fields.client, -// targetAddrs: test.fields.targetAddrs, -// concurrency: test.fields.concurrency, +// client: test.fields.client, +// targetAddrs: test.fields.targetAddrs, +// concurrency: test.fields.concurrency, // } // // got, err := idx.StartClient(test.args.ctx) // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_index_doSaveIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// fn func(_ context.Context, _ agent.AgentClient, _ ...grpc.CallOption) (*payload.Empty, error) +// } +// type fields struct { +// client discoverer.Client +// targetAddrs []string +// concurrency int +// } +// 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 { +// ctx:nil, +// fn:nil, +// }, +// fields: fields { +// client:nil, +// targetAddrs:nil, +// concurrency: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 { +// ctx:nil, +// fn:nil, +// }, +// fields: fields { +// client:nil, +// targetAddrs:nil, +// concurrency: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 +// } +// idx := &index{ +// client: test.fields.client, +// targetAddrs: test.fields.targetAddrs, +// concurrency: test.fields.concurrency, +// } // +// err := idx.doSaveIndex(test.args.ctx, test.args.fn) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/index/job/save/service/options_test.go b/pkg/index/job/save/service/options_test.go index 084c3c8466..b7d52a3725 100644 --- a/pkg/index/job/save/service/options_test.go +++ b/pkg/index/job/save/service/options_test.go @@ -96,7 +96,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/index/job/save/usecase/save_test.go b/pkg/index/job/save/usecase/save_test.go index b22780682f..a870303ca6 100644 --- a/pkg/index/job/save/usecase/save_test.go +++ b/pkg/index/job/save/usecase/save_test.go @@ -100,7 +100,580 @@ package usecase // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// indexer service.Indexer +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// indexer: test.fields.indexer, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/index/operator/config/config_test.go b/pkg/index/operator/config/config_test.go new file mode 100644 index 0000000000..aed7f2d165 --- /dev/null +++ b/pkg/index/operator/config/config_test.go @@ -0,0 +1,105 @@ +// 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 config + +// NOT IMPLEMENTED BELOW +// +// func TestNewConfig(t *testing.T) { +// type args struct { +// path string +// } +// type want struct { +// wantCfg *Data +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, *Data, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCfg *Data, 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(gotCfg, w.wantCfg) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCfg, w.wantCfg) +// } +// 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 +// } +// +// gotCfg, err := NewConfig(test.args.path) +// if err := checkFunc(test.want, gotCfg, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/index/operator/service/operator.go b/pkg/index/operator/service/operator.go index 9f7c7b1c48..dc9f476958 100644 --- a/pkg/index/operator/service/operator.go +++ b/pkg/index/operator/service/operator.go @@ -62,7 +62,11 @@ type operator struct { } // New returns Indexer object if no error occurs. -func New(namespace, agentName, rotatorName, targetReadReplicaIDKey string, rotatorJob *k8s.Job, opts ...Option) (o Operator, err error) { +func New( + namespace, agentName, rotatorName, targetReadReplicaIDKey string, + rotatorJob *k8s.Job, + opts ...Option, +) (o Operator, err error) { operator := new(operator) operator.namespace = namespace operator.targetReadReplicaIDAnnotationsKey = targetReadReplicaIDKey @@ -168,7 +172,9 @@ func (o *operator) podOnReconcile(ctx context.Context, pod *k8s.Pod) (k8s.Result // reconcileRotatorJob starts rotation job when the condition meets. // This function is work in progress. -func (o *operator) reconcileRotatorJob(ctx context.Context, pod *k8s.Pod) (requeue bool, err error) { +func (o *operator) reconcileRotatorJob( + ctx context.Context, pod *k8s.Pod, +) (requeue bool, err error) { podIdx, ok := pod.Labels[k8s.PodIndexLabel] if !ok { log.Info("no index label found. the agent is not StatefulSet? skipping...") @@ -236,7 +242,9 @@ func needsRotation(agentAnnotations, readReplicaAnnotations map[string]string) ( return true, nil } -func (o *operator) createRotationJobOrRequeue(ctx context.Context, podIdx string) (rq bool, err error) { +func (o *operator) createRotationJobOrRequeue( + ctx context.Context, podIdx string, +) (rq bool, err error) { // get all the rotation jobs and make sure the job is not running res, err := o.ensureJobConcurrency(ctx, podIdx) if err != nil { @@ -275,7 +283,9 @@ func (o *operator) createRotationJobOrRequeue(ctx context.Context, podIdx string // ensureJobConcurrency controls the job concurrency. It cannot handle concurrent calls but it is fine because // the MaxConcurrentReconciles defaults to 1 and we do not change it. -func (o *operator) ensureJobConcurrency(ctx context.Context, podIdx string) (jobReconcileResult, error) { +func (o *operator) ensureJobConcurrency( + ctx context.Context, podIdx string, +) (jobReconcileResult, error) { // get all the rotation jobs and make sure the job is not running var jobList k8s.JobList selector, err := o.client.LabelSelector("app", k8s.SelectionOpEquals, []string{o.rotatorName}) diff --git a/pkg/index/operator/service/operator_test.go b/pkg/index/operator/service/operator_test.go index be519476a5..de55bec036 100644 --- a/pkg/index/operator/service/operator_test.go +++ b/pkg/index/operator/service/operator_test.go @@ -325,3 +325,762 @@ func Test_operator_podOnReconcile(t *testing.T) { }) } } + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// namespace string +// agentName string +// rotatorName string +// targetReadReplicaIDKey string +// rotatorJob *k8s.Job +// opts []Option +// } +// type want struct { +// wantO Operator +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Operator, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotO Operator, 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(gotO, w.wantO) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotO, w.wantO) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// namespace:"", +// agentName:"", +// rotatorName:"", +// targetReadReplicaIDKey:"", +// rotatorJob:nil, +// 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 { +// namespace:"", +// agentName:"", +// rotatorName:"", +// targetReadReplicaIDKey:"", +// rotatorJob:nil, +// 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 +// } +// +// gotO, err := New(test.args.namespace, test.args.agentName, test.args.rotatorName, test.args.targetReadReplicaIDKey, test.args.rotatorJob, test.args.opts...) +// if err := checkFunc(test.want, gotO, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_operator_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// ctrl k8s.Controller +// eg errgroup.Group +// namespace string +// client client.Client +// rotatorName string +// targetReadReplicaIDAnnotationsKey string +// readReplicaEnabled bool +// readReplicaLabelKey string +// rotationJobConcurrency uint +// rotatorJob *k8s.Job +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// ctrl:nil, +// eg:nil, +// namespace:"", +// client:nil, +// rotatorName:"", +// targetReadReplicaIDAnnotationsKey:"", +// readReplicaEnabled:false, +// readReplicaLabelKey:"", +// rotationJobConcurrency:0, +// rotatorJob: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 { +// ctx:nil, +// }, +// fields: fields { +// ctrl:nil, +// eg:nil, +// namespace:"", +// client:nil, +// rotatorName:"", +// targetReadReplicaIDAnnotationsKey:"", +// readReplicaEnabled:false, +// readReplicaLabelKey:"", +// rotationJobConcurrency:0, +// rotatorJob: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 +// } +// o := &operator{ +// ctrl: test.fields.ctrl, +// eg: test.fields.eg, +// namespace: test.fields.namespace, +// client: test.fields.client, +// rotatorName: test.fields.rotatorName, +// targetReadReplicaIDAnnotationsKey: test.fields.targetReadReplicaIDAnnotationsKey, +// readReplicaEnabled: test.fields.readReplicaEnabled, +// readReplicaLabelKey: test.fields.readReplicaLabelKey, +// rotationJobConcurrency: test.fields.rotationJobConcurrency, +// rotatorJob: test.fields.rotatorJob, +// } +// +// got, err := o.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_operator_reconcileRotatorJob(t *testing.T) { +// type args struct { +// ctx context.Context +// pod *k8s.Pod +// } +// type fields struct { +// ctrl k8s.Controller +// eg errgroup.Group +// namespace string +// client client.Client +// rotatorName string +// targetReadReplicaIDAnnotationsKey string +// readReplicaEnabled bool +// readReplicaLabelKey string +// rotationJobConcurrency uint +// rotatorJob *k8s.Job +// } +// type want struct { +// wantRequeue bool +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, bool, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRequeue bool, 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(gotRequeue, w.wantRequeue) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRequeue, w.wantRequeue) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// pod:nil, +// }, +// fields: fields { +// ctrl:nil, +// eg:nil, +// namespace:"", +// client:nil, +// rotatorName:"", +// targetReadReplicaIDAnnotationsKey:"", +// readReplicaEnabled:false, +// readReplicaLabelKey:"", +// rotationJobConcurrency:0, +// rotatorJob: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 { +// ctx:nil, +// pod:nil, +// }, +// fields: fields { +// ctrl:nil, +// eg:nil, +// namespace:"", +// client:nil, +// rotatorName:"", +// targetReadReplicaIDAnnotationsKey:"", +// readReplicaEnabled:false, +// readReplicaLabelKey:"", +// rotationJobConcurrency:0, +// rotatorJob: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 +// } +// o := &operator{ +// ctrl: test.fields.ctrl, +// eg: test.fields.eg, +// namespace: test.fields.namespace, +// client: test.fields.client, +// rotatorName: test.fields.rotatorName, +// targetReadReplicaIDAnnotationsKey: test.fields.targetReadReplicaIDAnnotationsKey, +// readReplicaEnabled: test.fields.readReplicaEnabled, +// readReplicaLabelKey: test.fields.readReplicaLabelKey, +// rotationJobConcurrency: test.fields.rotationJobConcurrency, +// rotatorJob: test.fields.rotatorJob, +// } +// +// gotRequeue, err := o.reconcileRotatorJob(test.args.ctx, test.args.pod) +// if err := checkFunc(test.want, gotRequeue, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_needsRotation(t *testing.T) { +// type args struct { +// agentAnnotations map[string]string +// readReplicaAnnotations map[string]string +// } +// type want struct { +// want bool +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, bool, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got bool, 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 { +// agentAnnotations:nil, +// readReplicaAnnotations: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 { +// agentAnnotations:nil, +// readReplicaAnnotations: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 := needsRotation(test.args.agentAnnotations, test.args.readReplicaAnnotations) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_operator_createRotationJobOrRequeue(t *testing.T) { +// type args struct { +// ctx context.Context +// podIdx string +// } +// type fields struct { +// ctrl k8s.Controller +// eg errgroup.Group +// namespace string +// client client.Client +// rotatorName string +// targetReadReplicaIDAnnotationsKey string +// readReplicaEnabled bool +// readReplicaLabelKey string +// rotationJobConcurrency uint +// rotatorJob *k8s.Job +// } +// type want struct { +// wantRq bool +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, bool, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRq bool, 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(gotRq, w.wantRq) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRq, w.wantRq) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// podIdx:"", +// }, +// fields: fields { +// ctrl:nil, +// eg:nil, +// namespace:"", +// client:nil, +// rotatorName:"", +// targetReadReplicaIDAnnotationsKey:"", +// readReplicaEnabled:false, +// readReplicaLabelKey:"", +// rotationJobConcurrency:0, +// rotatorJob: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 { +// ctx:nil, +// podIdx:"", +// }, +// fields: fields { +// ctrl:nil, +// eg:nil, +// namespace:"", +// client:nil, +// rotatorName:"", +// targetReadReplicaIDAnnotationsKey:"", +// readReplicaEnabled:false, +// readReplicaLabelKey:"", +// rotationJobConcurrency:0, +// rotatorJob: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 +// } +// o := &operator{ +// ctrl: test.fields.ctrl, +// eg: test.fields.eg, +// namespace: test.fields.namespace, +// client: test.fields.client, +// rotatorName: test.fields.rotatorName, +// targetReadReplicaIDAnnotationsKey: test.fields.targetReadReplicaIDAnnotationsKey, +// readReplicaEnabled: test.fields.readReplicaEnabled, +// readReplicaLabelKey: test.fields.readReplicaLabelKey, +// rotationJobConcurrency: test.fields.rotationJobConcurrency, +// rotatorJob: test.fields.rotatorJob, +// } +// +// gotRq, err := o.createRotationJobOrRequeue(test.args.ctx, test.args.podIdx) +// if err := checkFunc(test.want, gotRq, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_operator_ensureJobConcurrency(t *testing.T) { +// type args struct { +// ctx context.Context +// podIdx string +// } +// type fields struct { +// ctrl k8s.Controller +// eg errgroup.Group +// namespace string +// client client.Client +// rotatorName string +// targetReadReplicaIDAnnotationsKey string +// readReplicaEnabled bool +// readReplicaLabelKey string +// rotationJobConcurrency uint +// rotatorJob *k8s.Job +// } +// type want struct { +// want jobReconcileResult +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, jobReconcileResult, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got jobReconcileResult, 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 { +// ctx:nil, +// podIdx:"", +// }, +// fields: fields { +// ctrl:nil, +// eg:nil, +// namespace:"", +// client:nil, +// rotatorName:"", +// targetReadReplicaIDAnnotationsKey:"", +// readReplicaEnabled:false, +// readReplicaLabelKey:"", +// rotationJobConcurrency:0, +// rotatorJob: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 { +// ctx:nil, +// podIdx:"", +// }, +// fields: fields { +// ctrl:nil, +// eg:nil, +// namespace:"", +// client:nil, +// rotatorName:"", +// targetReadReplicaIDAnnotationsKey:"", +// readReplicaEnabled:false, +// readReplicaLabelKey:"", +// rotationJobConcurrency:0, +// rotatorJob: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 +// } +// o := &operator{ +// ctrl: test.fields.ctrl, +// eg: test.fields.eg, +// namespace: test.fields.namespace, +// client: test.fields.client, +// rotatorName: test.fields.rotatorName, +// targetReadReplicaIDAnnotationsKey: test.fields.targetReadReplicaIDAnnotationsKey, +// readReplicaEnabled: test.fields.readReplicaEnabled, +// readReplicaLabelKey: test.fields.readReplicaLabelKey, +// rotationJobConcurrency: test.fields.rotationJobConcurrency, +// rotatorJob: test.fields.rotatorJob, +// } +// +// got, err := o.ensureJobConcurrency(test.args.ctx, test.args.podIdx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/index/operator/service/options_test.go b/pkg/index/operator/service/options_test.go new file mode 100644 index 0000000000..193ccdaf68 --- /dev/null +++ b/pkg/index/operator/service/options_test.go @@ -0,0 +1,441 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithReadReplicaEnabled(t *testing.T) { +// type args struct { +// enabled 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 { +// enabled: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 { +// enabled: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 := WithReadReplicaEnabled(test.args.enabled) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithReadReplicaLabelKey(t *testing.T) { +// type args struct { +// key 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 { +// key:"", +// }, +// 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:"", +// }, +// 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 := WithReadReplicaLabelKey(test.args.key) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithRotationJobConcurrency(t *testing.T) { +// type args struct { +// concurrency uint +// } +// 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 { +// concurrency: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 { +// concurrency: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 := WithRotationJobConcurrency(test.args.concurrency) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithK8sClient(t *testing.T) { +// type args struct { +// client client.Client +// } +// 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 { +// client: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 { +// client: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 := WithK8sClient(test.args.client) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/index/operator/usecase/operator.go b/pkg/index/operator/usecase/operator.go index c2e0e71aa1..323db08081 100644 --- a/pkg/index/operator/usecase/operator.go +++ b/pkg/index/operator/usecase/operator.go @@ -100,7 +100,7 @@ func (r *run) PreStart(ctx context.Context) error { // Start is a method used to initiate an operation in the run, and it returns a channel for receiving errors // during the operation and an error representing any initialization errors. func (r *run) Start(ctx context.Context) (<-chan error, error) { - ech := make(chan error, 3) //nolint: gomnd + ech := make(chan error, 3) //nolint:gomnd var oech, dech, sech <-chan error r.eg.Go(safety.RecoverFunc(func() (err error) { defer close(ech) diff --git a/pkg/index/operator/usecase/operator_test.go b/pkg/index/operator/usecase/operator_test.go new file mode 100644 index 0000000000..f4b4f1b654 --- /dev/null +++ b/pkg/index/operator/usecase/operator_test.go @@ -0,0 +1,679 @@ +// 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 usecase + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// cfg *config.Data +// } +// type want struct { +// want runner.Runner +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, runner.Runner, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got runner.Runner, 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 { +// cfg: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 { +// cfg: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.cfg) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// operator service.Operator +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// operator: test.fields.operator, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// operator service.Operator +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// operator: test.fields.operator, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// operator service.Operator +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// operator: test.fields.operator, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// operator service.Operator +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// operator: test.fields.operator, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// observability observability.Observability +// server starter.Server +// operator service.Operator +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// observability:nil, +// server:nil, +// operator: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// observability: test.fields.observability, +// server: test.fields.server, +// operator: test.fields.operator, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/manager/index/config/config_test.go b/pkg/manager/index/config/config_test.go index 2d7afeecdd..5a237d0a9f 100644 --- a/pkg/manager/index/config/config_test.go +++ b/pkg/manager/index/config/config_test.go @@ -104,7 +104,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/manager/index/handler/grpc/handler.go b/pkg/manager/index/handler/grpc/handler.go index baa60334b2..b910f2742a 100644 --- a/pkg/manager/index/handler/grpc/handler.go +++ b/pkg/manager/index/handler/grpc/handler.go @@ -20,8 +20,8 @@ package grpc import ( "context" - "github.com/vdaas/vald/apis/grpc/v1/manager/index" "github.com/vdaas/vald/apis/grpc/v1/payload" + index "github.com/vdaas/vald/apis/grpc/v1/vald" "github.com/vdaas/vald/internal/observability/trace" "github.com/vdaas/vald/pkg/manager/index/service" ) @@ -40,7 +40,9 @@ func New(opts ...Option) index.IndexServer { return s } -func (s *server) IndexInfo(ctx context.Context, _ *payload.Empty) (res *payload.Info_Index_Count, err error) { +func (s *server) IndexInfo( + ctx context.Context, _ *payload.Empty, +) (res *payload.Info_Index_Count, err error) { ctx, span := trace.StartSpan(ctx, "vald/manager-index.IndexInfo") defer func() { if span != nil { @@ -53,3 +55,15 @@ func (s *server) IndexInfo(ctx context.Context, _ *payload.Empty) (res *payload. Indexing: s.indexer.IsIndexing(), }, nil } + +func (s *server) IndexDetail( + ctx context.Context, _ *payload.Empty, +) (res *payload.Info_Index_Detail, err error) { + ctx, span := trace.StartSpan(ctx, "vald/manager-index.IndexDetail") + defer func() { + if span != nil { + span.End() + } + }() + return s.indexer.LoadIndexDetail(), nil +} diff --git a/pkg/manager/index/handler/grpc/handler_test.go b/pkg/manager/index/handler/grpc/handler_test.go index 7318ce15fb..e93264dbd6 100644 --- a/pkg/manager/index/handler/grpc/handler_test.go +++ b/pkg/manager/index/handler/grpc/handler_test.go @@ -100,7 +100,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -210,7 +209,115 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_server_IndexDetail(t *testing.T) { +// type args struct { +// ctx context.Context +// in1 *payload.Empty +// } +// type fields struct { +// indexer service.Indexer +// UnimplementedIndexServer index.UnimplementedIndexServer +// } +// type want struct { +// wantRes *payload.Info_Index_Detail +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Detail, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRes *payload.Info_Index_Detail, 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// indexer:nil, +// UnimplementedIndexServer: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 { +// ctx:nil, +// in1:nil, +// }, +// fields: fields { +// indexer:nil, +// UnimplementedIndexServer: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 +// } +// s := &server{ +// indexer: test.fields.indexer, +// UnimplementedIndexServer: test.fields.UnimplementedIndexServer, +// } // +// gotRes, err := s.IndexDetail(test.args.ctx, test.args.in1) +// if err := checkFunc(test.want, gotRes, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/manager/index/handler/grpc/option.go b/pkg/manager/index/handler/grpc/option.go index 3323225bb6..d521b356ff 100644 --- a/pkg/manager/index/handler/grpc/option.go +++ b/pkg/manager/index/handler/grpc/option.go @@ -17,9 +17,7 @@ // Package grpc provides grpc server logic package grpc -import ( - "github.com/vdaas/vald/pkg/manager/index/service" -) +import "github.com/vdaas/vald/pkg/manager/index/service" type Option func(*server) diff --git a/pkg/manager/index/handler/grpc/option_test.go b/pkg/manager/index/handler/grpc/option_test.go index 7fd0b430af..7efdb624af 100644 --- a/pkg/manager/index/handler/grpc/option_test.go +++ b/pkg/manager/index/handler/grpc/option_test.go @@ -100,7 +100,6 @@ package grpc // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/manager/index/handler/rest/handler.go b/pkg/manager/index/handler/rest/handler.go index 258d5d9c7d..c3e9d356f4 100644 --- a/pkg/manager/index/handler/rest/handler.go +++ b/pkg/manager/index/handler/rest/handler.go @@ -20,8 +20,8 @@ package rest import ( "net/http" - "github.com/vdaas/vald/apis/grpc/v1/manager/index" "github.com/vdaas/vald/apis/grpc/v1/payload" + index "github.com/vdaas/vald/apis/grpc/v1/vald" "github.com/vdaas/vald/internal/net/http/dump" "github.com/vdaas/vald/internal/net/http/json" ) @@ -45,15 +45,15 @@ func New(opts ...Option) Handler { } func (*handler) Index(w http.ResponseWriter, r *http.Request) (int, error) { - data := make(map[string]interface{}) - return json.Handler(w, r, &data, func() (interface{}, error) { + data := make(map[string]any) + return json.Handler(w, r, &data, func() (any, error) { return dump.Request(nil, data, r) }) } func (h *handler) IndexInfo(w http.ResponseWriter, r *http.Request) (code int, err error) { var req *payload.Empty - return json.Handler(w, r, &req, func() (interface{}, error) { + return json.Handler(w, r, &req, func() (any, error) { return h.indexer.IndexInfo(r.Context(), req) }) } diff --git a/pkg/manager/index/handler/rest/handler_test.go b/pkg/manager/index/handler/rest/handler_test.go new file mode 100644 index 0000000000..1cad5e5dba --- /dev/null +++ b/pkg/manager/index/handler/rest/handler_test.go @@ -0,0 +1,311 @@ +// 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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_Index(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// indexer index.IndexServer +// } +// type want struct { +// want int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// indexer: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// indexer: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 +// } +// h := &handler{ +// indexer: test.fields.indexer, +// } +// +// got, err := h.Index(test.args.w, test.args.r) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_handler_IndexInfo(t *testing.T) { +// type args struct { +// w http.ResponseWriter +// r *http.Request +// } +// type fields struct { +// indexer index.IndexServer +// } +// type want struct { +// wantCode int +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCode 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(gotCode, w.wantCode) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCode, w.wantCode) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// w:nil, +// r:nil, +// }, +// fields: fields { +// indexer: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 { +// w:nil, +// r:nil, +// }, +// fields: fields { +// indexer: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 +// } +// h := &handler{ +// indexer: test.fields.indexer, +// } +// +// gotCode, err := h.IndexInfo(test.args.w, test.args.r) +// if err := checkFunc(test.want, gotCode, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/manager/index/handler/rest/option.go b/pkg/manager/index/handler/rest/option.go index ec39e2913d..115765c052 100644 --- a/pkg/manager/index/handler/rest/option.go +++ b/pkg/manager/index/handler/rest/option.go @@ -17,7 +17,7 @@ // Package rest provides rest api logic package rest -import "github.com/vdaas/vald/apis/grpc/v1/manager/index" +import index "github.com/vdaas/vald/apis/grpc/v1/vald" type Option func(*handler) diff --git a/pkg/manager/index/handler/rest/option_test.go b/pkg/manager/index/handler/rest/option_test.go new file mode 100644 index 0000000000..594e336727 --- /dev/null +++ b/pkg/manager/index/handler/rest/option_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestWithIndexer(t *testing.T) { +// type args struct { +// i index.IndexServer +// } +// 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 { +// i: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 { +// i: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 := WithIndexer(test.args.i) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/manager/index/router/option.go b/pkg/manager/index/router/option.go index 834aae2f68..b88a3b9b9b 100644 --- a/pkg/manager/index/router/option.go +++ b/pkg/manager/index/router/option.go @@ -17,9 +17,7 @@ // Package router provides implementation of Go API for routing http Handler wrapped by rest.Func package router -import ( - "github.com/vdaas/vald/pkg/manager/index/handler/rest" -) +import "github.com/vdaas/vald/pkg/manager/index/handler/rest" type Option func(*router) diff --git a/pkg/manager/index/router/option_test.go b/pkg/manager/index/router/option_test.go new file mode 100644 index 0000000000..c39d90a7bc --- /dev/null +++ b/pkg/manager/index/router/option_test.go @@ -0,0 +1,186 @@ +// 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 router + +// NOT IMPLEMENTED BELOW +// +// func TestWithHandler(t *testing.T) { +// type args struct { +// h rest.Handler +// } +// 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 { +// h: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 { +// h: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 := WithHandler(test.args.h) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTimeout(t *testing.T) { +// type args struct { +// timeout 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 { +// timeout:"", +// }, +// 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 { +// timeout:"", +// }, +// 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 := WithTimeout(test.args.timeout) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/manager/index/router/router_test.go b/pkg/manager/index/router/router_test.go new file mode 100644 index 0000000000..e9e3069588 --- /dev/null +++ b/pkg/manager/index/router/router_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 router + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want http.Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, http.Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got http.Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/manager/index/service/indexer.go b/pkg/manager/index/service/indexer.go index 4d6b39729b..42e90b1c9b 100644 --- a/pkg/manager/index/service/indexer.go +++ b/pkg/manager/index/service/indexer.go @@ -26,6 +26,7 @@ import ( agent "github.com/vdaas/vald/apis/grpc/v1/agent/core" "github.com/vdaas/vald/apis/grpc/v1/payload" + vald "github.com/vdaas/vald/apis/grpc/v1/vald" "github.com/vdaas/vald/internal/client/v1/client/discoverer" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" @@ -43,6 +44,8 @@ type Indexer interface { NumberOfUUIDs() uint32 NumberOfUncommittedUUIDs() uint32 IsIndexing() bool + IsSaving() bool + LoadIndexDetail() *payload.Info_Index_Detail } type index struct { @@ -51,18 +54,21 @@ type index struct { creationPoolSize uint32 indexDuration time.Duration indexDurationLimit time.Duration + saveIndexDuration time.Duration saveIndexDurationLimit time.Duration - saveIndexWaitDuration time.Duration - saveIndexTargetAddrCh chan string - schMap sync.Map[string, any] - concurrency int + shouldSaveList sync.Map[string, struct{}] + createIndexConcurrency int + saveIndexConcurrency int indexInfos sync.Map[string, *payload.Info_Index_Count] - indexing atomic.Value // bool + indexing atomic.Bool + saving atomic.Bool minUncommitted uint32 uuidsCount uint32 uncommittedUUIDsCount uint32 } +var empty = struct{}{} + func New(opts ...Option) (idx Indexer, err error) { i := new(index) for _, opt := range append(defaultOptions, opts...) { @@ -71,7 +77,8 @@ func New(opts ...Option) (idx Indexer, err error) { } } i.indexing.Store(false) - if i.indexDuration+i.indexDurationLimit+i.saveIndexDurationLimit == 0 { + i.saving.Store(false) + if i.indexDuration+i.indexDurationLimit+i.saveIndexDurationLimit <= 0 { return nil, errors.ErrInvalidConfig } return i, nil @@ -87,8 +94,6 @@ func (idx *index) Start(ctx context.Context) (<-chan error, error) { return nil, err } ech := make(chan error, 100) - sech := make(chan error, 10) - idx.saveIndexTargetAddrCh = make(chan string, len(idx.client.GetAddrs(ctx))*2) idx.eg.Go(safety.RecoverFunc(func() (err error) { defer close(ech) if idx.indexDuration <= 0 { @@ -97,56 +102,101 @@ func (idx *index) Start(ctx context.Context) (<-chan error, error) { if idx.indexDurationLimit <= 0 { idx.indexDurationLimit = math.MaxInt64 } + if idx.saveIndexDuration <= 0 { + idx.saveIndexDuration = math.MaxInt64 + } if idx.saveIndexDurationLimit <= 0 { idx.saveIndexDurationLimit = math.MaxInt64 } it := time.NewTicker(idx.indexDuration) itl := time.NewTicker(idx.indexDurationLimit) + st := time.NewTicker(idx.saveIndexDuration) stl := time.NewTicker(idx.saveIndexDurationLimit) defer it.Stop() defer itl.Stop() + defer st.Stop() defer stl.Stop() finalize := func() (err error) { err = ctx.Err() - if err != nil && err != context.Canceled { + if err != nil && + !errors.Is(err, context.Canceled) && + !errors.Is(err, context.DeadlineExceeded) { return err } return nil } + var mu sync.Mutex for { select { case <-ctx.Done(): return finalize() case err = <-dech: - ech <- err - case err = <-sech: - ech <- err - case <-it.C: - err = idx.execute(grpc.WithGRPCMethod(ctx, "core.v1.Agent/CreateIndex"), true, false) - if err != nil { - ech <- err - log.Error("an error occurred during indexing", err) - err = nil + case <-it.C: // index duration ticker + // execute CreateIndex. This execution ignores low index agent. + err = idx.createIndex(grpc.WithGRPCMethod(ctx, "core.v1.Agent/CreateIndex"), true) + if err != nil && + !errors.Is(err, context.Canceled) && + !errors.Is(err, context.DeadlineExceeded) { + err = errors.Wrap(err, "an error occurred during create indexing") } it.Reset(idx.indexDuration) - case <-itl.C: - err = idx.execute(grpc.WithGRPCMethod(ctx, "core.v1.Agent/CreateIndex"), false, false) - if err != nil { - ech <- err - log.Error("an error occurred during indexing", err) - err = nil + case <-itl.C: // index duration limit ticker + // execute CreateIndex. This execution always executes CreateIndex regardless of the state of the uncommitted index. + err = idx.createIndex(grpc.WithGRPCMethod(ctx, "core.v1.Agent/CreateIndex"), false) + if err != nil && + !errors.Is(err, context.Canceled) && + !errors.Is(err, context.DeadlineExceeded) { + err = errors.Wrap(err, "an error occurred during force create indexing") } itl.Reset(idx.indexDurationLimit) - case <-stl.C: - err = idx.execute(grpc.WithGRPCMethod(ctx, "core.v1.Agent/CreateAndSaveIndex"), false, true) - if err != nil { - ech <- err - log.Error("an error occurred during indexing and saving", err) - err = nil - } - stl.Reset(idx.saveIndexDurationLimit) + case <-st.C: // save index duration ticker + // execute SaveIndex in concurrent. + idx.eg.Go(safety.RecoverFunc(func() (err error) { + if !mu.TryLock() { + return + } + defer mu.Unlock() + defer st.Reset(idx.saveIndexDuration) + err = idx.saveIndex(grpc.WithGRPCMethod(ctx, "core.v1.Agent/SaveIndex"), false) + if err != nil && + !errors.Is(err, context.Canceled) && + !errors.Is(err, context.DeadlineExceeded) { + err = errors.Wrap(err, "an error occurred during save indexing") + log.Error(err) + select { + case <-ctx.Done(): + return nil + case ech <- err: + } + } + return nil + })) + case <-stl.C: // save index duration limit ticker + // execute SaveIndex in concurrent. + idx.eg.Go(safety.RecoverFunc(func() (err error) { + if !mu.TryLock() { + return + } + defer mu.Unlock() + defer stl.Reset(idx.saveIndexDurationLimit) + err = idx.saveIndex(grpc.WithGRPCMethod(ctx, "core.v1.Agent/SaveIndex"), true) + if err != nil && + !errors.Is(err, context.Canceled) && + !errors.Is(err, context.DeadlineExceeded) { + err = errors.Wrap(err, "an error occurred during force save indexing") + log.Error(err) + select { + case <-ctx.Done(): + return nil + case ech <- err: + } + } + return nil + })) } - if err != nil { + if err != nil && + !errors.Is(err, context.Canceled) && + !errors.Is(err, context.DeadlineExceeded) { log.Error(err) select { case <-ctx.Done(): @@ -156,35 +206,10 @@ func (idx *index) Start(ctx context.Context) (<-chan error, error) { } } })) - idx.eg.Go(safety.RecoverFunc(func() (err error) { - defer close(sech) - for { - select { - case <-ctx.Done(): - return - case addr := <-idx.saveIndexTargetAddrCh: - idx.schMap.Delete(addr) - _, err := idx.client.GetClient(). - Do(grpc.WithGRPCMethod(ctx, "core.v1.Agent/SaveIndex"), addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) { - return agent.NewAgentClient(conn).SaveIndex(ctx, &payload.Empty{}, copts...) - }) - if err != nil { - log.Warnf("an error occurred while calling SaveIndex of %s: %s", addr, err) - select { - case <-ctx.Done(): - return nil - case sech <- err: - } - } - } - - idx.waitForNextSaving(ctx) - } - })) return ech, nil } -func (idx *index) execute(ctx context.Context, enableLowIndexSkip, immediateSaving bool) (err error) { +func (idx *index) createIndex(ctx context.Context, enableLowIndexSkip bool) (err error) { ctx, span := trace.StartSpan(ctx, "vald/manager-index/service/Indexer.execute") defer func() { if span != nil { @@ -192,79 +217,75 @@ func (idx *index) execute(ctx context.Context, enableLowIndexSkip, immediateSavi } }() - if idx.indexing.Load().(bool) { + if idx.indexing.Load() { return nil } idx.indexing.Store(true) defer idx.indexing.Store(false) - addrs := idx.client.GetAddrs(ctx) - err = idx.client.GetClient().OrderedRangeConcurrent(ctx, addrs, - idx.concurrency, + return errors.Join(idx.client.GetClient().OrderedRangeConcurrent(ctx, idx.client.GetAddrs(ctx), + idx.createIndexConcurrency, func(ctx context.Context, addr string, conn *grpc.ClientConn, copts ...grpc.CallOption, ) (err error) { - select { - case <-ctx.Done(): - return nil - default: - } info, ok := idx.indexInfos.Load(addr) if ok && (info.GetUncommitted() == 0 || (enableLowIndexSkip && info.GetUncommitted() < idx.minUncommitted)) { return nil } - ac := agent.NewAgentClient(conn) - req := &payload.Control_CreateIndexRequest{ + _, err = agent.NewAgentClient(conn).CreateIndex(ctx, &payload.Control_CreateIndexRequest{ PoolSize: idx.creationPoolSize, - } - if !immediateSaving { - _, err = ac.CreateIndex(ctx, req, copts...) - if err != nil { - st, ok := status.FromError(err) - if ok && st != nil && st.Code() == codes.FailedPrecondition { - log.Debugf("CreateIndex of %s skipped, message: %s, err: %v", addr, st.Message(), errors.Join(st.Err(), err)) - return nil - } - log.Warnf("an error occurred while calling CreateIndex of %s: %s", addr, err) - return err - } - _, ok := idx.schMap.Load(addr) - if !ok { - select { - case <-ctx.Done(): - case idx.saveIndexTargetAddrCh <- addr: - idx.schMap.Store(addr, struct{}{}) - } - } - return nil - } - _, err = ac.CreateAndSaveIndex(ctx, req, copts...) + }, copts...) if err != nil { st, ok := status.FromError(err) if ok && st != nil && st.Code() == codes.FailedPrecondition { log.Debugf("CreateIndex of %s skipped, message: %s, err: %v", addr, st.Message(), errors.Join(st.Err(), err)) return nil } - log.Warnf("an error occurred while calling CreateAndSaveIndex of %s: %s", addr, err) + log.Warnf("an error occurred while calling CreateIndex of %s: %s", addr, err) return err } - idx.waitForNextSaving(ctx) + _, ok = idx.shouldSaveList.LoadOrStore(addr, empty) + if ok { + log.Debugf("addr %s already queued for saveIndex", addr) + return nil + } return nil - }) - if err != nil { - return err - } - return idx.loadInfos(ctx) + }), idx.loadInfos(ctx)) } -func (idx *index) waitForNextSaving(ctx context.Context) { - if idx.saveIndexWaitDuration > 0 { - timer := time.NewTimer(idx.saveIndexWaitDuration) - select { - case <-ctx.Done(): - case <-timer.C: +func (idx *index) saveIndex(ctx context.Context, force bool) (err error) { + ctx, span := trace.StartSpan(ctx, "vald/manager-index/service/Indexer.saveIndex") + defer func() { + if span != nil { + span.End() } - timer.Stop() + }() + + if idx.saving.Load() { + return nil } + idx.saving.Store(true) + defer idx.saving.Store(false) + return idx.client.GetClient().OrderedRangeConcurrent(ctx, idx.client.GetAddrs(ctx), + idx.saveIndexConcurrency, + func(ctx context.Context, + addr string, conn *grpc.ClientConn, copts ...grpc.CallOption, + ) (err error) { + _, ok := idx.shouldSaveList.LoadAndDelete(addr) + if !ok && !force { + return nil + } + _, err = agent.NewAgentClient(conn).SaveIndex(ctx, new(payload.Empty), copts...) + if err != nil { + st, ok := status.FromError(err) + if ok && st != nil && st.Code() == codes.FailedPrecondition { + log.Debugf("CreateIndex of %s skipped, message: %s, err: %v", addr, st.Message(), errors.Join(st.Err(), err)) + return nil + } + log.Warnf("an error occurred while calling CreateIndex of %s: %s", addr, err) + return err + } + return nil + }) } func (idx *index) loadInfos(ctx context.Context) (err error) { @@ -285,7 +306,7 @@ func (idx *index) loadInfos(ctx context.Context) (err error) { case <-ctx.Done(): return nil default: - info, err := agent.NewAgentClient(conn).IndexInfo(ctx, new(payload.Empty), copts...) + info, err := vald.NewValdClient(conn).IndexInfo(ctx, new(payload.Empty), copts...) if err != nil { log.Warnf("an error occurred while calling IndexInfo of %s: %s", addr, err) return nil @@ -318,7 +339,11 @@ func (idx *index) loadInfos(ctx context.Context) (err error) { } func (idx *index) IsIndexing() bool { - return idx.indexing.Load().(bool) + return idx.indexing.Load() +} + +func (idx *index) IsSaving() bool { + return idx.saving.Load() } func (idx *index) NumberOfUUIDs() uint32 { @@ -328,3 +353,14 @@ func (idx *index) NumberOfUUIDs() uint32 { func (idx *index) NumberOfUncommittedUUIDs() uint32 { return atomic.LoadUint32(&idx.uncommittedUUIDsCount) } + +func (idx *index) LoadIndexDetail() (detail *payload.Info_Index_Detail) { + detail = &payload.Info_Index_Detail{ + Counts: make(map[string]*payload.Info_Index_Count, idx.indexInfos.Len()), + } + idx.indexInfos.Range(func(addr string, info *payload.Info_Index_Count) bool { + detail.Counts[addr] = info + return true + }) + return detail +} diff --git a/pkg/manager/index/service/indexer_test.go b/pkg/manager/index/service/indexer_test.go index 40854f98d6..a4e80576c7 100644 --- a/pkg/manager/index/service/indexer_test.go +++ b/pkg/manager/index/service/indexer_test.go @@ -104,12 +104,495 @@ package service // if err := checkFunc(test.want, gotIdx, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_index_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// client discoverer.Client +// eg errgroup.Group +// creationPoolSize uint32 +// indexDuration time.Duration +// indexDurationLimit time.Duration +// saveIndexDuration time.Duration +// saveIndexDurationLimit time.Duration +// shouldSaveList sync.Map[string, struct{}] +// createIndexConcurrency int +// saveIndexConcurrency int +// indexInfos sync.Map[string, *payload.Info_Index_Count] +// indexing atomic.Bool +// saving atomic.Bool +// minUncommitted uint32 +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount: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 { +// ctx:nil, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount: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 +// } +// idx := &index{ +// client: test.fields.client, +// eg: test.fields.eg, +// creationPoolSize: test.fields.creationPoolSize, +// indexDuration: test.fields.indexDuration, +// indexDurationLimit: test.fields.indexDurationLimit, +// saveIndexDuration: test.fields.saveIndexDuration, +// saveIndexDurationLimit: test.fields.saveIndexDurationLimit, +// shouldSaveList: test.fields.shouldSaveList, +// createIndexConcurrency: test.fields.createIndexConcurrency, +// saveIndexConcurrency: test.fields.saveIndexConcurrency, +// indexInfos: test.fields.indexInfos, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// minUncommitted: test.fields.minUncommitted, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// } +// +// got, err := idx.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_index_createIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// enableLowIndexSkip bool +// } +// type fields struct { +// client discoverer.Client +// eg errgroup.Group +// creationPoolSize uint32 +// indexDuration time.Duration +// indexDurationLimit time.Duration +// saveIndexDuration time.Duration +// saveIndexDurationLimit time.Duration +// shouldSaveList sync.Map[string, struct{}] +// createIndexConcurrency int +// saveIndexConcurrency int +// indexInfos sync.Map[string, *payload.Info_Index_Count] +// indexing atomic.Bool +// saving atomic.Bool +// minUncommitted uint32 +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// } +// 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 { +// ctx:nil, +// enableLowIndexSkip:false, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount: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 { +// ctx:nil, +// enableLowIndexSkip:false, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount: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 +// } +// idx := &index{ +// client: test.fields.client, +// eg: test.fields.eg, +// creationPoolSize: test.fields.creationPoolSize, +// indexDuration: test.fields.indexDuration, +// indexDurationLimit: test.fields.indexDurationLimit, +// saveIndexDuration: test.fields.saveIndexDuration, +// saveIndexDurationLimit: test.fields.saveIndexDurationLimit, +// shouldSaveList: test.fields.shouldSaveList, +// createIndexConcurrency: test.fields.createIndexConcurrency, +// saveIndexConcurrency: test.fields.saveIndexConcurrency, +// indexInfos: test.fields.indexInfos, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// minUncommitted: test.fields.minUncommitted, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// } +// +// err := idx.createIndex(test.args.ctx, test.args.enableLowIndexSkip) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_index_saveIndex(t *testing.T) { +// type args struct { +// ctx context.Context +// force bool +// } +// type fields struct { +// client discoverer.Client +// eg errgroup.Group +// creationPoolSize uint32 +// indexDuration time.Duration +// indexDurationLimit time.Duration +// saveIndexDuration time.Duration +// saveIndexDurationLimit time.Duration +// shouldSaveList sync.Map[string, struct{}] +// createIndexConcurrency int +// saveIndexConcurrency int +// indexInfos sync.Map[string, *payload.Info_Index_Count] +// indexing atomic.Bool +// saving atomic.Bool +// minUncommitted uint32 +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// } +// 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 { +// ctx:nil, +// force:false, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount: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 { +// ctx:nil, +// force:false, +// }, +// fields: fields { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount: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 +// } +// idx := &index{ +// client: test.fields.client, +// eg: test.fields.eg, +// creationPoolSize: test.fields.creationPoolSize, +// indexDuration: test.fields.indexDuration, +// indexDurationLimit: test.fields.indexDurationLimit, +// saveIndexDuration: test.fields.saveIndexDuration, +// saveIndexDurationLimit: test.fields.saveIndexDurationLimit, +// shouldSaveList: test.fields.shouldSaveList, +// createIndexConcurrency: test.fields.createIndexConcurrency, +// saveIndexConcurrency: test.fields.saveIndexConcurrency, +// indexInfos: test.fields.indexInfos, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// minUncommitted: test.fields.minUncommitted, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// } // +// err := idx.saveIndex(test.args.ctx, test.args.force) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } // -// func Test_index_Start(t *testing.T) { +// func Test_index_loadInfos(t *testing.T) { // type args struct { // ctx context.Context // } @@ -119,37 +602,34 @@ package service // creationPoolSize uint32 // indexDuration time.Duration // indexDurationLimit time.Duration +// saveIndexDuration time.Duration // saveIndexDurationLimit time.Duration -// saveIndexWaitDuration time.Duration -// saveIndexTargetAddrCh chan string -// schMap sync.Map[string, any] -// concurrency int +// shouldSaveList sync.Map[string, struct{}] +// createIndexConcurrency int +// saveIndexConcurrency int // indexInfos sync.Map[string, *payload.Info_Index_Count] -// indexing atomic.Value +// indexing atomic.Bool +// saving atomic.Bool // minUncommitted uint32 // uuidsCount uint32 // uncommittedUUIDsCount uint32 // } // type want struct { -// want <-chan error -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, <-chan error, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got <-chan error, 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(got, w.want) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) -// } // return nil // } // tests := []test{ @@ -166,13 +646,14 @@ package service // creationPoolSize:0, // indexDuration:nil, // indexDurationLimit:nil, +// saveIndexDuration:nil, // saveIndexDurationLimit:nil, -// saveIndexWaitDuration:nil, -// saveIndexTargetAddrCh:nil, -// schMap:nil, -// concurrency:0, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, // indexInfos:nil, // indexing:nil, +// saving:nil, // minUncommitted:0, // uuidsCount:0, // uncommittedUUIDsCount:0, @@ -202,13 +683,14 @@ package service // creationPoolSize:0, // indexDuration:nil, // indexDurationLimit:nil, +// saveIndexDuration:nil, // saveIndexDurationLimit:nil, -// saveIndexWaitDuration:nil, -// saveIndexTargetAddrCh:nil, -// schMap:nil, -// concurrency:0, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, // indexInfos:nil, // indexing:nil, +// saving:nil, // minUncommitted:0, // uuidsCount:0, // uncommittedUUIDsCount:0, @@ -247,23 +729,23 @@ package service // creationPoolSize: test.fields.creationPoolSize, // indexDuration: test.fields.indexDuration, // indexDurationLimit: test.fields.indexDurationLimit, +// saveIndexDuration: test.fields.saveIndexDuration, // saveIndexDurationLimit: test.fields.saveIndexDurationLimit, -// saveIndexWaitDuration: test.fields.saveIndexWaitDuration, -// saveIndexTargetAddrCh: test.fields.saveIndexTargetAddrCh, -// schMap: test.fields.schMap, -// concurrency: test.fields.concurrency, +// shouldSaveList: test.fields.shouldSaveList, +// createIndexConcurrency: test.fields.createIndexConcurrency, +// saveIndexConcurrency: test.fields.saveIndexConcurrency, // indexInfos: test.fields.indexInfos, // indexing: test.fields.indexing, +// saving: test.fields.saving, // minUncommitted: test.fields.minUncommitted, // uuidsCount: test.fields.uuidsCount, // uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, // } // -// got, err := idx.Start(test.args.ctx) -// if err := checkFunc(test.want, got, err); err != nil { +// err := idx.loadInfos(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -275,13 +757,14 @@ package service // creationPoolSize uint32 // indexDuration time.Duration // indexDurationLimit time.Duration +// saveIndexDuration time.Duration // saveIndexDurationLimit time.Duration -// saveIndexWaitDuration time.Duration -// saveIndexTargetAddrCh chan string -// schMap sync.Map[string, any] -// concurrency int +// shouldSaveList sync.Map[string, struct{}] +// createIndexConcurrency int +// saveIndexConcurrency int // indexInfos sync.Map[string, *payload.Info_Index_Count] -// indexing atomic.Value +// indexing atomic.Bool +// saving atomic.Bool // minUncommitted uint32 // uuidsCount uint32 // uncommittedUUIDsCount uint32 @@ -314,13 +797,14 @@ package service // creationPoolSize:0, // indexDuration:nil, // indexDurationLimit:nil, +// saveIndexDuration:nil, // saveIndexDurationLimit:nil, -// saveIndexWaitDuration:nil, -// saveIndexTargetAddrCh:nil, -// schMap:nil, -// concurrency:0, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, // indexInfos:nil, // indexing:nil, +// saving:nil, // minUncommitted:0, // uuidsCount:0, // uncommittedUUIDsCount:0, @@ -347,13 +831,14 @@ package service // creationPoolSize:0, // indexDuration:nil, // indexDurationLimit:nil, +// saveIndexDuration:nil, // saveIndexDurationLimit:nil, -// saveIndexWaitDuration:nil, -// saveIndexTargetAddrCh:nil, -// schMap:nil, -// concurrency:0, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, // indexInfos:nil, // indexing:nil, +// saving:nil, // minUncommitted:0, // uuidsCount:0, // uncommittedUUIDsCount:0, @@ -392,13 +877,14 @@ package service // creationPoolSize: test.fields.creationPoolSize, // indexDuration: test.fields.indexDuration, // indexDurationLimit: test.fields.indexDurationLimit, +// saveIndexDuration: test.fields.saveIndexDuration, // saveIndexDurationLimit: test.fields.saveIndexDurationLimit, -// saveIndexWaitDuration: test.fields.saveIndexWaitDuration, -// saveIndexTargetAddrCh: test.fields.saveIndexTargetAddrCh, -// schMap: test.fields.schMap, -// concurrency: test.fields.concurrency, +// shouldSaveList: test.fields.shouldSaveList, +// createIndexConcurrency: test.fields.createIndexConcurrency, +// saveIndexConcurrency: test.fields.saveIndexConcurrency, // indexInfos: test.fields.indexInfos, // indexing: test.fields.indexing, +// saving: test.fields.saving, // minUncommitted: test.fields.minUncommitted, // uuidsCount: test.fields.uuidsCount, // uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, @@ -408,7 +894,154 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_index_IsSaving(t *testing.T) { +// type fields struct { +// client discoverer.Client +// eg errgroup.Group +// creationPoolSize uint32 +// indexDuration time.Duration +// indexDurationLimit time.Duration +// saveIndexDuration time.Duration +// saveIndexDurationLimit time.Duration +// shouldSaveList sync.Map[string, struct{}] +// createIndexConcurrency int +// saveIndexConcurrency int +// indexInfos sync.Map[string, *payload.Info_Index_Count] +// indexing atomic.Bool +// saving atomic.Bool +// minUncommitted uint32 +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// } +// type want struct { +// want bool +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, bool) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got bool) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// }, +// 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 { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// }, +// 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 +// } +// idx := &index{ +// client: test.fields.client, +// eg: test.fields.eg, +// creationPoolSize: test.fields.creationPoolSize, +// indexDuration: test.fields.indexDuration, +// indexDurationLimit: test.fields.indexDurationLimit, +// saveIndexDuration: test.fields.saveIndexDuration, +// saveIndexDurationLimit: test.fields.saveIndexDurationLimit, +// shouldSaveList: test.fields.shouldSaveList, +// createIndexConcurrency: test.fields.createIndexConcurrency, +// saveIndexConcurrency: test.fields.saveIndexConcurrency, +// indexInfos: test.fields.indexInfos, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// minUncommitted: test.fields.minUncommitted, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// } // +// got := idx.IsSaving() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -420,13 +1053,14 @@ package service // creationPoolSize uint32 // indexDuration time.Duration // indexDurationLimit time.Duration +// saveIndexDuration time.Duration // saveIndexDurationLimit time.Duration -// saveIndexWaitDuration time.Duration -// saveIndexTargetAddrCh chan string -// schMap sync.Map[string, any] -// concurrency int +// shouldSaveList sync.Map[string, struct{}] +// createIndexConcurrency int +// saveIndexConcurrency int // indexInfos sync.Map[string, *payload.Info_Index_Count] -// indexing atomic.Value +// indexing atomic.Bool +// saving atomic.Bool // minUncommitted uint32 // uuidsCount uint32 // uncommittedUUIDsCount uint32 @@ -459,13 +1093,14 @@ package service // creationPoolSize:0, // indexDuration:nil, // indexDurationLimit:nil, +// saveIndexDuration:nil, // saveIndexDurationLimit:nil, -// saveIndexWaitDuration:nil, -// saveIndexTargetAddrCh:nil, -// schMap:nil, -// concurrency:0, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, // indexInfos:nil, // indexing:nil, +// saving:nil, // minUncommitted:0, // uuidsCount:0, // uncommittedUUIDsCount:0, @@ -492,13 +1127,14 @@ package service // creationPoolSize:0, // indexDuration:nil, // indexDurationLimit:nil, +// saveIndexDuration:nil, // saveIndexDurationLimit:nil, -// saveIndexWaitDuration:nil, -// saveIndexTargetAddrCh:nil, -// schMap:nil, -// concurrency:0, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, // indexInfos:nil, // indexing:nil, +// saving:nil, // minUncommitted:0, // uuidsCount:0, // uncommittedUUIDsCount:0, @@ -537,13 +1173,14 @@ package service // creationPoolSize: test.fields.creationPoolSize, // indexDuration: test.fields.indexDuration, // indexDurationLimit: test.fields.indexDurationLimit, +// saveIndexDuration: test.fields.saveIndexDuration, // saveIndexDurationLimit: test.fields.saveIndexDurationLimit, -// saveIndexWaitDuration: test.fields.saveIndexWaitDuration, -// saveIndexTargetAddrCh: test.fields.saveIndexTargetAddrCh, -// schMap: test.fields.schMap, -// concurrency: test.fields.concurrency, +// shouldSaveList: test.fields.shouldSaveList, +// createIndexConcurrency: test.fields.createIndexConcurrency, +// saveIndexConcurrency: test.fields.saveIndexConcurrency, // indexInfos: test.fields.indexInfos, // indexing: test.fields.indexing, +// saving: test.fields.saving, // minUncommitted: test.fields.minUncommitted, // uuidsCount: test.fields.uuidsCount, // uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, @@ -553,7 +1190,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -565,13 +1201,14 @@ package service // creationPoolSize uint32 // indexDuration time.Duration // indexDurationLimit time.Duration +// saveIndexDuration time.Duration // saveIndexDurationLimit time.Duration -// saveIndexWaitDuration time.Duration -// saveIndexTargetAddrCh chan string -// schMap sync.Map[string, any] -// concurrency int +// shouldSaveList sync.Map[string, struct{}] +// createIndexConcurrency int +// saveIndexConcurrency int // indexInfos sync.Map[string, *payload.Info_Index_Count] -// indexing atomic.Value +// indexing atomic.Bool +// saving atomic.Bool // minUncommitted uint32 // uuidsCount uint32 // uncommittedUUIDsCount uint32 @@ -604,13 +1241,14 @@ package service // creationPoolSize:0, // indexDuration:nil, // indexDurationLimit:nil, +// saveIndexDuration:nil, // saveIndexDurationLimit:nil, -// saveIndexWaitDuration:nil, -// saveIndexTargetAddrCh:nil, -// schMap:nil, -// concurrency:0, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, // indexInfos:nil, // indexing:nil, +// saving:nil, // minUncommitted:0, // uuidsCount:0, // uncommittedUUIDsCount:0, @@ -637,13 +1275,14 @@ package service // creationPoolSize:0, // indexDuration:nil, // indexDurationLimit:nil, +// saveIndexDuration:nil, // saveIndexDurationLimit:nil, -// saveIndexWaitDuration:nil, -// saveIndexTargetAddrCh:nil, -// schMap:nil, -// concurrency:0, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, // indexInfos:nil, // indexing:nil, +// saving:nil, // minUncommitted:0, // uuidsCount:0, // uncommittedUUIDsCount:0, @@ -682,13 +1321,14 @@ package service // creationPoolSize: test.fields.creationPoolSize, // indexDuration: test.fields.indexDuration, // indexDurationLimit: test.fields.indexDurationLimit, +// saveIndexDuration: test.fields.saveIndexDuration, // saveIndexDurationLimit: test.fields.saveIndexDurationLimit, -// saveIndexWaitDuration: test.fields.saveIndexWaitDuration, -// saveIndexTargetAddrCh: test.fields.saveIndexTargetAddrCh, -// schMap: test.fields.schMap, -// concurrency: test.fields.concurrency, +// shouldSaveList: test.fields.shouldSaveList, +// createIndexConcurrency: test.fields.createIndexConcurrency, +// saveIndexConcurrency: test.fields.saveIndexConcurrency, // indexInfos: test.fields.indexInfos, // indexing: test.fields.indexing, +// saving: test.fields.saving, // minUncommitted: test.fields.minUncommitted, // uuidsCount: test.fields.uuidsCount, // uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, @@ -698,7 +1338,154 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_index_LoadIndexDetail(t *testing.T) { +// type fields struct { +// client discoverer.Client +// eg errgroup.Group +// creationPoolSize uint32 +// indexDuration time.Duration +// indexDurationLimit time.Duration +// saveIndexDuration time.Duration +// saveIndexDurationLimit time.Duration +// shouldSaveList sync.Map[string, struct{}] +// createIndexConcurrency int +// saveIndexConcurrency int +// indexInfos sync.Map[string, *payload.Info_Index_Count] +// indexing atomic.Bool +// saving atomic.Bool +// minUncommitted uint32 +// uuidsCount uint32 +// uncommittedUUIDsCount uint32 +// } +// type want struct { +// wantDetail *payload.Info_Index_Detail +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *payload.Info_Index_Detail) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, gotDetail *payload.Info_Index_Detail) error { +// if !reflect.DeepEqual(gotDetail, w.wantDetail) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotDetail, w.wantDetail) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// }, +// 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 { +// client:nil, +// eg:nil, +// creationPoolSize:0, +// indexDuration:nil, +// indexDurationLimit:nil, +// saveIndexDuration:nil, +// saveIndexDurationLimit:nil, +// shouldSaveList:nil, +// createIndexConcurrency:0, +// saveIndexConcurrency:0, +// indexInfos:nil, +// indexing:nil, +// saving:nil, +// minUncommitted:0, +// uuidsCount:0, +// uncommittedUUIDsCount:0, +// }, +// 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 +// } +// idx := &index{ +// client: test.fields.client, +// eg: test.fields.eg, +// creationPoolSize: test.fields.creationPoolSize, +// indexDuration: test.fields.indexDuration, +// indexDurationLimit: test.fields.indexDurationLimit, +// saveIndexDuration: test.fields.saveIndexDuration, +// saveIndexDurationLimit: test.fields.saveIndexDurationLimit, +// shouldSaveList: test.fields.shouldSaveList, +// createIndexConcurrency: test.fields.createIndexConcurrency, +// saveIndexConcurrency: test.fields.saveIndexConcurrency, +// indexInfos: test.fields.indexInfos, +// indexing: test.fields.indexing, +// saving: test.fields.saving, +// minUncommitted: test.fields.minUncommitted, +// uuidsCount: test.fields.uuidsCount, +// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount, +// } // +// gotDetail := idx.LoadIndexDetail() +// if err := checkFunc(test.want, gotDetail); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/manager/index/service/option.go b/pkg/manager/index/service/option.go index c3fffb7dc2..ec6b76d662 100644 --- a/pkg/manager/index/service/option.go +++ b/pkg/manager/index/service/option.go @@ -31,7 +31,6 @@ var defaultOptions = []Option{ WithIndexingDuration("1m"), WithIndexingDurationLimit("30m"), WithSaveIndexDurationLimit("3h"), - WithSaveIndexWaitDuration("10m"), WithMinUncommitted(100), WithCreationPoolSize(10000), } @@ -39,27 +38,22 @@ var defaultOptions = []Option{ func WithIndexingConcurrency(c int) Option { return func(idx *index) error { if c != 0 { - idx.concurrency = c + idx.createIndexConcurrency = c } return nil } } -func WithIndexingDuration(dur string) Option { +func WithSaveConcurrency(c int) Option { return func(idx *index) error { - if dur == "" { - return nil - } - d, err := timeutil.Parse(dur) - if err != nil { - return err + if c != 0 { + idx.saveIndexConcurrency = c } - idx.indexDuration = d return nil } } -func WithIndexingDurationLimit(dur string) Option { +func WithIndexingDuration(dur string) Option { return func(idx *index) error { if dur == "" { return nil @@ -68,12 +62,12 @@ func WithIndexingDurationLimit(dur string) Option { if err != nil { return err } - idx.indexDurationLimit = d + idx.indexDuration = d return nil } } -func WithSaveIndexDurationLimit(dur string) Option { +func WithIndexingDurationLimit(dur string) Option { return func(idx *index) error { if dur == "" { return nil @@ -82,12 +76,12 @@ func WithSaveIndexDurationLimit(dur string) Option { if err != nil { return err } - idx.saveIndexDurationLimit = d + idx.indexDurationLimit = d return nil } } -func WithSaveIndexWaitDuration(dur string) Option { +func WithSaveIndexDurationLimit(dur string) Option { return func(idx *index) error { if dur == "" { return nil @@ -96,7 +90,7 @@ func WithSaveIndexWaitDuration(dur string) Option { if err != nil { return err } - idx.saveIndexWaitDuration = d + idx.saveIndexDurationLimit = d return nil } } diff --git a/pkg/manager/index/service/option_test.go b/pkg/manager/index/service/option_test.go index 455c00e64f..833cc3209d 100644 --- a/pkg/manager/index/service/option_test.go +++ b/pkg/manager/index/service/option_test.go @@ -100,14 +100,13 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func TestWithIndexingDuration(t *testing.T) { +// func TestWithSaveConcurrency(t *testing.T) { // type args struct { -// dur string +// c int // } // type want struct { // want Option @@ -132,7 +131,7 @@ package service // { // name: "test_case_1", // args: args { -// dur:"", +// c:0, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -151,7 +150,7 @@ package service // return test { // name: "test_case_2", // args: args { -// dur:"", +// c:0, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -182,16 +181,15 @@ package service // checkFunc = defaultCheckFunc // } // -// got := WithIndexingDuration(test.args.dur) +// got := WithSaveConcurrency(test.args.c) // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func TestWithIndexingDurationLimit(t *testing.T) { +// func TestWithIndexingDuration(t *testing.T) { // type args struct { // dur string // } @@ -268,16 +266,15 @@ package service // checkFunc = defaultCheckFunc // } // -// got := WithIndexingDurationLimit(test.args.dur) +// got := WithIndexingDuration(test.args.dur) // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func TestWithSaveIndexDurationLimit(t *testing.T) { +// func TestWithIndexingDurationLimit(t *testing.T) { // type args struct { // dur string // } @@ -354,16 +351,15 @@ package service // checkFunc = defaultCheckFunc // } // -// got := WithSaveIndexDurationLimit(test.args.dur) +// got := WithIndexingDurationLimit(test.args.dur) // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func TestWithSaveIndexWaitDuration(t *testing.T) { +// func TestWithSaveIndexDurationLimit(t *testing.T) { // type args struct { // dur string // } @@ -440,11 +436,10 @@ package service // checkFunc = defaultCheckFunc // } // -// got := WithSaveIndexWaitDuration(test.args.dur) +// got := WithSaveIndexDurationLimit(test.args.dur) // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -530,7 +525,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -616,7 +610,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -702,7 +695,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -788,7 +780,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/manager/index/usecase/indexer.go b/pkg/manager/index/usecase/indexer.go index a891fc487f..0591b32123 100644 --- a/pkg/manager/index/usecase/indexer.go +++ b/pkg/manager/index/usecase/indexer.go @@ -19,7 +19,7 @@ package usecase import ( "context" - "github.com/vdaas/vald/apis/grpc/v1/manager/index" + index "github.com/vdaas/vald/apis/grpc/v1/vald" "github.com/vdaas/vald/internal/client/v1/client/discoverer" iconf "github.com/vdaas/vald/internal/config" "github.com/vdaas/vald/internal/net/grpc" @@ -98,7 +98,6 @@ func New(cfg *config.Data) (r runner.Runner, err error) { service.WithIndexingDuration(cfg.Indexer.AutoIndexCheckDuration), service.WithIndexingDurationLimit(cfg.Indexer.AutoIndexDurationLimit), service.WithSaveIndexDurationLimit(cfg.Indexer.AutoSaveIndexDurationLimit), - service.WithSaveIndexWaitDuration(cfg.Indexer.AutoSaveIndexWaitDuration), service.WithCreationPoolSize(cfg.Indexer.CreationPoolSize), service.WithMinUncommitted(cfg.Indexer.AutoIndexLength), ) diff --git a/pkg/manager/index/usecase/indexer_test.go b/pkg/manager/index/usecase/indexer_test.go index 483e3950e7..9a19fcc5e4 100644 --- a/pkg/manager/index/usecase/indexer_test.go +++ b/pkg/manager/index/usecase/indexer_test.go @@ -103,7 +103,580 @@ package usecase // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// indexer service.Indexer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// indexer: test.fields.indexer, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// indexer service.Indexer +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// indexer: test.fields.indexer, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// indexer service.Indexer +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// indexer: test.fields.indexer, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// indexer service.Indexer +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// indexer: test.fields.indexer, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Data +// server starter.Server +// observability observability.Observability +// indexer service.Indexer +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// server:nil, +// observability:nil, +// indexer: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// server: test.fields.server, +// observability: test.fields.observability, +// indexer: test.fields.indexer, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/tools/benchmark/job/config/config_test.go b/pkg/tools/benchmark/job/config/config_test.go index facad92568..a69716a0f4 100644 --- a/pkg/tools/benchmark/job/config/config_test.go +++ b/pkg/tools/benchmark/job/config/config_test.go @@ -106,3 +106,5 @@ func TestNewConfig(t *testing.T) { }) } } + +// NOT IMPLEMENTED BELOW diff --git a/pkg/tools/benchmark/job/handler/grpc/handler_test.go b/pkg/tools/benchmark/job/handler/grpc/handler_test.go new file mode 100644 index 0000000000..3b50d59c42 --- /dev/null +++ b/pkg/tools/benchmark/job/handler/grpc/handler_test.go @@ -0,0 +1,198 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// wantBm Benchmark +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Benchmark, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotBm Benchmark, 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(gotBm, w.wantBm) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotBm, w.wantBm) +// } +// 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 +// } +// +// gotBm, err := New(test.args.opts...) +// if err := checkFunc(test.want, gotBm, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// job service.Job +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// job: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 { +// ctx:nil, +// }, +// fields: fields { +// job: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 +// } +// s := &server{ +// job: test.fields.job, +// } +// +// s.Start(test.args.ctx) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/handler/rest/handler.go b/pkg/tools/benchmark/job/handler/rest/handler.go index 1de5069055..091b03c422 100644 --- a/pkg/tools/benchmark/job/handler/rest/handler.go +++ b/pkg/tools/benchmark/job/handler/rest/handler.go @@ -17,7 +17,7 @@ // Package rest provides rest api logic package rest -type Handler interface{} +type Handler any type handler struct{} diff --git a/pkg/tools/benchmark/job/handler/rest/handler_test.go b/pkg/tools/benchmark/job/handler/rest/handler_test.go new file mode 100644 index 0000000000..5fae0a75a7 --- /dev/null +++ b/pkg/tools/benchmark/job/handler/rest/handler_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/router/option_test.go b/pkg/tools/benchmark/job/router/option_test.go new file mode 100644 index 0000000000..42e073651c --- /dev/null +++ b/pkg/tools/benchmark/job/router/option_test.go @@ -0,0 +1,271 @@ +// 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 router + +// NOT IMPLEMENTED BELOW +// +// func TestWithHandler(t *testing.T) { +// type args struct { +// h rest.Handler +// } +// 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 { +// h: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 { +// h: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 := WithHandler(test.args.h) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTimeout(t *testing.T) { +// type args struct { +// timeout 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 { +// timeout:"", +// }, +// 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 { +// timeout:"", +// }, +// 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 := WithTimeout(test.args.timeout) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/router/router_test.go b/pkg/tools/benchmark/job/router/router_test.go new file mode 100644 index 0000000000..e9e3069588 --- /dev/null +++ b/pkg/tools/benchmark/job/router/router_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 router + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want http.Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, http.Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got http.Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/service/insert_test.go b/pkg/tools/benchmark/job/service/insert_test.go new file mode 100644 index 0000000000..c007886fd2 --- /dev/null +++ b/pkg/tools/benchmark/job/service/insert_test.go @@ -0,0 +1,197 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func Test_job_insert(t *testing.T) { +// type args struct { +// ctx context.Context +// ech chan error +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// 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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// err := j.insert(test.args.ctx, test.args.ech) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/service/job_test.go b/pkg/tools/benchmark/job/service/job_test.go new file mode 100644 index 0000000000..d5a9170c9c --- /dev/null +++ b/pkg/tools/benchmark/job/service/job_test.go @@ -0,0 +1,892 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func Test_jobType_String(t *testing.T) { +// type want struct { +// want string +// } +// type test struct { +// name string +// jt jobType +// 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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// 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 +// } +// +// got := test.jt.String() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Job +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Job, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Job, 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 Test_job_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// err := j.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_job_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// got, err := j.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_job_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// err := j.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_calcRecall(t *testing.T) { +// type args struct { +// linearRes *payload.Search_Response +// searchRes *payload.Search_Response +// } +// type want struct { +// wantRecall float64 +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, float64) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotRecall float64) error { +// if !reflect.DeepEqual(gotRecall, w.wantRecall) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRecall, w.wantRecall) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// linearRes:nil, +// searchRes: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 { +// linearRes:nil, +// searchRes: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 +// } +// +// gotRecall := calcRecall(test.args.linearRes, test.args.searchRes) +// if err := checkFunc(test.want, gotRecall); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_addNoiseToVec(t *testing.T) { +// type args struct { +// oVec []float32 +// } +// type want struct { +// want []float32 +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, []float32) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got []float32) 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 { +// oVec: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 { +// oVec: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 := addNoiseToVec(test.args.oVec) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/service/object_test.go b/pkg/tools/benchmark/job/service/object_test.go new file mode 100644 index 0000000000..9fbdb3aab4 --- /dev/null +++ b/pkg/tools/benchmark/job/service/object_test.go @@ -0,0 +1,378 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func Test_job_exists(t *testing.T) { +// type args struct { +// ctx context.Context +// ech chan error +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// 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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// err := j.exists(test.args.ctx, test.args.ech) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_job_getObject(t *testing.T) { +// type args struct { +// ctx context.Context +// ech chan error +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// 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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// err := j.getObject(test.args.ctx, test.args.ech) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/service/option.go b/pkg/tools/benchmark/job/service/option.go index 4b0fb7e459..f0a1764d9d 100644 --- a/pkg/tools/benchmark/job/service/option.go +++ b/pkg/tools/benchmark/job/service/option.go @@ -130,7 +130,8 @@ func WithHdf5(d hdf5.Data) Option { } } -// WithDataset sets the config.BenchmarkDataset including benchmark dataset name, group name of hdf5.Data, the number of index, start range and end range, and original URL which is used for download user defined hdf5. +// WithDataset sets the config.BenchmarkDataset including benchmark dataset name, group name of hdf5.Data, the number of index, start range and end range, and +// original URL which is used for download user defined hdf5. func WithDataset(d *config.BenchmarkDataset) Option { return func(j *job) error { if d == nil { diff --git a/pkg/tools/benchmark/job/service/option_test.go b/pkg/tools/benchmark/job/service/option_test.go new file mode 100644 index 0000000000..53d87247df --- /dev/null +++ b/pkg/tools/benchmark/job/service/option_test.go @@ -0,0 +1,1631 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func TestWithInsertConfig(t *testing.T) { +// type args struct { +// c *config.InsertConfig +// } +// 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 { +// 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 := WithInsertConfig(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithUpdateConfig(t *testing.T) { +// type args struct { +// c *config.UpdateConfig +// } +// 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 { +// 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 := WithUpdateConfig(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithUpsertConfig(t *testing.T) { +// type args struct { +// c *config.UpsertConfig +// } +// 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 { +// 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 := WithUpsertConfig(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithSearchConfig(t *testing.T) { +// type args struct { +// c *config.SearchConfig +// } +// 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 { +// 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 := WithSearchConfig(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithRemoveConfig(t *testing.T) { +// type args struct { +// c *config.RemoveConfig +// } +// 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 { +// 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 := WithRemoveConfig(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithObjectConfig(t *testing.T) { +// type args struct { +// c *config.ObjectConfig +// } +// 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 { +// 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 := WithObjectConfig(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithValdClient(t *testing.T) { +// type args struct { +// c vald.Client +// } +// 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 { +// 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 := WithValdClient(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithHdf5(t *testing.T) { +// type args struct { +// d hdf5.Data +// } +// 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 { +// d: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 { +// d: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 := WithHdf5(test.args.d) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDataset(t *testing.T) { +// type args struct { +// d *config.BenchmarkDataset +// } +// 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 { +// d: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 { +// d: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 := WithDataset(test.args.d) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithJobTypeByString(t *testing.T) { +// type args struct { +// t 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 { +// t:"", +// }, +// 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 { +// t:"", +// }, +// 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 := WithJobTypeByString(test.args.t) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithJobType(t *testing.T) { +// type args struct { +// jt jobType +// } +// 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 { +// jt: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 { +// jt: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 := WithJobType(test.args.jt) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithJobFunc(t *testing.T) { +// type args struct { +// jf func(context.Context, chan error) error +// } +// 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 { +// jf: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 { +// jf: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 := WithJobFunc(test.args.jf) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithBeforeJobName(t *testing.T) { +// type args struct { +// bjn 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 { +// bjn:"", +// }, +// 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 { +// bjn:"", +// }, +// 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 := WithBeforeJobName(test.args.bjn) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithBeforeJobNamespace(t *testing.T) { +// type args struct { +// bjns 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 { +// bjns:"", +// }, +// 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 { +// bjns:"", +// }, +// 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 := WithBeforeJobNamespace(test.args.bjns) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithBeforeJobDuration(t *testing.T) { +// type args struct { +// dur 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 { +// dur:"", +// }, +// 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 { +// dur:"", +// }, +// 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 := WithBeforeJobDuration(test.args.dur) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithK8sClient(t *testing.T) { +// type args struct { +// cli client.Client +// } +// 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 { +// cli: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 { +// cli: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 := WithK8sClient(test.args.cli) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithRPS(t *testing.T) { +// type args struct { +// rps 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 { +// rps: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 { +// rps: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 := WithRPS(test.args.rps) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithConcurencyLimit(t *testing.T) { +// type args struct { +// limit 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 { +// limit: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 { +// limit: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 := WithConcurencyLimit(test.args.limit) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/service/remove_test.go b/pkg/tools/benchmark/job/service/remove_test.go new file mode 100644 index 0000000000..c3d3412389 --- /dev/null +++ b/pkg/tools/benchmark/job/service/remove_test.go @@ -0,0 +1,197 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func Test_job_remove(t *testing.T) { +// type args struct { +// ctx context.Context +// ech chan error +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// 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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// err := j.remove(test.args.ctx, test.args.ech) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/service/search_test.go b/pkg/tools/benchmark/job/service/search_test.go new file mode 100644 index 0000000000..2de062dabf --- /dev/null +++ b/pkg/tools/benchmark/job/service/search_test.go @@ -0,0 +1,197 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func Test_job_search(t *testing.T) { +// type args struct { +// ctx context.Context +// ech chan error +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// 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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// err := j.search(test.args.ctx, test.args.ech) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/service/update_test.go b/pkg/tools/benchmark/job/service/update_test.go new file mode 100644 index 0000000000..f7b86ed04a --- /dev/null +++ b/pkg/tools/benchmark/job/service/update_test.go @@ -0,0 +1,197 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func Test_job_update(t *testing.T) { +// type args struct { +// ctx context.Context +// ech chan error +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// 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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// err := j.update(test.args.ctx, test.args.ech) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/service/upsert_test.go b/pkg/tools/benchmark/job/service/upsert_test.go new file mode 100644 index 0000000000..4c798f9e13 --- /dev/null +++ b/pkg/tools/benchmark/job/service/upsert_test.go @@ -0,0 +1,197 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func Test_job_upsert(t *testing.T) { +// type args struct { +// ctx context.Context +// ech chan error +// } +// type fields struct { +// eg errgroup.Group +// dataset *config.BenchmarkDataset +// jobType jobType +// jobFunc func(context.Context, chan error) error +// insertConfig *config.InsertConfig +// updateConfig *config.UpdateConfig +// upsertConfig *config.UpsertConfig +// searchConfig *config.SearchConfig +// removeConfig *config.RemoveConfig +// objectConfig *config.ObjectConfig +// client vald.Client +// hdf5 hdf5.Data +// beforeJobName string +// beforeJobNamespace string +// k8sClient client.Client +// beforeJobDur time.Duration +// limiter rate.Limiter +// rps int +// concurrencyLimit int +// timeout time.Duration +// timestamp int64 +// } +// 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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 { +// ctx:nil, +// ech:nil, +// }, +// fields: fields { +// eg:nil, +// dataset:nil, +// jobType:nil, +// jobFunc:nil, +// insertConfig:nil, +// updateConfig:nil, +// upsertConfig:nil, +// searchConfig:nil, +// removeConfig:nil, +// objectConfig:nil, +// client:nil, +// hdf5:nil, +// beforeJobName:"", +// beforeJobNamespace:"", +// k8sClient:nil, +// beforeJobDur:nil, +// limiter:nil, +// rps:0, +// concurrencyLimit:0, +// timeout:nil, +// timestamp: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 +// } +// j := &job{ +// eg: test.fields.eg, +// dataset: test.fields.dataset, +// jobType: test.fields.jobType, +// jobFunc: test.fields.jobFunc, +// insertConfig: test.fields.insertConfig, +// updateConfig: test.fields.updateConfig, +// upsertConfig: test.fields.upsertConfig, +// searchConfig: test.fields.searchConfig, +// removeConfig: test.fields.removeConfig, +// objectConfig: test.fields.objectConfig, +// client: test.fields.client, +// hdf5: test.fields.hdf5, +// beforeJobName: test.fields.beforeJobName, +// beforeJobNamespace: test.fields.beforeJobNamespace, +// k8sClient: test.fields.k8sClient, +// beforeJobDur: test.fields.beforeJobDur, +// limiter: test.fields.limiter, +// rps: test.fields.rps, +// concurrencyLimit: test.fields.concurrencyLimit, +// timeout: test.fields.timeout, +// timestamp: test.fields.timestamp, +// } +// +// err := j.upsert(test.args.ctx, test.args.ech) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/job/usecase/benchmarkd_test.go b/pkg/tools/benchmark/job/usecase/benchmarkd_test.go new file mode 100644 index 0000000000..aaec5fc90a --- /dev/null +++ b/pkg/tools/benchmark/job/usecase/benchmarkd_test.go @@ -0,0 +1,699 @@ +// 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 usecase + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// cfg *config.Config +// } +// type want struct { +// wantR runner.Runner +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, runner.Runner, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotR runner.Runner, 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(gotR, w.wantR) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotR, w.wantR) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// cfg: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 { +// cfg: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 +// } +// +// gotR, err := New(test.args.cfg) +// if err := checkFunc(test.want, gotR, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// job service.Job +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// job: test.fields.job, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// job service.Job +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// job: test.fields.job, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// job service.Job +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// job: test.fields.job, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PreStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// job service.Job +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// job: test.fields.job, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// job service.Job +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// job:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// job: test.fields.job, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PostStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/operator/config/config.go b/pkg/tools/benchmark/operator/config/config.go index 29c2ad522e..6881ff91e8 100644 --- a/pkg/tools/benchmark/operator/config/config.go +++ b/pkg/tools/benchmark/operator/config/config.go @@ -17,9 +17,7 @@ // Package config stores all server application settings package config -import ( - "github.com/vdaas/vald/internal/config" -) +import "github.com/vdaas/vald/internal/config" // GlobalConfig is type alias for config.GlobalConfig. type GlobalConfig = config.GlobalConfig diff --git a/pkg/tools/benchmark/operator/config/config_test.go b/pkg/tools/benchmark/operator/config/config_test.go new file mode 100644 index 0000000000..6424dcee87 --- /dev/null +++ b/pkg/tools/benchmark/operator/config/config_test.go @@ -0,0 +1,105 @@ +// 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 config + +// NOT IMPLEMENTED BELOW +// +// func TestNewConfig(t *testing.T) { +// type args struct { +// path string +// } +// type want struct { +// wantCfg *Config +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, *Config, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotCfg *Config, 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(gotCfg, w.wantCfg) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotCfg, w.wantCfg) +// } +// 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 +// } +// +// gotCfg, err := NewConfig(test.args.path) +// if err := checkFunc(test.want, gotCfg, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/operator/handler/grpc/handler_test.go b/pkg/tools/benchmark/operator/handler/grpc/handler_test.go new file mode 100644 index 0000000000..642123ce1d --- /dev/null +++ b/pkg/tools/benchmark/operator/handler/grpc/handler_test.go @@ -0,0 +1,198 @@ +// 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 grpc + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// wantBm Benchmark +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Benchmark, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotBm Benchmark, 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(gotBm, w.wantBm) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotBm, w.wantBm) +// } +// 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 +// } +// +// gotBm, err := New(test.args.opts...) +// if err := checkFunc(test.want, gotBm, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_server_Start(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// Operator service.Operator +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// Operator: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 { +// in0:nil, +// }, +// fields: fields { +// Operator: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 +// } +// s := &server{ +// Operator: test.fields.Operator, +// } +// +// s.Start(test.args.in0) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/operator/handler/rest/handler.go b/pkg/tools/benchmark/operator/handler/rest/handler.go index 1de5069055..091b03c422 100644 --- a/pkg/tools/benchmark/operator/handler/rest/handler.go +++ b/pkg/tools/benchmark/operator/handler/rest/handler.go @@ -17,7 +17,7 @@ // Package rest provides rest api logic package rest -type Handler interface{} +type Handler any type handler struct{} diff --git a/pkg/tools/benchmark/operator/handler/rest/handler_test.go b/pkg/tools/benchmark/operator/handler/rest/handler_test.go new file mode 100644 index 0000000000..5fae0a75a7 --- /dev/null +++ b/pkg/tools/benchmark/operator/handler/rest/handler_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 rest + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/operator/router/option_test.go b/pkg/tools/benchmark/operator/router/option_test.go new file mode 100644 index 0000000000..42e073651c --- /dev/null +++ b/pkg/tools/benchmark/operator/router/option_test.go @@ -0,0 +1,271 @@ +// 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 router + +// NOT IMPLEMENTED BELOW +// +// func TestWithHandler(t *testing.T) { +// type args struct { +// h rest.Handler +// } +// 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 { +// h: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 { +// h: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 := WithHandler(test.args.h) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithTimeout(t *testing.T) { +// type args struct { +// timeout 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 { +// timeout:"", +// }, +// 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 { +// timeout:"", +// }, +// 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 := WithTimeout(test.args.timeout) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/operator/router/router_test.go b/pkg/tools/benchmark/operator/router/router_test.go new file mode 100644 index 0000000000..e9e3069588 --- /dev/null +++ b/pkg/tools/benchmark/operator/router/router_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 router + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want http.Handler +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, http.Handler) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got http.Handler) 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 { +// 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 := New(test.args.opts...) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/operator/service/operator.go b/pkg/tools/benchmark/operator/service/operator.go index 438967f1fa..187673d527 100644 --- a/pkg/tools/benchmark/operator/service/operator.go +++ b/pkg/tools/benchmark/operator/service/operator.go @@ -237,7 +237,9 @@ func (o *operator) jobReconcile(ctx context.Context, jobList map[string][]k8s.Jo // benchJobReconcile gets the vald benchmark job resource list and create Job for running benchmark job. // skipcq: GO-R1005 -func (o *operator) benchJobReconcile(ctx context.Context, benchJobList map[string]v1.ValdBenchmarkJob) { +func (o *operator) benchJobReconcile( + ctx context.Context, benchJobList map[string]v1.ValdBenchmarkJob, +) { log.Debugf("[reconcile benchmark job resource] job list: %#v", benchJobList) cbjl := o.getAtomicBenchJob() if cbjl == nil { @@ -315,7 +317,9 @@ func (o *operator) benchJobReconcile(ctx context.Context, benchJobList map[strin } // benchScenarioReconcile gets the vald benchmark scenario list and create vald benchmark job resource according to it. -func (o *operator) benchScenarioReconcile(ctx context.Context, scenarioList map[string]v1.ValdBenchmarkScenario) { +func (o *operator) benchScenarioReconcile( + ctx context.Context, scenarioList map[string]v1.ValdBenchmarkScenario, +) { log.Debugf("[reconcile benchmark scenario resource] scenario list: %#v", scenarioList) cbsl := o.getAtomicScenario() if cbsl == nil { @@ -422,7 +426,9 @@ func (o *operator) deleteJob(ctx context.Context, name string) error { } // createBenchmarkJob creates the ValdBenchmarkJob crd for running job. -func (o *operator) createBenchmarkJob(ctx context.Context, scenario v1.ValdBenchmarkScenario) ([]string, error) { +func (o *operator) createBenchmarkJob( + ctx context.Context, scenario v1.ValdBenchmarkScenario, +) ([]string, error) { ownerRef := []k8s.OwnerReference{ { APIVersion: scenario.APIVersion, @@ -514,7 +520,9 @@ func (o *operator) createJob(ctx context.Context, bjr v1.ValdBenchmarkJob) error } // updateBenchmarkScenarioStatus updates status of ValdBenchmarkScenarioResource. -func (o *operator) updateBenchmarkScenarioStatus(ctx context.Context, ss map[string]v1.ValdBenchmarkScenarioStatus) ([]string, error) { +func (o *operator) updateBenchmarkScenarioStatus( + ctx context.Context, ss map[string]v1.ValdBenchmarkScenarioStatus, +) ([]string, error) { var sns []string if cbsl := o.getAtomicScenario(); cbsl != nil { for name, status := range ss { @@ -537,7 +545,9 @@ func (o *operator) updateBenchmarkScenarioStatus(ctx context.Context, ss map[str } // updateBenchmarkJobStatus updates status of ValdBenchmarkJobResource. -func (o *operator) updateBenchmarkJobStatus(ctx context.Context, js map[string]v1.BenchmarkJobStatus) ([]string, error) { +func (o *operator) updateBenchmarkJobStatus( + ctx context.Context, js map[string]v1.BenchmarkJobStatus, +) ([]string, error) { var jns []string if cbjl := o.getAtomicBenchJob(); cbjl != nil { for name, status := range js { diff --git a/pkg/tools/benchmark/operator/service/operator_test.go b/pkg/tools/benchmark/operator/service/operator_test.go index 0510f078a2..1e2e0abba5 100644 --- a/pkg/tools/benchmark/operator/service/operator_test.go +++ b/pkg/tools/benchmark/operator/service/operator_test.go @@ -16,7 +16,6 @@ package service import ( "context" "reflect" - "strings" "sync/atomic" "testing" "time" @@ -25,6 +24,7 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/k8s" v1 "github.com/vdaas/vald/internal/k8s/vald/benchmark/api/v1" + "github.com/vdaas/vald/internal/strings" "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/internal/test/mock" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -3120,6 +3120,7 @@ func Test_operator_checkAtomics(t *testing.T) { } // NOT IMPLEMENTED BELOW +// // func TestNew(t *testing.T) { // type args struct { // opts []Option @@ -3147,30 +3148,22 @@ func Test_operator_checkAtomics(t *testing.T) { // } // tests := []test{ // // TODO test cases -// // { -// // name: "test_case_1", -// // args: args{ -// // opts: nil, -// // }, -// // want: want{ -// // want: func() Operator { -// // o := &operator{ -// // jobNamespace: "default", -// // jobImageRepository: "vdaas/vald-benchmark-job", -// // jobImagePullPolicy: "Always", -// // rcd: 10 * time.Second, -// // } -// // return o -// // }(), -// // }, -// // checkFunc: defaultCheckFunc, -// // beforeFunc: func(t *testing.T, args args) { -// // t.Helper() -// // }, -// // afterFunc: func(t *testing.T, args args) { -// // t.Helper() -// // }, -// // }, +// /* +// { +// 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 // /* @@ -3216,19 +3209,17 @@ func Test_operator_checkAtomics(t *testing.T) { // }) // } // } - // -// func Test_operator_PreStart(t *testing.T) { -// type args struct { -// ctx context.Context -// } +// func Test_operator_initCtrl(t *testing.T) { // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller @@ -3238,12 +3229,11 @@ func Test_operator_checkAtomics(t *testing.T) { // } // 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) { @@ -3256,13 +3246,12 @@ func Test_operator_checkAtomics(t *testing.T) { // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3272,10 +3261,10 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // 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() // }, // }, @@ -3286,13 +3275,12 @@ func Test_operator_checkAtomics(t *testing.T) { // func() test { // return test { // name: "test_case_2", -// args: args { -// ctx:nil, -// }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3302,10 +3290,10 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // 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() // }, // } @@ -3319,10 +3307,10 @@ func Test_operator_checkAtomics(t *testing.T) { // 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 { @@ -3330,8 +3318,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -3340,50 +3330,49 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// err := o.PreStart(test.args.ctx) +// err := o.initCtrl() // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } // -// func Test_operator_Start(t *testing.T) { +// func Test_operator_deleteBenchmarkJob(t *testing.T) { // type args struct { -// ctx context.Context +// ctx context.Context +// name string +// generation int64 // } // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller // } // type want struct { -// want <-chan error -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, <-chan error, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got <-chan error, 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(got, w.want) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) -// } // return nil // } // tests := []test{ @@ -3393,11 +3382,15 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, +// name:"", +// generation:0, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3423,11 +3416,15 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, +// name:"", +// generation:0, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3465,8 +3462,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -3475,23 +3474,28 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// got, err := o.Start(test.args.ctx) -// if err := checkFunc(test.want, got, err); err != nil { +// err := o.deleteBenchmarkJob(test.args.ctx, test.args.name, test.args.generation) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } - -// func Test_operator_initCtrl(t *testing.T) { +// +// func Test_operator_deleteJob(t *testing.T) { +// type args struct { +// ctx context.Context +// name string +// } // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller @@ -3501,11 +3505,12 @@ func Test_operator_checkAtomics(t *testing.T) { // } // type test struct { // name string +// args args // fields fields // want want // checkFunc func(want, error) error -// beforeFunc func(*testing.T) -// afterFunc func(*testing.T) +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) // } // defaultCheckFunc := func(w want, err error) error { // if !errors.Is(err, w.err) { @@ -3513,42 +3518,54 @@ func Test_operator_checkAtomics(t *testing.T) { // } // return nil // } -// // tests := []test{ -// // { -// // name: "test_case_1", -// // fields: fields{ -// // jobNamespace: "default", -// // jobImageRepository: "vdaas/vald-benchmark-job", -// // jobImagePullPolicy: "Always", -// // // scenarios:nil, -// // // benchjobs:nil, -// // // jobs:nil, -// // // rcd:nil, -// // eg: nil, -// // ctrl: nil, -// // }, -// // want: want{ -// // err: errors.New("hoge"), -// // }, -// // checkFunc: defaultCheckFunc, -// // beforeFunc: func(t *testing.T) { -// // t.Helper() -// // }, -// // afterFunc: func(t *testing.T) { -// // t.Helper() -// // }, -// // }, +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// name:"", +// }, +// fields: fields { +// jobNamespace:"", +// jobImageRepository:"", +// jobImageTag:"", +// jobImagePullPolicy:"", +// configMapName:"", +// scenarios:nil, +// benchjobs:nil, +// jobs:nil, +// rcd:nil, +// eg:nil, +// ctrl: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 { +// ctx:nil, +// name:"", +// }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3558,10 +3575,10 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T,) { +// beforeFunc: func(t *testing.T, args args) { // t.Helper() // }, -// afterFunc: func(t *testing.T,) { +// afterFunc: func(t *testing.T, args args) { // t.Helper() // }, // } @@ -3575,10 +3592,10 @@ func Test_operator_checkAtomics(t *testing.T) { // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt) +// test.beforeFunc(tt, test.args) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt) +// defer test.afterFunc(tt, test.args) // } // checkFunc := test.checkFunc // if test.checkFunc == nil { @@ -3586,8 +3603,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -3596,47 +3615,52 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// err := o.initCtrl() +// err := o.deleteJob(test.args.ctx, test.args.name) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } - -// func Test_operator_deleteBenchmarkJob(t *testing.T) { +// +// func Test_operator_createBenchmarkJob(t *testing.T) { // type args struct { -// ctx context.Context -// name string -// generation int64 +// ctx context.Context +// scenario v1.ValdBenchmarkScenario // } // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller // } // type want struct { -// err error +// want []string +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, []string, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, got []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(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } // return nil // } // tests := []test{ @@ -3646,13 +3670,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, -// name:"", -// generation:0, +// scenario:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3678,13 +3703,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, -// name:"", -// generation:0, +// scenario:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3722,8 +3748,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -3732,27 +3760,28 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// err := o.deleteBenchmarkJob(test.args.ctx, test.args.name, test.args.generation) -// if err := checkFunc(test.want, err); err != nil { +// got, err := o.createBenchmarkJob(test.args.ctx, test.args.scenario) +// if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_operator_deleteJob(t *testing.T) { +// func Test_operator_createJob(t *testing.T) { // type args struct { -// ctx context.Context -// name string -// generation int64 +// ctx context.Context +// bjr v1.ValdBenchmarkJob // } // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller @@ -3782,13 +3811,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, -// name:"", -// generation:0, +// bjr:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3814,13 +3844,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, -// name:"", -// generation:0, +// bjr:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3858,8 +3889,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -3868,7 +3901,7 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// err := o.deleteJob(test.args.ctx, test.args.name, test.args.generation) +// err := o.createJob(test.args.ctx, test.args.bjr) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -3876,18 +3909,20 @@ func Test_operator_checkAtomics(t *testing.T) { // } // } // -// func Test_operator_createBenchmarkJob(t *testing.T) { +// func Test_operator_updateBenchmarkScenarioStatus(t *testing.T) { // type args struct { -// ctx context.Context -// scenario v1.ValdBenchmarkScenario +// ctx context.Context +// ss map[string]v1.ValdBenchmarkScenarioStatus // } // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller @@ -3921,12 +3956,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, -// scenario:nil, +// ss:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3952,12 +3989,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, -// scenario:nil, +// ss:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -3995,8 +4034,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -4005,7 +4046,7 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// got, err := o.createBenchmarkJob(test.args.ctx, test.args.scenario) +// got, err := o.updateBenchmarkScenarioStatus(test.args.ctx, test.args.ss) // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -4013,38 +4054,44 @@ func Test_operator_checkAtomics(t *testing.T) { // } // } // -// func Test_operator_createJob(t *testing.T) { +// func Test_operator_updateBenchmarkJobStatus(t *testing.T) { // type args struct { // ctx context.Context -// bjr v1.ValdBenchmarkJob +// js map[string]v1.BenchmarkJobStatus // } // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller // } // type want struct { -// err error +// want []string +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, []string, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, err error) error { +// defaultCheckFunc := func(w want, got []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(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } // return nil // } // tests := []test{ @@ -4054,12 +4101,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, -// bjr:nil, +// js:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -4085,12 +4134,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, -// bjr:nil, +// js:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -4128,8 +4179,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -4138,50 +4191,48 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// err := o.createJob(test.args.ctx, test.args.bjr) -// if err := checkFunc(test.want, err); err != nil { +// got, err := o.updateBenchmarkJobStatus(test.args.ctx, test.args.js) +// if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_operator_updateBenchmarkScenarioStatus(t *testing.T) { +// func Test_operator_checkJobsStatus(t *testing.T) { // type args struct { -// ctx context.Context -// ss map[string]v1.ValdBenchmarkScenarioStatus +// ctx context.Context +// jobs map[string]string // } // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller // } // type want struct { -// want []string -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, []string, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got []string, 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(got, w.want) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) -// } // return nil // } // tests := []test{ @@ -4191,12 +4242,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_1", // args: args { // ctx:nil, -// ss:nil, +// jobs:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -4222,12 +4275,14 @@ func Test_operator_checkAtomics(t *testing.T) { // name: "test_case_2", // args: args { // ctx:nil, -// ss:nil, +// jobs:nil, // }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -4265,8 +4320,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -4275,47 +4332,40 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// got, err := o.updateBenchmarkScenarioStatus(test.args.ctx, test.args.ss) -// if err := checkFunc(test.want, got, err); err != nil { +// err := o.checkJobsStatus(test.args.ctx, test.args.jobs) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_operator_updateBenchmarkJobStatus(t *testing.T) { -// type args struct { -// ctx context.Context -// js map[string]v1.BenchmarkJobStatus -// } +// func Test_operator_GetScenarioStatus(t *testing.T) { // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller // } // type want struct { -// want []string -// err error +// want map[v1.ValdBenchmarkScenarioStatus]int64 // } // type test struct { // name string -// args args // fields fields // want want -// checkFunc func(want, []string, error) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) +// checkFunc func(want, map[v1.ValdBenchmarkScenarioStatus]int64) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) // } -// defaultCheckFunc := func(w want, got []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) -// } +// defaultCheckFunc := func(w want, got map[v1.ValdBenchmarkScenarioStatus]int64) error { // if !reflect.DeepEqual(got, w.want) { // return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } @@ -4326,14 +4376,12 @@ func Test_operator_checkAtomics(t *testing.T) { // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// js:nil, -// }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -4343,10 +4391,10 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // 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() // }, // }, @@ -4357,14 +4405,12 @@ func Test_operator_checkAtomics(t *testing.T) { // func() test { // return test { // name: "test_case_2", -// args: args { -// ctx:nil, -// js:nil, -// }, // fields: fields { // jobNamespace:"", // jobImageRepository:"", +// jobImageTag:"", // jobImagePullPolicy:"", +// configMapName:"", // scenarios:nil, // benchjobs:nil, // jobs:nil, @@ -4374,10 +4420,10 @@ func Test_operator_checkAtomics(t *testing.T) { // }, // 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() // }, // } @@ -4391,10 +4437,10 @@ func Test_operator_checkAtomics(t *testing.T) { // 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 { @@ -4402,8 +4448,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -4412,26 +4460,155 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// got, err := o.updateBenchmarkJobStatus(test.args.ctx, test.args.js) -// if err := checkFunc(test.want, got, err); err != nil { +// got := o.GetScenarioStatus() +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_operator_checkJobsStatus(t *testing.T) { +// func Test_operator_GetBenchmarkJobStatus(t *testing.T) { +// type fields struct { +// jobNamespace string +// jobImageRepository string +// jobImageTag string +// jobImagePullPolicy string +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] +// rcd time.Duration +// eg errgroup.Group +// ctrl k8s.Controller +// } +// type want struct { +// want map[v1.BenchmarkJobStatus]int64 +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, map[v1.BenchmarkJobStatus]int64) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got map[v1.BenchmarkJobStatus]int64) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// jobNamespace:"", +// jobImageRepository:"", +// jobImageTag:"", +// jobImagePullPolicy:"", +// configMapName:"", +// scenarios:nil, +// benchjobs:nil, +// jobs:nil, +// rcd:nil, +// eg:nil, +// ctrl: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 { +// jobNamespace:"", +// jobImageRepository:"", +// jobImageTag:"", +// jobImagePullPolicy:"", +// configMapName:"", +// scenarios:nil, +// benchjobs:nil, +// jobs:nil, +// rcd:nil, +// eg:nil, +// ctrl: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 +// } +// o := &operator{ +// jobNamespace: test.fields.jobNamespace, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, +// jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, +// scenarios: test.fields.scenarios, +// benchjobs: test.fields.benchjobs, +// jobs: test.fields.jobs, +// rcd: test.fields.rcd, +// eg: test.fields.eg, +// ctrl: test.fields.ctrl, +// } +// +// got := o.GetBenchmarkJobStatus() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_operator_PreStart(t *testing.T) { // type args struct { -// ctx context.Context -// jobs map[string]string +// in0 context.Context // } // type fields struct { // jobNamespace string -// jobImage string +// jobImageRepository string +// jobImageTag string // jobImagePullPolicy string -// scenarios atomic.Pointer[map[string]*scenario] -// benchjobs atomic.Pointer[map[string]*v1.ValdBenchmarkJob] -// jobs atomic.Pointer[map[string]string] +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] // rcd time.Duration // eg errgroup.Group // ctrl k8s.Controller @@ -4455,34 +4632,69 @@ func Test_operator_checkAtomics(t *testing.T) { // return nil // } // tests := []test{ -// // func() test { -// // return test{ -// // name: "test_case_2", -// // args: args{ -// // ctx: nil, -// // jobs: nil, -// // }, -// // fields: fields{ -// // jobNamespace: "", -// // jobImageRepository: "", -// // jobImagePullPolicy: "", -// // scenarios: nil, -// // benchjobs: nil, -// // jobs: nil, -// // rcd: nil, -// // eg: nil, -// // ctrl: 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 +// /* +// { +// name: "test_case_1", +// args: args { +// in0:nil, +// }, +// fields: fields { +// jobNamespace:"", +// jobImageRepository:"", +// jobImageTag:"", +// jobImagePullPolicy:"", +// configMapName:"", +// scenarios:nil, +// benchjobs:nil, +// jobs:nil, +// rcd:nil, +// eg:nil, +// ctrl: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 { +// in0:nil, +// }, +// fields: fields { +// jobNamespace:"", +// jobImageRepository:"", +// jobImageTag:"", +// jobImagePullPolicy:"", +// configMapName:"", +// scenarios:nil, +// benchjobs:nil, +// jobs:nil, +// rcd:nil, +// eg:nil, +// ctrl: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 { @@ -4502,8 +4714,10 @@ func Test_operator_checkAtomics(t *testing.T) { // } // o := &operator{ // jobNamespace: test.fields.jobNamespace, -// jobImageRepository: test.fields.jobImage, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, // jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, // scenarios: test.fields.scenarios, // benchjobs: test.fields.benchjobs, // jobs: test.fields.jobs, @@ -4512,10 +4726,152 @@ func Test_operator_checkAtomics(t *testing.T) { // ctrl: test.fields.ctrl, // } // -// err := o.checkJobsStatus(test.args.ctx, test.args.jobs) +// err := o.PreStart(test.args.in0) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } +// +// func Test_operator_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// jobNamespace string +// jobImageRepository string +// jobImageTag string +// jobImagePullPolicy string +// configMapName string +// scenarios *atomic.Pointer[map[string]*scenario] +// benchjobs *atomic.Pointer[map[string]*v1.ValdBenchmarkJob] +// jobs *atomic.Pointer[map[string]string] +// rcd time.Duration +// eg errgroup.Group +// ctrl k8s.Controller +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// jobNamespace:"", +// jobImageRepository:"", +// jobImageTag:"", +// jobImagePullPolicy:"", +// configMapName:"", +// scenarios:nil, +// benchjobs:nil, +// jobs:nil, +// rcd:nil, +// eg:nil, +// ctrl: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 { +// ctx:nil, +// }, +// fields: fields { +// jobNamespace:"", +// jobImageRepository:"", +// jobImageTag:"", +// jobImagePullPolicy:"", +// configMapName:"", +// scenarios:nil, +// benchjobs:nil, +// jobs:nil, +// rcd:nil, +// eg:nil, +// ctrl: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 +// } +// o := &operator{ +// jobNamespace: test.fields.jobNamespace, +// jobImageRepository: test.fields.jobImageRepository, +// jobImageTag: test.fields.jobImageTag, +// jobImagePullPolicy: test.fields.jobImagePullPolicy, +// configMapName: test.fields.configMapName, +// scenarios: test.fields.scenarios, +// benchjobs: test.fields.benchjobs, +// jobs: test.fields.jobs, +// rcd: test.fields.rcd, +// eg: test.fields.eg, +// ctrl: test.fields.ctrl, +// } +// +// got, err := o.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/operator/service/option_test.go b/pkg/tools/benchmark/operator/service/option_test.go new file mode 100644 index 0000000000..04be36cdf2 --- /dev/null +++ b/pkg/tools/benchmark/operator/service/option_test.go @@ -0,0 +1,611 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func TestWithErrGroup(t *testing.T) { +// type args struct { +// eg errgroup.Group +// } +// 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 { +// eg: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 { +// eg: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 := WithErrGroup(test.args.eg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithReconcileCheckDuration(t *testing.T) { +// type args struct { +// ts 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 { +// ts:"", +// }, +// 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 { +// ts:"", +// }, +// 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 := WithReconcileCheckDuration(test.args.ts) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithJobNamespace(t *testing.T) { +// type args struct { +// ns 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 { +// ns:"", +// }, +// 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 { +// ns:"", +// }, +// 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 := WithJobNamespace(test.args.ns) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithJobImageRepository(t *testing.T) { +// type args struct { +// repo 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 { +// repo:"", +// }, +// 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 { +// repo:"", +// }, +// 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 := WithJobImageRepository(test.args.repo) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithJobImageTag(t *testing.T) { +// type args struct { +// tag 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 { +// tag:"", +// }, +// 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 { +// tag:"", +// }, +// 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 := WithJobImageTag(test.args.tag) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithJobImagePullPolicy(t *testing.T) { +// type args struct { +// p 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 { +// p:"", +// }, +// 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 { +// p:"", +// }, +// 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 := WithJobImagePullPolicy(test.args.p) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithConfigMapName(t *testing.T) { +// type args struct { +// cm 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 { +// cm:"", +// }, +// 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 { +// cm:"", +// }, +// 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 := WithConfigMapName(test.args.cm) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/benchmark/operator/usecase/benchmarkd_test.go b/pkg/tools/benchmark/operator/usecase/benchmarkd_test.go new file mode 100644 index 0000000000..c8be6191f4 --- /dev/null +++ b/pkg/tools/benchmark/operator/usecase/benchmarkd_test.go @@ -0,0 +1,699 @@ +// 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 usecase + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// cfg *config.Config +// } +// type want struct { +// wantR runner.Runner +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, runner.Runner, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotR runner.Runner, 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(gotR, w.wantR) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotR, w.wantR) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// cfg: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 { +// cfg: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 +// } +// +// gotR, err := New(test.args.cfg) +// if err := checkFunc(test.want, gotR, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// operator service.Operator +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// operator: test.fields.operator, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// operator service.Operator +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// operator: test.fields.operator, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// operator service.Operator +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// operator: test.fields.operator, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PreStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// operator service.Operator +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// operator: test.fields.operator, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// in0 context.Context +// } +// type fields struct { +// eg errgroup.Group +// cfg *config.Config +// operator service.Operator +// h handler.Benchmark +// server starter.Server +// observability observability.Observability +// } +// 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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 { +// in0:nil, +// }, +// fields: fields { +// eg:nil, +// cfg:nil, +// operator:nil, +// h:nil, +// server:nil, +// observability: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 +// } +// r := &run{ +// eg: test.fields.eg, +// cfg: test.fields.cfg, +// operator: test.fields.operator, +// h: test.fields.h, +// server: test.fields.server, +// observability: test.fields.observability, +// } +// +// err := r.PostStop(test.args.in0) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/cli/loadtest/assets/dataset.go b/pkg/tools/cli/loadtest/assets/dataset.go index f1f6d2afd2..acd03fd924 100644 --- a/pkg/tools/cli/loadtest/assets/dataset.go +++ b/pkg/tools/cli/loadtest/assets/dataset.go @@ -28,9 +28,9 @@ var ErrOutOfBounds = x1b.ErrOutOfBounds // Dataset is representation of train and test dataset. type Dataset interface { - Train(i int) (interface{}, error) + Train(i int) (any, error) TrainSize() int - Query(i int) (interface{}, error) + Query(i int) (any, error) QuerySize() int Distance(i int) ([]float32, error) DistanceSize() int diff --git a/pkg/tools/cli/loadtest/assets/dataset_test.go b/pkg/tools/cli/loadtest/assets/dataset_test.go index a510087bb9..8132ccf12f 100644 --- a/pkg/tools/cli/loadtest/assets/dataset_test.go +++ b/pkg/tools/cli/loadtest/assets/dataset_test.go @@ -111,7 +111,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -212,7 +211,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -313,7 +311,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -414,7 +411,95 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func Test_findDir(t *testing.T) { +// type args struct { +// path string +// } +// type want struct { +// want string +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, string, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got 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(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, err := findDir(test.args.path) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } @@ -500,7 +585,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/tools/cli/loadtest/assets/hdf5_loader.go b/pkg/tools/cli/loadtest/assets/hdf5_loader.go index 482dabba32..c06dea16cc 100644 --- a/pkg/tools/cli/loadtest/assets/hdf5_loader.go +++ b/pkg/tools/cli/loadtest/assets/hdf5_loader.go @@ -18,9 +18,9 @@ import ( "gonum.org/v1/hdf5" ) -type loaderFunc func(*hdf5.Dataset, int, int, int) (interface{}, error) +type loaderFunc func(*hdf5.Dataset, int, int, int) (any, error) -func loadFloat32(dset *hdf5.Dataset, npoints, row, dim int) (interface{}, error) { +func loadFloat32(dset *hdf5.Dataset, npoints, row, dim int) (any, error) { v := make([]float32, npoints) if err := dset.Read(&v); err != nil { return nil, err @@ -36,7 +36,7 @@ func loadFloat32(dset *hdf5.Dataset, npoints, row, dim int) (interface{}, error) return vec, nil } -func loadInt(dset *hdf5.Dataset, npoints, row, dim int) (interface{}, error) { +func loadInt(dset *hdf5.Dataset, npoints, row, dim int) (any, error) { v := make([]int32, npoints) if err := dset.Read(&v); err != nil { return nil, err @@ -52,7 +52,7 @@ func loadInt(dset *hdf5.Dataset, npoints, row, dim int) (interface{}, error) { return vec, nil } -func loadDataset(file *hdf5.File, name string, f loaderFunc) (dim int, vec interface{}, err error) { +func loadDataset(file *hdf5.File, name string, f loaderFunc) (dim int, vec any, err error) { dset, err := file.OpenDataset(name) if err != nil { return 0, nil, err diff --git a/pkg/tools/cli/loadtest/assets/hdf5_loader_test.go b/pkg/tools/cli/loadtest/assets/hdf5_loader_test.go index aaab1f1e22..be5e1b607b 100644 --- a/pkg/tools/cli/loadtest/assets/hdf5_loader_test.go +++ b/pkg/tools/cli/loadtest/assets/hdf5_loader_test.go @@ -15,6 +15,301 @@ package assets // NOT IMPLEMENTED BELOW // +// func Test_loadFloat32(t *testing.T) { +// type args struct { +// dset *hdf5.Dataset +// npoints int +// row int +// dim int +// } +// type want struct { +// want any +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, any, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got any, 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 { +// dset:nil, +// npoints:0, +// row:0, +// 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 { +// dset:nil, +// npoints:0, +// row:0, +// 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, err := loadFloat32(test.args.dset, test.args.npoints, test.args.row, test.args.dim) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_loadInt(t *testing.T) { +// type args struct { +// dset *hdf5.Dataset +// npoints int +// row int +// dim int +// } +// type want struct { +// want any +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, any, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got any, 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 { +// dset:nil, +// npoints:0, +// row:0, +// 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 { +// dset:nil, +// npoints:0, +// row:0, +// 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, err := loadInt(test.args.dset, test.args.npoints, test.args.row, test.args.dim) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_loadDataset(t *testing.T) { +// type args struct { +// file *hdf5.File +// name string +// f loaderFunc +// } +// type want struct { +// wantDim int +// wantVec any +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, int, any, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotDim int, gotVec any, 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(gotDim, w.wantDim) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotDim, w.wantDim) +// } +// if !reflect.DeepEqual(gotVec, w.wantVec) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotVec, w.wantVec) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// file:nil, +// name:"", +// f: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 { +// file:nil, +// name:"", +// f: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 +// } +// +// gotDim, gotVec, err := loadDataset(test.args.file, test.args.name, test.args.f) +// if err := checkFunc(test.want, gotDim, gotVec, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func TestLoad(t *testing.T) { // type args struct { // path string @@ -116,7 +411,6 @@ package assets // if err := checkFunc(test.want, gotTrain, gotTest, gotDistances, gotNeighbors, gotDim, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/tools/cli/loadtest/assets/large_dataset.go b/pkg/tools/cli/loadtest/assets/large_dataset.go index 5621b67b37..1649fea69f 100644 --- a/pkg/tools/cli/loadtest/assets/large_dataset.go +++ b/pkg/tools/cli/loadtest/assets/large_dataset.go @@ -31,7 +31,9 @@ type largeDataset struct { distances x1b.FloatVectors } -func loadLargeData(trainFileName, queryFileName, groundTruthFileName, distanceFileName, name, distanceType, objectType string) func() (Dataset, error) { +func loadLargeData( + trainFileName, queryFileName, groundTruthFileName, distanceFileName, name, distanceType, objectType string, +) func() (Dataset, error) { return func() (Dataset, error) { dir, err := findDir(largeDatasetPath) if err != nil { @@ -86,7 +88,7 @@ func loadLargeData(trainFileName, queryFileName, groundTruthFileName, distanceFi } } -func (d *largeDataset) Train(i int) (interface{}, error) { +func (d *largeDataset) Train(i int) (any, error) { return d.train.Load(i) } @@ -94,7 +96,7 @@ func (d *largeDataset) TrainSize() int { return d.train.Size() } -func (d *largeDataset) Query(i int) (interface{}, error) { +func (d *largeDataset) Query(i int) (any, error) { return d.query.Load(i) } diff --git a/pkg/tools/cli/loadtest/assets/large_dataset_test.go b/pkg/tools/cli/loadtest/assets/large_dataset_test.go index bf310dc49b..58183c6df5 100644 --- a/pkg/tools/cli/loadtest/assets/large_dataset_test.go +++ b/pkg/tools/cli/loadtest/assets/large_dataset_test.go @@ -15,6 +15,117 @@ package assets // NOT IMPLEMENTED BELOW // +// func Test_loadLargeData(t *testing.T) { +// type args struct { +// trainFileName string +// queryFileName string +// groundTruthFileName string +// distanceFileName string +// name string +// distanceType string +// objectType string +// } +// type want struct { +// want func() (Dataset, error) +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, func() (Dataset, error)) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got func() (Dataset, error)) 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 { +// trainFileName:"", +// queryFileName:"", +// groundTruthFileName:"", +// distanceFileName:"", +// name:"", +// distanceType:"", +// objectType:"", +// }, +// 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 { +// trainFileName:"", +// queryFileName:"", +// groundTruthFileName:"", +// distanceFileName:"", +// name:"", +// distanceType:"", +// objectType:"", +// }, +// 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 := loadLargeData( +// test.args.trainFileName, +// test.args.queryFileName, +// test.args.groundTruthFileName, +// test.args.distanceFileName, +// test.args.name, +// test.args.distanceType, +// test.args.objectType, +// ) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func Test_largeDataset_Train(t *testing.T) { // type args struct { // i int @@ -27,7 +138,7 @@ package assets // distances x1b.FloatVectors // } // type want struct { -// want interface{} +// want any // err error // } // type test struct { @@ -35,11 +146,11 @@ package assets // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got interface{}, err error) error { +// defaultCheckFunc := func(w want, got any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -129,7 +240,6 @@ package assets // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -234,7 +344,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -251,7 +360,7 @@ package assets // distances x1b.FloatVectors // } // type want struct { -// want interface{} +// want any // err error // } // type test struct { @@ -259,11 +368,11 @@ package assets // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got interface{}, err error) error { +// defaultCheckFunc := func(w want, got any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -353,7 +462,6 @@ package assets // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -458,7 +566,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -577,7 +684,6 @@ package assets // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -682,7 +788,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -801,7 +906,6 @@ package assets // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -906,7 +1010,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1011,7 +1114,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1116,7 +1218,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1221,7 +1322,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1326,7 +1426,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/tools/cli/loadtest/assets/small_dataset.go b/pkg/tools/cli/loadtest/assets/small_dataset.go index ed9cb82919..52e141cc1e 100644 --- a/pkg/tools/cli/loadtest/assets/small_dataset.go +++ b/pkg/tools/cli/loadtest/assets/small_dataset.go @@ -129,7 +129,7 @@ func gaussian(dim, size int, mean, stdDev float64) func() (Dataset, error) { } // Train returns vectors for train. -func (s *smallDataset) Train(i int) (interface{}, error) { +func (s *smallDataset) Train(i int) (any, error) { if i >= len(s.train) { return nil, ErrOutOfBounds } @@ -142,7 +142,7 @@ func (s *smallDataset) TrainSize() int { } // Query returns vectors for test. -func (s *smallDataset) Query(i int) (interface{}, error) { +func (s *smallDataset) Query(i int) (any, error) { if i >= len(s.query) { return nil, ErrOutOfBounds } diff --git a/pkg/tools/cli/loadtest/assets/small_dataset_test.go b/pkg/tools/cli/loadtest/assets/small_dataset_test.go index 2b1bf9f5da..d6aa962cf9 100644 --- a/pkg/tools/cli/loadtest/assets/small_dataset_test.go +++ b/pkg/tools/cli/loadtest/assets/small_dataset_test.go @@ -15,6 +15,367 @@ package assets // NOT IMPLEMENTED BELOW // +// func Test_loadSmallData(t *testing.T) { +// type args struct { +// fileName string +// datasetName string +// distanceType string +// objectType string +// } +// type want struct { +// want func() (Dataset, error) +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, func() (Dataset, error)) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got func() (Dataset, error)) 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 { +// fileName:"", +// datasetName:"", +// distanceType:"", +// objectType:"", +// }, +// 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 { +// fileName:"", +// datasetName:"", +// distanceType:"", +// objectType:"", +// }, +// 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 := loadSmallData(test.args.fileName, test.args.datasetName, test.args.distanceType, test.args.objectType) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_identity(t *testing.T) { +// type args struct { +// dim int +// } +// type want struct { +// want func() (Dataset, error) +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, func() (Dataset, error)) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got func() (Dataset, error)) 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 := identity(test.args.dim) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_random(t *testing.T) { +// type args struct { +// dim int +// size int +// } +// type want struct { +// want func() (Dataset, error) +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, func() (Dataset, error)) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got func() (Dataset, error)) 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, +// size: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, +// size: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 := random(test.args.dim, test.args.size) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_gaussian(t *testing.T) { +// type args struct { +// dim int +// size int +// mean float64 +// stdDev float64 +// } +// type want struct { +// want func() (Dataset, error) +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, func() (Dataset, error)) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got func() (Dataset, error)) 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, +// size:0, +// mean:0, +// stdDev: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, +// size:0, +// mean:0, +// stdDev: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 := gaussian(test.args.dim, test.args.size, test.args.mean, test.args.stdDev) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func Test_smallDataset_Train(t *testing.T) { // type args struct { // i int @@ -27,7 +388,7 @@ package assets // neighbors [][]int // } // type want struct { -// want interface{} +// want any // err error // } // type test struct { @@ -35,11 +396,11 @@ package assets // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got interface{}, err error) error { +// defaultCheckFunc := func(w want, got any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -129,7 +490,6 @@ package assets // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -234,7 +594,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -251,7 +610,7 @@ package assets // neighbors [][]int // } // type want struct { -// want interface{} +// want any // err error // } // type test struct { @@ -259,11 +618,11 @@ package assets // args args // fields fields // want want -// checkFunc func(want, interface{}, error) error +// checkFunc func(want, any, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got interface{}, err error) error { +// defaultCheckFunc := func(w want, got any, err error) error { // if !errors.Is(err, w.err) { // return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) // } @@ -353,7 +712,6 @@ package assets // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -458,7 +816,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -577,7 +934,6 @@ package assets // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -682,7 +1038,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -801,7 +1156,6 @@ package assets // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -906,7 +1260,6 @@ package assets // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/tools/cli/loadtest/config/config_test.go b/pkg/tools/cli/loadtest/config/config_test.go index 02d2bc3386..ee882d6587 100644 --- a/pkg/tools/cli/loadtest/config/config_test.go +++ b/pkg/tools/cli/loadtest/config/config_test.go @@ -100,7 +100,6 @@ package config // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -177,7 +176,6 @@ package config // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -267,7 +265,6 @@ package config // if err := checkFunc(test.want, gotCfg, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/tools/cli/loadtest/service/insert.go b/pkg/tools/cli/loadtest/service/insert.go index 087fab4ac9..54562961c5 100644 --- a/pkg/tools/cli/loadtest/service/insert.go +++ b/pkg/tools/cli/loadtest/service/insert.go @@ -25,7 +25,9 @@ import ( "github.com/vdaas/vald/pkg/tools/cli/loadtest/assets" ) -func insertRequestProvider(dataset assets.Dataset, batchSize int) (f func() interface{}, size int, err error) { +func insertRequestProvider( + dataset assets.Dataset, batchSize int, +) (f func() any, size int, err error) { switch { case batchSize == 1: f, size = objectVectorProvider(dataset) @@ -40,10 +42,10 @@ func insertRequestProvider(dataset assets.Dataset, batchSize int) (f func() inte return f, size, nil } -func objectVectorProvider(dataset assets.Dataset) (func() interface{}, int) { +func objectVectorProvider(dataset assets.Dataset) (func() any, int) { idx := int32(-1) size := dataset.TrainSize() - return func() (ret interface{}) { + return func() (ret any) { if i := int(atomic.AddInt32(&idx, 1)); i < size { v, err := dataset.Train(i) if err != nil { @@ -60,13 +62,13 @@ func objectVectorProvider(dataset assets.Dataset) (func() interface{}, int) { }, size } -func objectVectorsProvider(dataset assets.Dataset, n int) (func() interface{}, int) { +func objectVectorsProvider(dataset assets.Dataset, n int) (func() any, int) { provider, s := objectVectorProvider(dataset) size := s / n if s%n != 0 { size = size + 1 } - return func() (ret interface{}) { + return func() (ret any) { r := make([]*payload.Insert_Request, 0, n) for i := 0; i < n; i++ { d := provider() @@ -87,11 +89,11 @@ func objectVectorsProvider(dataset assets.Dataset, n int) (func() interface{}, i func (l *loader) newInsert() (f loadFunc, err error) { switch { case l.batchSize == 1: - f = func(ctx context.Context, conn *grpc.ClientConn, i interface{}, copts ...grpc.CallOption) (interface{}, error) { + f = func(ctx context.Context, conn *grpc.ClientConn, i any, copts ...grpc.CallOption) (any, error) { return vald.NewInsertClient(conn).Insert(ctx, i.(*payload.Insert_Request), copts...) } case l.batchSize >= 2: - f = func(ctx context.Context, conn *grpc.ClientConn, i interface{}, copts ...grpc.CallOption) (interface{}, error) { + f = func(ctx context.Context, conn *grpc.ClientConn, i any, copts ...grpc.CallOption) (any, error) { return vald.NewInsertClient(conn).MultiInsert(ctx, i.(*payload.Insert_MultiRequest), copts...) } default: @@ -105,7 +107,7 @@ func (l *loader) newInsert() (f loadFunc, err error) { func (l *loader) newStreamInsert() (f loadFunc, err error) { l.batchSize = 1 - return func(ctx context.Context, conn *grpc.ClientConn, i interface{}, copts ...grpc.CallOption) (interface{}, error) { + return func(ctx context.Context, conn *grpc.ClientConn, i any, copts ...grpc.CallOption) (any, error) { return vald.NewValdClient(conn).StreamInsert(ctx, copts...) }, nil } diff --git a/pkg/tools/cli/loadtest/service/insert_test.go b/pkg/tools/cli/loadtest/service/insert_test.go new file mode 100644 index 0000000000..424a1ed61b --- /dev/null +++ b/pkg/tools/cli/loadtest/service/insert_test.go @@ -0,0 +1,557 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func Test_insertRequestProvider(t *testing.T) { +// type args struct { +// dataset assets.Dataset +// batchSize int +// } +// type want struct { +// wantF func() any +// wantSize int +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, func() any, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotF func() any, gotSize 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(gotF, w.wantF) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotF, w.wantF) +// } +// if !reflect.DeepEqual(gotSize, w.wantSize) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotSize, w.wantSize) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// dataset:nil, +// batchSize: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 { +// dataset:nil, +// batchSize: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 +// } +// +// gotF, gotSize, err := insertRequestProvider(test.args.dataset, test.args.batchSize) +// if err := checkFunc(test.want, gotF, gotSize, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_objectVectorProvider(t *testing.T) { +// type args struct { +// dataset assets.Dataset +// } +// type want struct { +// want func() any +// want1 int +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, func() any, int) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got func() any, got1 int) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// dataset: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 { +// dataset: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, got1 := objectVectorProvider(test.args.dataset) +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_objectVectorsProvider(t *testing.T) { +// type args struct { +// dataset assets.Dataset +// n int +// } +// type want struct { +// want func() any +// want1 int +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, func() any, int) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got func() any, got1 int) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// dataset:nil, +// n: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 { +// dataset:nil, +// n: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, got1 := objectVectorsProvider(test.args.dataset, test.args.n) +// if err := checkFunc(test.want, got, got1); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_loader_newInsert(t *testing.T) { +// type fields struct { +// eg errgroup.Group +// client grpc.Client +// addr string +// concurrency int +// batchSize int +// dataset string +// progressDuration time.Duration +// loaderFunc loadFunc +// dataProvider func() any +// dataSize int +// operation config.Operation +// } +// type want struct { +// wantF loadFunc +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, loadFunc, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, gotF loadFunc, 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(gotF, w.wantF) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotF, w.wantF) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 +// } +// l := &loader{ +// eg: test.fields.eg, +// client: test.fields.client, +// addr: test.fields.addr, +// concurrency: test.fields.concurrency, +// batchSize: test.fields.batchSize, +// dataset: test.fields.dataset, +// progressDuration: test.fields.progressDuration, +// loaderFunc: test.fields.loaderFunc, +// dataProvider: test.fields.dataProvider, +// dataSize: test.fields.dataSize, +// operation: test.fields.operation, +// } +// +// gotF, err := l.newInsert() +// if err := checkFunc(test.want, gotF, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_loader_newStreamInsert(t *testing.T) { +// type fields struct { +// eg errgroup.Group +// client grpc.Client +// addr string +// concurrency int +// batchSize int +// dataset string +// progressDuration time.Duration +// loaderFunc loadFunc +// dataProvider func() any +// dataSize int +// operation config.Operation +// } +// type want struct { +// wantF loadFunc +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, loadFunc, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, gotF loadFunc, 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(gotF, w.wantF) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotF, w.wantF) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 +// } +// l := &loader{ +// eg: test.fields.eg, +// client: test.fields.client, +// addr: test.fields.addr, +// concurrency: test.fields.concurrency, +// batchSize: test.fields.batchSize, +// dataset: test.fields.dataset, +// progressDuration: test.fields.progressDuration, +// loaderFunc: test.fields.loaderFunc, +// dataProvider: test.fields.dataProvider, +// dataSize: test.fields.dataSize, +// operation: test.fields.operation, +// } +// +// gotF, err := l.newStreamInsert() +// if err := checkFunc(test.want, gotF, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/cli/loadtest/service/loader.go b/pkg/tools/cli/loadtest/service/loader.go index 7a12be9f9d..c22c500f47 100644 --- a/pkg/tools/cli/loadtest/service/loader.go +++ b/pkg/tools/cli/loadtest/service/loader.go @@ -38,7 +38,7 @@ type Loader interface { } type ( - loadFunc func(context.Context, *grpc.ClientConn, interface{}, ...grpc.CallOption) (interface{}, error) + loadFunc func(context.Context, *grpc.ClientConn, any, ...grpc.CallOption) (any, error) ) type loader struct { @@ -50,7 +50,7 @@ type loader struct { dataset string progressDuration time.Duration loaderFunc loadFunc - dataProvider func() interface{} + dataProvider func() any dataSize int operation config.Operation } @@ -135,7 +135,7 @@ func (l *loader) Do(ctx context.Context) <-chan error { log.Infof("progress %d requests, %f[vps], error: %d", pgCnt, vps(int(pgCnt)*l.batchSize, start, time.Now()), errCnt) } - f := func(i interface{}, err error) { + f := func(i any, err error) { atomic.AddInt32(&pgCnt, 1) if err != nil { atomic.AddInt32(&errCnt, 1) @@ -183,19 +183,21 @@ func (l *loader) Do(ctx context.Context) <-chan error { return ech } -func (l *loader) do(ctx context.Context, f func(interface{}, error), notify func(context.Context, error)) (err error) { +func (l *loader) do( + ctx context.Context, f func(any, error), notify func(context.Context, error), +) (err error) { eg, egctx := errgroup.New(ctx) switch l.operation { case config.StreamInsert, config.StreamSearch: - var newData func() interface{} + var newData func() any switch l.operation { case config.StreamInsert: - newData = func() interface{} { + newData = func() any { return new(payload.Empty) } case config.StreamSearch: - newData = func() interface{} { + newData = func() any { return new(payload.Search_Response) } } @@ -206,7 +208,7 @@ func (l *loader) do(ctx context.Context, f func(interface{}, error), notify func err = nil } }() - _, err = l.client.Do(egctx, l.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) { + _, err = l.client.Do(egctx, l.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (any, error) { st, err := l.loaderFunc(ctx, conn, nil, copts...) if err != nil { return nil, err @@ -230,7 +232,7 @@ func (l *loader) do(ctx context.Context, f func(interface{}, error), notify func notify(egctx, err) err = nil }() - _, err = l.client.Do(egctx, l.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) { + _, err = l.client.Do(egctx, l.addr, func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (any, error) { res, err := l.loaderFunc(egctx, conn, r) f(res, err) return res, err diff --git a/pkg/tools/cli/loadtest/service/loader_option_test.go b/pkg/tools/cli/loadtest/service/loader_option_test.go index badfa1ca02..91dbb95976 100644 --- a/pkg/tools/cli/loadtest/service/loader_option_test.go +++ b/pkg/tools/cli/loadtest/service/loader_option_test.go @@ -96,7 +96,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -182,7 +181,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -268,7 +266,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -354,7 +351,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -440,7 +436,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -526,7 +521,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -612,7 +606,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -698,7 +691,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } diff --git a/pkg/tools/cli/loadtest/service/loader_test.go b/pkg/tools/cli/loadtest/service/loader_test.go index 4c8324f35e..e5f46563ce 100644 --- a/pkg/tools/cli/loadtest/service/loader_test.go +++ b/pkg/tools/cli/loadtest/service/loader_test.go @@ -100,7 +100,6 @@ package service // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -118,7 +117,7 @@ package service // dataset string // progressDuration time.Duration // loaderFunc loadFunc -// dataProvider func() interface{} +// dataProvider func() any // dataSize int // operation config.Operation // } @@ -239,7 +238,6 @@ package service // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -257,7 +255,7 @@ package service // dataset string // progressDuration time.Duration // loaderFunc loadFunc -// dataProvider func() interface{} +// dataProvider func() any // dataSize int // operation config.Operation // } @@ -378,7 +376,150 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } // +// func Test_loader_do(t *testing.T) { +// type args struct { +// ctx context.Context +// f func(any, error) +// notify func(context.Context, error) +// } +// type fields struct { +// eg errgroup.Group +// client grpc.Client +// addr string +// concurrency int +// batchSize int +// dataset string +// progressDuration time.Duration +// loaderFunc loadFunc +// dataProvider func() any +// dataSize int +// operation config.Operation +// } +// 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 { +// ctx:nil, +// f:nil, +// notify:nil, +// }, +// fields: fields { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 { +// ctx:nil, +// f:nil, +// notify:nil, +// }, +// fields: fields { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 +// } +// l := &loader{ +// eg: test.fields.eg, +// client: test.fields.client, +// addr: test.fields.addr, +// concurrency: test.fields.concurrency, +// batchSize: test.fields.batchSize, +// dataset: test.fields.dataset, +// progressDuration: test.fields.progressDuration, +// loaderFunc: test.fields.loaderFunc, +// dataProvider: test.fields.dataProvider, +// dataSize: test.fields.dataSize, +// operation: test.fields.operation, +// } +// +// err := l.do(test.args.ctx, test.args.f, test.args.notify) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/pkg/tools/cli/loadtest/service/search.go b/pkg/tools/cli/loadtest/service/search.go index 7b5091dc9e..722a924d7c 100644 --- a/pkg/tools/cli/loadtest/service/search.go +++ b/pkg/tools/cli/loadtest/service/search.go @@ -23,10 +23,10 @@ import ( "github.com/vdaas/vald/pkg/tools/cli/loadtest/assets" ) -func searchRequestProvider(dataset assets.Dataset) (func() interface{}, int, error) { +func searchRequestProvider(dataset assets.Dataset) (func() any, int, error) { size := dataset.QuerySize() idx := int32(-1) - return func() (ret interface{}) { + return func() (ret any) { if i := int(atomic.AddInt32(&idx, 1)); i < size { v, err := dataset.Query(i) if err != nil { @@ -41,13 +41,13 @@ func searchRequestProvider(dataset assets.Dataset) (func() interface{}, int, err } func (l *loader) newSearch() (loadFunc, error) { - return func(ctx context.Context, conn *grpc.ClientConn, i interface{}, copts ...grpc.CallOption) (interface{}, error) { + return func(ctx context.Context, conn *grpc.ClientConn, i any, copts ...grpc.CallOption) (any, error) { return vald.NewSearchClient(conn).Search(ctx, i.(*payload.Search_Request), copts...) }, nil } func (l *loader) newStreamSearch() (loadFunc, error) { - return func(ctx context.Context, conn *grpc.ClientConn, i interface{}, copts ...grpc.CallOption) (interface{}, error) { + return func(ctx context.Context, conn *grpc.ClientConn, i any, copts ...grpc.CallOption) (any, error) { return vald.NewSearchClient(conn).StreamSearch(ctx, copts...) }, nil } diff --git a/pkg/tools/cli/loadtest/service/search_test.go b/pkg/tools/cli/loadtest/service/search_test.go new file mode 100644 index 0000000000..cb7c1b4e8f --- /dev/null +++ b/pkg/tools/cli/loadtest/service/search_test.go @@ -0,0 +1,373 @@ +// 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 service + +// NOT IMPLEMENTED BELOW +// +// func Test_searchRequestProvider(t *testing.T) { +// type args struct { +// dataset assets.Dataset +// } +// type want struct { +// want func() any +// want1 int +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, func() any, int, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got func() any, got1 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(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) +// } +// if !reflect.DeepEqual(got1, w.want1) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// dataset: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 { +// dataset: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, got1, err := searchRequestProvider(test.args.dataset) +// if err := checkFunc(test.want, got, got1, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_loader_newSearch(t *testing.T) { +// type fields struct { +// eg errgroup.Group +// client grpc.Client +// addr string +// concurrency int +// batchSize int +// dataset string +// progressDuration time.Duration +// loaderFunc loadFunc +// dataProvider func() any +// dataSize int +// operation config.Operation +// } +// type want struct { +// want loadFunc +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, loadFunc, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got loadFunc, 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 { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 +// } +// l := &loader{ +// eg: test.fields.eg, +// client: test.fields.client, +// addr: test.fields.addr, +// concurrency: test.fields.concurrency, +// batchSize: test.fields.batchSize, +// dataset: test.fields.dataset, +// progressDuration: test.fields.progressDuration, +// loaderFunc: test.fields.loaderFunc, +// dataProvider: test.fields.dataProvider, +// dataSize: test.fields.dataSize, +// operation: test.fields.operation, +// } +// +// got, err := l.newSearch() +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_loader_newStreamSearch(t *testing.T) { +// type fields struct { +// eg errgroup.Group +// client grpc.Client +// addr string +// concurrency int +// batchSize int +// dataset string +// progressDuration time.Duration +// loaderFunc loadFunc +// dataProvider func() any +// dataSize int +// operation config.Operation +// } +// type want struct { +// want loadFunc +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, loadFunc, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got loadFunc, 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 { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 { +// eg:nil, +// client:nil, +// addr:"", +// concurrency:0, +// batchSize:0, +// dataset:"", +// progressDuration:nil, +// loaderFunc:nil, +// dataProvider:nil, +// dataSize:0, +// operation: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 +// } +// l := &loader{ +// eg: test.fields.eg, +// client: test.fields.client, +// addr: test.fields.addr, +// concurrency: test.fields.concurrency, +// batchSize: test.fields.batchSize, +// dataset: test.fields.dataset, +// progressDuration: test.fields.progressDuration, +// loaderFunc: test.fields.loaderFunc, +// dataProvider: test.fields.dataProvider, +// dataSize: test.fields.dataSize, +// operation: test.fields.operation, +// } +// +// got, err := l.newStreamSearch() +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/tools/cli/loadtest/usecase/load_test.go b/pkg/tools/cli/loadtest/usecase/load_test.go index 483e3950e7..21d004bb39 100644 --- a/pkg/tools/cli/loadtest/usecase/load_test.go +++ b/pkg/tools/cli/loadtest/usecase/load_test.go @@ -103,7 +103,540 @@ package usecase // if err := checkFunc(test.want, gotR, err); err != nil { // tt.Errorf("error = %v", err) // } +// }) +// } +// } +// +// func Test_run_PreStart(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// loader service.Loader +// client grpc.Client +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 +// } +// r := &run{ +// eg: test.fields.eg, +// loader: test.fields.loader, +// client: test.fields.client, +// } +// +// err := r.PreStart(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Start(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// loader service.Loader +// client grpc.Client +// } +// type want struct { +// want <-chan error +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, <-chan error, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got <-chan error, 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 +// } +// r := &run{ +// eg: test.fields.eg, +// loader: test.fields.loader, +// client: test.fields.client, +// } +// +// got, err := r.Start(test.args.ctx) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PreStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// loader service.Loader +// client grpc.Client +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 +// } +// r := &run{ +// eg: test.fields.eg, +// loader: test.fields.loader, +// client: test.fields.client, +// } +// +// err := r.PreStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_Stop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// loader service.Loader +// client grpc.Client +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 +// } +// r := &run{ +// eg: test.fields.eg, +// loader: test.fields.loader, +// client: test.fields.client, +// } +// +// err := r.Stop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_run_PostStop(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// eg errgroup.Group +// loader service.Loader +// client grpc.Client +// } +// 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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 { +// ctx:nil, +// }, +// fields: fields { +// eg:nil, +// loader:nil, +// client: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 +// } +// r := &run{ +// eg: test.fields.eg, +// loader: test.fields.loader, +// client: test.fields.client, +// } +// +// err := r.PostStop(test.args.ctx) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } // }) // } // } diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 59ff70724e..787aebcaa7 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "async-stream" @@ -59,9 +59,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", @@ -121,9 +121,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -157,21 +157,21 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bytes" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "cc" -version = "1.0.97" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" [[package]] name = "cfg-if" @@ -191,9 +191,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.122" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb497fad022245b29c2a0351df572e2d67c1046bcef2260ebc022aec81efea82" +checksum = "273dcfd3acd4e1e276af13ed2a43eea7001318823e7a726a6b3ed39b4acc0b82" dependencies = [ "cc", "cxxbridge-flags", @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.122" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9327c7f9fbd6329a200a5d4aa6f674c60ab256525ff0084b52a889d4e4c60cee" +checksum = "d8b2766fbd92be34e9ed143898fce6c572dc009de39506ed6903e5a05b68914e" dependencies = [ "cc", "codespan-reporting", @@ -218,15 +218,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.122" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c799a4a846f1c0acb9f36bb9c6272d9b3d9457f3633c7753c6057270df13c" +checksum = "839fcd5e43464614ffaa989eaf1c139ef1f0c51672a1ed08023307fa1b909ccd" [[package]] name = "cxxbridge-macro" -version = "1.0.122" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928bc249a7e3cd554fd2e8e08a426e9670c50bbfc9a621653cfa9accc9641783" +checksum = "4b2c1c1776b986979be68bb2285da855f8d8a35851a769fca8740df7c3d07877" dependencies = [ "proc-macro2", "quote", @@ -235,9 +235,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "equivalent" @@ -247,9 +247,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -313,9 +313,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "h2" @@ -378,9 +378,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -390,9 +390,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -467,9 +467,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "link-cplusplus" @@ -482,9 +482,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" @@ -504,9 +504,9 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miette" @@ -547,22 +547,23 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -583,21 +584,11 @@ dependencies = [ "rand", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" -version = "0.32.2" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] @@ -616,9 +607,9 @@ checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -634,7 +625,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -683,18 +674,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "prost" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", "prost-derive", @@ -702,9 +693,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", "itertools", @@ -715,9 +706,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ "prost", ] @@ -773,11 +764,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -792,7 +783,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -801,9 +792,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "scopeguard" @@ -819,18 +810,18 @@ checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -900,9 +891,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "syn" -version = "2.0.61" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -947,18 +938,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -967,21 +958,20 @@ dependencies = [ [[package]] name = "tokio" -version = "1.37.0" +version = "1.39.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -996,9 +986,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -1151,9 +1141,9 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "want" @@ -1194,7 +1184,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1214,18 +1204,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -1236,9 +1226,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -1248,9 +1238,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -1260,15 +1250,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -1278,9 +1268,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -1290,9 +1280,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -1302,9 +1292,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -1314,6 +1304,6 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/rust/bin/agent/src/handler/index.rs b/rust/bin/agent/src/handler/index.rs index af0ac55d01..67888ee91d 100644 --- a/rust/bin/agent/src/handler/index.rs +++ b/rust/bin/agent/src/handler/index.rs @@ -16,6 +16,7 @@ use proto::{ core::v1::agent_server, payload::v1::{control, info, object, Empty}, + vald::v1::index_server, }; #[tonic::async_trait] @@ -41,7 +42,10 @@ impl agent_server::Agent for super::Agent { ) -> std::result::Result, tonic::Status> { todo!() } +} +#[tonic::async_trait] +impl index_server::Index for super::Agent { #[doc = " Represent the RPC to get the agent index information.\n"] async fn index_info( &self, @@ -50,11 +54,26 @@ impl agent_server::Agent for super::Agent { todo!() } - #[doc = " Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process\n"] - async fn get_timestamp( + #[doc = " Represent the RPC to get the agent index detailed information.\n"] + async fn index_detail( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status> { + todo!() + } + #[doc = " Represent the RPC to get the agent index statistics.\n"] + async fn index_statistics( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status> { + todo!() + } + + #[doc = " Represent the RPC to get the agent index detailed statistics.\n"] + async fn index_statistics_detail( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status> { + request: tonic::Request, + ) -> std::result::Result, tonic::Status> { todo!() } } diff --git a/rust/libs/proto/src/core.v1.tonic.rs b/rust/libs/proto/src/core.v1.tonic.rs index ba50ab8380..b021552c00 100644 --- a/rust/libs/proto/src/core.v1.tonic.rs +++ b/rust/libs/proto/src/core.v1.tonic.rs @@ -123,6 +123,8 @@ pub mod agent_client { req.extensions_mut().insert(GrpcMethod::new("core.v1.Agent", "CreateIndex")); self.inner.unary(req, path, codec).await } + /** Represent the saving index RPC. +*/ pub async fn save_index( &mut self, request: impl tonic::IntoRequest, @@ -174,59 +176,6 @@ pub mod agent_client { .insert(GrpcMethod::new("core.v1.Agent", "CreateAndSaveIndex")); self.inner.unary(req, path, codec).await } - /** Represent the RPC to get the agent index information. -*/ - pub async fn index_info( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/core.v1.Agent/IndexInfo"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("core.v1.Agent", "IndexInfo")); - self.inner.unary(req, path, codec).await - } - /** Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process -*/ - pub async fn get_timestamp( - &mut self, - request: impl tonic::IntoRequest< - super::super::super::payload::v1::object::GetTimestampRequest, - >, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/core.v1.Agent/GetTimestamp", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("core.v1.Agent", "GetTimestamp")); - self.inner.unary(req, path, codec).await - } } } /// Generated server implementations. @@ -245,6 +194,8 @@ pub mod agent_server { tonic::Response, tonic::Status, >; + /** Represent the saving index RPC. +*/ async fn save_index( &self, request: tonic::Request, @@ -263,26 +214,6 @@ pub mod agent_server { tonic::Response, tonic::Status, >; - /** Represent the RPC to get the agent index information. -*/ - async fn index_info( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /** Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process -*/ - async fn get_timestamp( - &self, - request: tonic::Request< - super::super::super::payload::v1::object::GetTimestampRequest, - >, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; } #[derive(Debug)] pub struct AgentServer { @@ -510,104 +441,6 @@ pub mod agent_server { }; Box::pin(fut) } - "/core.v1.Agent/IndexInfo" => { - #[allow(non_camel_case_types)] - struct IndexInfoSvc(pub Arc); - impl< - T: Agent, - > tonic::server::UnaryService< - super::super::super::payload::v1::Empty, - > for IndexInfoSvc { - type Response = super::super::super::payload::v1::info::index::Count; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::super::super::payload::v1::Empty, - >, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::index_info(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = IndexInfoSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/core.v1.Agent/GetTimestamp" => { - #[allow(non_camel_case_types)] - struct GetTimestampSvc(pub Arc); - impl< - T: Agent, - > tonic::server::UnaryService< - super::super::super::payload::v1::object::GetTimestampRequest, - > for GetTimestampSvc { - type Response = super::super::super::payload::v1::object::Timestamp; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::super::super::payload::v1::object::GetTimestampRequest, - >, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_timestamp(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = GetTimestampSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } _ => { Box::pin(async move { Ok( diff --git a/rust/libs/proto/src/manager.index.v1.rs b/rust/libs/proto/src/manager.index.v1.rs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/rust/libs/proto/src/manager.index.v1.tonic.rs b/rust/libs/proto/src/manager.index.v1.tonic.rs deleted file mode 100644 index 84255cb3a5..0000000000 --- a/rust/libs/proto/src/manager.index.v1.tonic.rs +++ /dev/null @@ -1,312 +0,0 @@ -// -// 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. -// -pub mod index_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - use tonic::codegen::http::Uri; - #[derive(Debug, Clone)] - pub struct IndexClient { - inner: tonic::client::Grpc, - } - impl IndexClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl IndexClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> IndexClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + Send + Sync, - { - IndexClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - pub async fn index_info( - &mut self, - request: impl tonic::IntoRequest< - super::super::super::super::payload::v1::Empty, - >, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/manager.index.v1.Index/IndexInfo", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("manager.index.v1.Index", "IndexInfo")); - self.inner.unary(req, path, codec).await - } - } -} -/// Generated server implementations. -pub mod index_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with IndexServer. - #[async_trait] - pub trait Index: Send + Sync + 'static { - async fn index_info( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - } - #[derive(Debug)] - pub struct IndexServer { - inner: _Inner, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - max_decoding_message_size: Option, - max_encoding_message_size: Option, - } - struct _Inner(Arc); - impl IndexServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - let inner = _Inner(inner); - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - max_decoding_message_size: None, - max_encoding_message_size: None, - } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.max_decoding_message_size = Some(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.max_encoding_message_size = Some(limit); - self - } - } - impl tonic::codegen::Service> for IndexServer - where - T: Index, - B: Body + Send + 'static, - B::Error: Into + Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - let inner = self.inner.clone(); - match req.uri().path() { - "/manager.index.v1.Index/IndexInfo" => { - #[allow(non_camel_case_types)] - struct IndexInfoSvc(pub Arc); - impl< - T: Index, - > tonic::server::UnaryService< - super::super::super::super::payload::v1::Empty, - > for IndexInfoSvc { - type Response = super::super::super::super::payload::v1::info::index::Count; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::super::super::super::payload::v1::Empty, - >, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::index_info(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = IndexInfoSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } - } - } - } - impl Clone for IndexServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - max_decoding_message_size: self.max_decoding_message_size, - max_encoding_message_size: self.max_encoding_message_size, - } - } - } - impl Clone for _Inner { - fn clone(&self) -> Self { - Self(Arc::clone(&self.0)) - } - } - impl std::fmt::Debug for _Inner { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self.0) - } - } - impl tonic::server::NamedService for IndexServer { - const NAME: &'static str = "manager.index.v1.Index"; - } -} diff --git a/rust/libs/proto/src/payload.v1.rs b/rust/libs/proto/src/payload.v1.rs index 25051403a4..40a2c08f78 100644 --- a/rust/libs/proto/src/payload.v1.rs +++ b/rust/libs/proto/src/payload.v1.rs @@ -444,7 +444,8 @@ pub mod remove { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct TimestampRequest { - /// The timestamp comparison list. If more than one is specified, the `AND` search is applied. + /// The timestamp comparison list. If more than one is specified, the `AND` + /// search is applied. #[prost(message, repeated, tag="1")] pub timestamps: ::prost::alloc::vec::Vec, } @@ -469,11 +470,13 @@ pub mod remove { Eq = 0, /// The timestamp is not equal to the specified value in the request. Ne = 1, - /// The timestamp is greater than or equal to the specified value in the request. + /// The timestamp is greater than or equal to the specified value in the + /// request. Ge = 2, /// The timestamp is greater than the specified value in the request. Gt = 3, - /// The timestamp is less than or equal to the specified value in the request. + /// The timestamp is less than or equal to the specified value in the + /// request. Le = 4, /// The timestamp is less than the specified value in the request. Lt = 5, @@ -611,7 +614,7 @@ pub mod object { /// Represent a request to fetch vector meta data. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] - pub struct GetTimestampRequest { + pub struct TimestampRequest { /// The vector ID to be fetched. #[prost(message, optional, tag="1")] pub id: ::core::option::Option, @@ -838,6 +841,20 @@ pub mod info { #[prost(bool, tag="4")] pub saving: bool, } + /// Represent the index count for each Agents message. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Detail { + /// count infos for each agents + #[prost(map="string, message", tag="1")] + pub counts: ::std::collections::HashMap<::prost::alloc::string::String, Count>, + /// index replica of vald cluster + #[prost(uint32, tag="2")] + pub replica: u32, + /// live agent replica of vald cluster + #[prost(uint32, tag="3")] + pub live_agents: u32, + } /// Represent the UUID message. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -860,6 +877,85 @@ pub mod info { pub uuid: ::prost::alloc::string::String, } } + /// Represents index Statistics + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct Statistics { + #[prost(bool, tag="1")] + pub valid: bool, + #[prost(int32, tag="2")] + pub median_indegree: i32, + #[prost(int32, tag="3")] + pub median_outdegree: i32, + #[prost(uint64, tag="4")] + pub max_number_of_indegree: u64, + #[prost(uint64, tag="5")] + pub max_number_of_outdegree: u64, + #[prost(uint64, tag="6")] + pub min_number_of_indegree: u64, + #[prost(uint64, tag="7")] + pub min_number_of_outdegree: u64, + #[prost(uint64, tag="8")] + pub mode_indegree: u64, + #[prost(uint64, tag="9")] + pub mode_outdegree: u64, + #[prost(uint64, tag="10")] + pub nodes_skipped_for_10_edges: u64, + #[prost(uint64, tag="11")] + pub nodes_skipped_for_indegree_distance: u64, + #[prost(uint64, tag="12")] + pub number_of_edges: u64, + #[prost(uint64, tag="13")] + pub number_of_indexed_objects: u64, + #[prost(uint64, tag="14")] + pub number_of_nodes: u64, + #[prost(uint64, tag="15")] + pub number_of_nodes_without_edges: u64, + #[prost(uint64, tag="16")] + pub number_of_nodes_without_indegree: u64, + #[prost(uint64, tag="17")] + pub number_of_objects: u64, + #[prost(uint64, tag="18")] + pub number_of_removed_objects: u64, + #[prost(uint64, tag="19")] + pub size_of_object_repository: u64, + #[prost(uint64, tag="20")] + pub size_of_refinement_object_repository: u64, + #[prost(double, tag="21")] + pub variance_of_indegree: f64, + #[prost(double, tag="22")] + pub variance_of_outdegree: f64, + #[prost(double, tag="23")] + pub mean_edge_length: f64, + #[prost(double, tag="24")] + pub mean_edge_length_for_10_edges: f64, + #[prost(double, tag="25")] + pub mean_indegree_distance_for_10_edges: f64, + #[prost(double, tag="26")] + pub mean_number_of_edges_per_node: f64, + #[prost(double, tag="27")] + pub c1_indegree: f64, + #[prost(double, tag="28")] + pub c5_indegree: f64, + #[prost(double, tag="29")] + pub c95_outdegree: f64, + #[prost(double, tag="30")] + pub c99_outdegree: f64, + #[prost(int64, repeated, tag="31")] + pub indegree_count: ::prost::alloc::vec::Vec, + #[prost(uint64, repeated, tag="32")] + pub outdegree_histogram: ::prost::alloc::vec::Vec, + #[prost(uint64, repeated, tag="33")] + pub indegree_histogram: ::prost::alloc::vec::Vec, + } + /// Represents index Statistics for each Agents + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] + pub struct StatisticsDetail { + /// count infos for each agents + #[prost(map="string, message", tag="1")] + pub details: ::std::collections::HashMap<::prost::alloc::string::String, Statistics>, + } } /// Represent the pod information message. #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/rust/libs/proto/src/vald.v1.tonic.rs b/rust/libs/proto/src/vald.v1.tonic.rs index 32d1d10e7b..1ff23e3b46 100644 --- a/rust/libs/proto/src/vald.v1.tonic.rs +++ b/rust/libs/proto/src/vald.v1.tonic.rs @@ -1651,6 +1651,557 @@ pub mod flush_server { } } /// Generated client implementations. +pub mod index_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + #[derive(Debug, Clone)] + pub struct IndexClient { + inner: tonic::client::Grpc, + } + impl IndexClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl IndexClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + Send + 'static, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> IndexClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + Send + Sync, + { + IndexClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + pub async fn index_info( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/vald.v1.Index/IndexInfo"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("vald.v1.Index", "IndexInfo")); + self.inner.unary(req, path, codec).await + } + /** Represent the RPC to get the index information for each agents. +*/ + pub async fn index_detail( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/vald.v1.Index/IndexDetail", + ); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("vald.v1.Index", "IndexDetail")); + self.inner.unary(req, path, codec).await + } + /** Represent the RPC to get the index statistics. +*/ + pub async fn index_statistics( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/vald.v1.Index/IndexStatistics", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("vald.v1.Index", "IndexStatistics")); + self.inner.unary(req, path, codec).await + } + /** Represent the RPC to get the index statistics for each agents. +*/ + pub async fn index_statistics_detail( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response< + super::super::super::payload::v1::info::index::StatisticsDetail, + >, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/vald.v1.Index/IndexStatisticsDetail", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("vald.v1.Index", "IndexStatisticsDetail")); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod index_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with IndexServer. + #[async_trait] + pub trait Index: Send + Sync + 'static { + async fn index_info( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /** Represent the RPC to get the index information for each agents. +*/ + async fn index_detail( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /** Represent the RPC to get the index statistics. +*/ + async fn index_statistics( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /** Represent the RPC to get the index statistics for each agents. +*/ + async fn index_statistics_detail( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response< + super::super::super::payload::v1::info::index::StatisticsDetail, + >, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct IndexServer { + inner: _Inner, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + struct _Inner(Arc); + impl IndexServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + let inner = _Inner(inner); + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for IndexServer + where + T: Index, + B: Body + Send + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/vald.v1.Index/IndexInfo" => { + #[allow(non_camel_case_types)] + struct IndexInfoSvc(pub Arc); + impl< + T: Index, + > tonic::server::UnaryService< + super::super::super::payload::v1::Empty, + > for IndexInfoSvc { + type Response = super::super::super::payload::v1::info::index::Count; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::super::super::payload::v1::Empty, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::index_info(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = IndexInfoSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/vald.v1.Index/IndexDetail" => { + #[allow(non_camel_case_types)] + struct IndexDetailSvc(pub Arc); + impl< + T: Index, + > tonic::server::UnaryService< + super::super::super::payload::v1::Empty, + > for IndexDetailSvc { + type Response = super::super::super::payload::v1::info::index::Detail; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::super::super::payload::v1::Empty, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::index_detail(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = IndexDetailSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/vald.v1.Index/IndexStatistics" => { + #[allow(non_camel_case_types)] + struct IndexStatisticsSvc(pub Arc); + impl< + T: Index, + > tonic::server::UnaryService< + super::super::super::payload::v1::Empty, + > for IndexStatisticsSvc { + type Response = super::super::super::payload::v1::info::index::Statistics; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::super::super::payload::v1::Empty, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::index_statistics(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = IndexStatisticsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/vald.v1.Index/IndexStatisticsDetail" => { + #[allow(non_camel_case_types)] + struct IndexStatisticsDetailSvc(pub Arc); + impl< + T: Index, + > tonic::server::UnaryService< + super::super::super::payload::v1::Empty, + > for IndexStatisticsDetailSvc { + type Response = super::super::super::payload::v1::info::index::StatisticsDetail; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::super::super::payload::v1::Empty, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::index_statistics_detail(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = IndexStatisticsDetailSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } + } + } + } + impl Clone for IndexServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(Arc::clone(&self.0)) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::server::NamedService for IndexServer { + const NAME: &'static str = "vald.v1.Index"; + } +} +/// Generated client implementations. pub mod insert_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] use tonic::codegen::*; @@ -2248,8 +2799,6 @@ pub mod object_client { req.extensions_mut().insert(GrpcMethod::new("vald.v1.Object", "Exists")); self.inner.unary(req, path, codec).await } - /** A method to fetch a vector. -*/ pub async fn get_object( &mut self, request: impl tonic::IntoRequest< @@ -2340,6 +2889,35 @@ pub mod object_client { .insert(GrpcMethod::new("vald.v1.Object", "StreamListObject")); self.inner.server_streaming(req, path, codec).await } + /** Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process +*/ + pub async fn get_timestamp( + &mut self, + request: impl tonic::IntoRequest< + super::super::super::payload::v1::object::TimestampRequest, + >, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/vald.v1.Object/GetTimestamp", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("vald.v1.Object", "GetTimestamp")); + self.inner.unary(req, path, codec).await + } } } /// Generated server implementations. @@ -2356,8 +2934,6 @@ pub mod object_server { tonic::Response, tonic::Status, >; - /** A method to fetch a vector. -*/ async fn get_object( &self, request: tonic::Request< @@ -2407,6 +2983,17 @@ pub mod object_server { tonic::Response, tonic::Status, >; + /** Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process +*/ + async fn get_timestamp( + &self, + request: tonic::Request< + super::super::super::payload::v1::object::TimestampRequest, + >, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } #[derive(Debug)] pub struct ObjectServer { @@ -2687,6 +3274,55 @@ pub mod object_server { }; Box::pin(fut) } + "/vald.v1.Object/GetTimestamp" => { + #[allow(non_camel_case_types)] + struct GetTimestampSvc(pub Arc); + impl< + T: Object, + > tonic::server::UnaryService< + super::super::super::payload::v1::object::TimestampRequest, + > for GetTimestampSvc { + type Response = super::super::super::payload::v1::object::Timestamp; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::super::super::payload::v1::object::TimestampRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_timestamp(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = GetTimestampSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } _ => { Box::pin(async move { Ok( diff --git a/tests/e2e/hdf5/hdf5.go b/tests/e2e/hdf5/hdf5.go index 4ebd9c0cb4..3a8745c244 100644 --- a/tests/e2e/hdf5/hdf5.go +++ b/tests/e2e/hdf5/hdf5.go @@ -19,9 +19,7 @@ // package hdf5 provides hdf5 utilities for e2e testing package hdf5 -import ( - "gonum.org/v1/hdf5" -) +import "gonum.org/v1/hdf5" type Dataset struct { Train [][]float32 diff --git a/tests/e2e/kubernetes/client/client.go b/tests/e2e/kubernetes/client/client.go index e97aba2d01..60d1441ed8 100644 --- a/tests/e2e/kubernetes/client/client.go +++ b/tests/e2e/kubernetes/client/client.go @@ -102,15 +102,12 @@ func New(kubeConfig string) (Client, error) { } func (cli *client) Portforward( - namespace, podName string, - localPort, podPort int, + namespace, podName string, localPort, podPort int, ) *portforward.Portforward { return portforward.New(cli.rest, namespace, podName, localPort, podPort) } -func (cli *client) GetPod( - ctx context.Context, - namespace, +func (cli *client) GetPod(ctx context.Context, namespace, name string, ) (*corev1.Pod, error) { pod, err := cli.clientset.CoreV1().Pods( @@ -123,9 +120,7 @@ func (cli *client) GetPod( } func (cli *client) GetPods( - ctx context.Context, - namespace string, - labelSelector string, + ctx context.Context, namespace string, labelSelector string, ) ([]corev1.Pod, error) { pods, err := cli.clientset.CoreV1().Pods( namespace, @@ -139,10 +134,7 @@ func (cli *client) GetPods( return pods.Items, nil } -func (cli *client) DeletePod( - ctx context.Context, - namespace, name string, -) error { +func (cli *client) DeletePod(ctx context.Context, namespace, name string) error { cli.clientset.CoreV1().Pods( namespace, ).Delete(ctx, name, metav1.DeleteOptions{}) @@ -151,9 +143,7 @@ func (cli *client) DeletePod( } func (cli *client) WaitForPodReady( - ctx context.Context, - namespace, name string, - timeout time.Duration, + ctx context.Context, namespace, name string, timeout time.Duration, ) (ok bool, err error) { ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel() @@ -184,7 +174,9 @@ func (cli *client) WaitForPodReady( } } -func (cli *client) ListCronJob(ctx context.Context, namespace, labelSelector string) ([]v1.CronJob, error) { +func (cli *client) ListCronJob( + ctx context.Context, namespace, labelSelector string, +) ([]v1.CronJob, error) { cronJobs, err := cli.clientset.BatchV1().CronJobs(namespace).List(ctx, metav1.ListOptions{ LabelSelector: labelSelector, }) @@ -195,7 +187,9 @@ func (cli *client) ListCronJob(ctx context.Context, namespace, labelSelector str return cronJobs.Items, nil } -func (cli *client) CreateJobFromCronJob(ctx context.Context, name, namespace string, cronJob *v1.CronJob) error { +func (cli *client) CreateJobFromCronJob( + ctx context.Context, name, namespace string, cronJob *v1.CronJob, +) error { job := &v1.Job{ ObjectMeta: metav1.ObjectMeta{ Name: name, diff --git a/tests/e2e/kubernetes/kubectl/kubectl.go b/tests/e2e/kubernetes/kubectl/kubectl.go index a09725a5f1..f50e396bfc 100644 --- a/tests/e2e/kubernetes/kubectl/kubectl.go +++ b/tests/e2e/kubernetes/kubectl/kubectl.go @@ -41,7 +41,9 @@ func RolloutResource(ctx context.Context, t *testing.T, resource string) error { } // WaitResources waits for multiple resources to be ready. -func WaitResources(ctx context.Context, t *testing.T, resource, labelSelector, condition, timeout string) error { +func WaitResources( + ctx context.Context, t *testing.T, resource, labelSelector, condition, timeout string, +) error { t.Helper() cmd := exec.CommandContext(ctx, "kubectl", "wait", "--for=condition="+condition, "-l", labelSelector, "--timeout", timeout, resource) diff --git a/tests/e2e/operation/job.go b/tests/e2e/operation/job.go index d98bfeca53..2a9e2efbec 100644 --- a/tests/e2e/operation/job.go +++ b/tests/e2e/operation/job.go @@ -22,6 +22,22 @@ import ( "testing" ) +type JobExecutor interface { + CreateAndWait(t *testing.T, ctx context.Context, jobName string) error +} + +type cronJobExecute struct { + cronJob string +} + +var _ JobExecutor = (*cronJobExecute)(nil) + +func NewCronJobExecutor(cronJob string) JobExecutor { + return &cronJobExecute{ + cronJob: cronJob, + } +} + func (j *cronJobExecute) CreateAndWait(t *testing.T, ctx context.Context, jobName string) error { if err := createJob(t, jobName, j.cronJob); err != nil { return err diff --git a/tests/e2e/operation/operation.go b/tests/e2e/operation/operation.go index 592b07a9c6..62e9a794d0 100644 --- a/tests/e2e/operation/operation.go +++ b/tests/e2e/operation/operation.go @@ -174,7 +174,7 @@ func (c *client) SaveIndex(t *testing.T, ctx context.Context) error { } func (c *client) IndexInfo(t *testing.T, ctx context.Context) (*payload.Info_Index_Count, error) { - client, err := c.getAgentClient(ctx) + client, err := c.getClient(ctx) if err != nil { return nil, err } @@ -229,19 +229,3 @@ func (c *client) recall(results []string, neighbors []int) (recall float64) { return recall / float64(len(neighbors)) } - -type JobExecutor interface { - CreateAndWait(t *testing.T, ctx context.Context, jobName string) error -} - -type cronJobExecute struct { - cronJob string -} - -var _ JobExecutor = (*cronJobExecute)(nil) - -func NewCronJobExecutor(cronJob string) JobExecutor { - return &cronJobExecute{ - cronJob: cronJob, - } -} diff --git a/tests/e2e/operation/stream.go b/tests/e2e/operation/stream.go index dac182d975..f606c67f1a 100644 --- a/tests/e2e/operation/stream.go +++ b/tests/e2e/operation/stream.go @@ -1093,11 +1093,7 @@ func (c *client) Exists(t *testing.T, ctx context.Context, id string) error { return nil } -func (c *client) GetObject( - t *testing.T, - ctx context.Context, - ds Dataset, -) (rerr error) { +func (c *client) GetObject(t *testing.T, ctx context.Context, ds Dataset) (rerr error) { t.Log("getObject operation started") client, err := c.getClient(ctx) @@ -1187,11 +1183,7 @@ func (c *client) GetObject( return rerr } -func (c *client) StreamListObject( - t *testing.T, - ctx context.Context, - ds Dataset, -) error { +func (c *client) StreamListObject(t *testing.T, ctx context.Context, ds Dataset) error { t.Log("StreamListObject operation started") client, err := c.getClient(ctx) diff --git a/versions/DOCKER_VERSION b/versions/DOCKER_VERSION new file mode 100644 index 0000000000..96e099462d --- /dev/null +++ b/versions/DOCKER_VERSION @@ -0,0 +1 @@ +v27.1.1 diff --git a/versions/GOLANGCILINT_VERSION b/versions/GOLANGCILINT_VERSION index f399a6f2bc..be33d89791 100644 --- a/versions/GOLANGCILINT_VERSION +++ b/versions/GOLANGCILINT_VERSION @@ -1 +1 @@ -v1.58.0 +v1.59.1 diff --git a/versions/GO_VERSION b/versions/GO_VERSION index 89144dbc38..da9594fd66 100644 --- a/versions/GO_VERSION +++ b/versions/GO_VERSION @@ -1 +1 @@ -1.22.3 +1.22.5 diff --git a/versions/HDF5_VERSION b/versions/HDF5_VERSION index e459802679..85b169d0cb 100644 --- a/versions/HDF5_VERSION +++ b/versions/HDF5_VERSION @@ -1 +1 @@ -hdf5-1_14_3 +hdf5_1.14.4.3 diff --git a/versions/HELM_DOCS_VERSION b/versions/HELM_DOCS_VERSION index b50dd27dd9..a4cc55716f 100644 --- a/versions/HELM_DOCS_VERSION +++ b/versions/HELM_DOCS_VERSION @@ -1 +1 @@ -1.13.1 +1.14.2 diff --git a/versions/HELM_VERSION b/versions/HELM_VERSION index 362617ca87..de3e42fc29 100644 --- a/versions/HELM_VERSION +++ b/versions/HELM_VERSION @@ -1 +1 @@ -v3.14.4 +v3.15.3 diff --git a/versions/JAEGER_OPERATOR_VERSION b/versions/JAEGER_OPERATOR_VERSION index 261d95596f..99aed793ad 100644 --- a/versions/JAEGER_OPERATOR_VERSION +++ b/versions/JAEGER_OPERATOR_VERSION @@ -1 +1 @@ -2.53.0 +2.54.0 diff --git a/versions/K3S_VERSION b/versions/K3S_VERSION index 6e9db4b4bb..e777e8936c 100644 --- a/versions/K3S_VERSION +++ b/versions/K3S_VERSION @@ -1 +1 @@ -v1.29.4-k3s1 +v1.30.2-k3s2 diff --git a/versions/KIND_VERSION b/versions/KIND_VERSION index 2157409059..ca222b7cf3 100644 --- a/versions/KIND_VERSION +++ b/versions/KIND_VERSION @@ -1 +1 @@ -0.22.0 +0.23.0 diff --git a/versions/KUBECTL_VERSION b/versions/KUBECTL_VERSION index 3aceb49678..062a7525f1 100644 --- a/versions/KUBECTL_VERSION +++ b/versions/KUBECTL_VERSION @@ -1 +1 @@ -v1.30.0 \ No newline at end of file +v1.30.3 \ No newline at end of file diff --git a/versions/NGT_VERSION b/versions/NGT_VERSION index c043eea776..530cdd91a2 100644 --- a/versions/NGT_VERSION +++ b/versions/NGT_VERSION @@ -1 +1 @@ -2.2.1 +2.2.4 diff --git a/versions/OPERATOR_SDK_VERSION b/versions/OPERATOR_SDK_VERSION index e51138b8af..251643f6ba 100644 --- a/versions/OPERATOR_SDK_VERSION +++ b/versions/OPERATOR_SDK_VERSION @@ -1 +1 @@ -v1.34 +v1.35 diff --git a/versions/PROMETHEUS_STACK_VERSION b/versions/PROMETHEUS_STACK_VERSION index 18365ff7ad..d16771deca 100644 --- a/versions/PROMETHEUS_STACK_VERSION +++ b/versions/PROMETHEUS_STACK_VERSION @@ -1 +1 @@ -58.4.0 +61.3.2 diff --git a/versions/PROTOBUF_VERSION b/versions/PROTOBUF_VERSION index dfa88c8ebb..40682b3dcc 100644 --- a/versions/PROTOBUF_VERSION +++ b/versions/PROTOBUF_VERSION @@ -1 +1 @@ -26.1 +27.2 diff --git a/versions/REVIEWDOG_VERSION b/versions/REVIEWDOG_VERSION index 8acb5ca441..2c80271d5a 100644 --- a/versions/REVIEWDOG_VERSION +++ b/versions/REVIEWDOG_VERSION @@ -1 +1 @@ -v0.17.4 +v0.20.1 diff --git a/versions/TELEPRESENCE_VERSION b/versions/TELEPRESENCE_VERSION index cf8690732f..b8e248f40b 100644 --- a/versions/TELEPRESENCE_VERSION +++ b/versions/TELEPRESENCE_VERSION @@ -1 +1 @@ -2.18.0 +2.19.1 diff --git a/versions/YQ_VERSION b/versions/YQ_VERSION index ec877613c7..77b34ac509 100644 --- a/versions/YQ_VERSION +++ b/versions/YQ_VERSION @@ -1 +1 @@ -v4.43.1 +v4.44.2 diff --git a/versions/actions/ACTIONS_CHECKOUT b/versions/actions/ACTIONS_CHECKOUT index a95f288444..9edf2a44f4 100644 --- a/versions/actions/ACTIONS_CHECKOUT +++ b/versions/actions/ACTIONS_CHECKOUT @@ -1 +1 @@ -4.1.4 +4.1.7 diff --git a/versions/actions/ACTIONS_DOWNLOAD_ARTIFACT b/versions/actions/ACTIONS_DOWNLOAD_ARTIFACT index 9edf2a44f4..a7c00da34f 100644 --- a/versions/actions/ACTIONS_DOWNLOAD_ARTIFACT +++ b/versions/actions/ACTIONS_DOWNLOAD_ARTIFACT @@ -1 +1 @@ -4.1.7 +4.1.8 diff --git a/versions/actions/ACTIONS_SETUP_GO b/versions/actions/ACTIONS_SETUP_GO index 6b244dcd69..a1ef0cae18 100644 --- a/versions/actions/ACTIONS_SETUP_GO +++ b/versions/actions/ACTIONS_SETUP_GO @@ -1 +1 @@ -5.0.1 +5.0.2 diff --git a/versions/actions/ACTIONS_SETUP_NODE b/versions/actions/ACTIONS_SETUP_NODE index 4d54daddb6..c4e41f9459 100644 --- a/versions/actions/ACTIONS_SETUP_NODE +++ b/versions/actions/ACTIONS_SETUP_NODE @@ -1 +1 @@ -4.0.2 +4.0.3 diff --git a/versions/actions/ACTIONS_UPLOAD_ARTIFACT b/versions/actions/ACTIONS_UPLOAD_ARTIFACT index e91d9be2a8..eda862a98c 100644 --- a/versions/actions/ACTIONS_UPLOAD_ARTIFACT +++ b/versions/actions/ACTIONS_UPLOAD_ARTIFACT @@ -1 +1 @@ -4.3.3 +4.3.4 diff --git a/versions/actions/CODECOV_CODECOV_ACTION b/versions/actions/CODECOV_CODECOV_ACTION index f77856a6f1..a84947d6ff 100644 --- a/versions/actions/CODECOV_CODECOV_ACTION +++ b/versions/actions/CODECOV_CODECOV_ACTION @@ -1 +1 @@ -4.3.1 +4.5.0 diff --git a/versions/actions/DOCKER_LOGIN_ACTION b/versions/actions/DOCKER_LOGIN_ACTION index fd2a01863f..15a2799817 100644 --- a/versions/actions/DOCKER_LOGIN_ACTION +++ b/versions/actions/DOCKER_LOGIN_ACTION @@ -1 +1 @@ -3.1.0 +3.3.0 diff --git a/versions/actions/DOCKER_SETUP_BUILDX_ACTION b/versions/actions/DOCKER_SETUP_BUILDX_ACTION index 15a2799817..1545d96657 100644 --- a/versions/actions/DOCKER_SETUP_BUILDX_ACTION +++ b/versions/actions/DOCKER_SETUP_BUILDX_ACTION @@ -1 +1 @@ -3.3.0 +3.5.0 diff --git a/versions/actions/DOCKER_SETUP_QEMU_ACTION b/versions/actions/DOCKER_SETUP_QEMU_ACTION index 4a36342fca..944880fa15 100644 --- a/versions/actions/DOCKER_SETUP_QEMU_ACTION +++ b/versions/actions/DOCKER_SETUP_QEMU_ACTION @@ -1 +1 @@ -3.0.0 +3.2.0 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE b/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE index 94dc0ec910..a36e9b0906 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE +++ b/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE @@ -1 +1 @@ -2.17.2 +2.18.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD b/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD index 94dc0ec910..a36e9b0906 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD +++ b/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD @@ -1 +1 @@ -2.17.2 +2.18.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_INIT b/versions/actions/GITHUB_CODEQL_ACTION_INIT index 94dc0ec910..a36e9b0906 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_INIT +++ b/versions/actions/GITHUB_CODEQL_ACTION_INIT @@ -1 +1 @@ -2.17.2 +2.18.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF b/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF index 94dc0ec910..a36e9b0906 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF +++ b/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF @@ -1 +1 @@ -2.17.2 +2.18.1 diff --git a/versions/actions/GITHUB_ISSUE_METRICS b/versions/actions/GITHUB_ISSUE_METRICS index 18091983f5..19811903a7 100644 --- a/versions/actions/GITHUB_ISSUE_METRICS +++ b/versions/actions/GITHUB_ISSUE_METRICS @@ -1 +1 @@ -3.4.0 +3.8.0 diff --git a/versions/actions/REVIEWDOG_ACTION_HADOLINT b/versions/actions/REVIEWDOG_ACTION_HADOLINT index f86fb9cbcf..50aceaa7b7 100644 --- a/versions/actions/REVIEWDOG_ACTION_HADOLINT +++ b/versions/actions/REVIEWDOG_ACTION_HADOLINT @@ -1 +1 @@ -1.41.1 +1.45.0 diff --git a/versions/actions/REVIEWDOG_ACTION_LANGUAGETOOL b/versions/actions/REVIEWDOG_ACTION_LANGUAGETOOL index 850e742404..815d5ca06d 100644 --- a/versions/actions/REVIEWDOG_ACTION_LANGUAGETOOL +++ b/versions/actions/REVIEWDOG_ACTION_LANGUAGETOOL @@ -1 +1 @@ -1.14.0 +1.19.0 diff --git a/versions/actions/SOFTPROPS_ACTION_GH_RELEASE b/versions/actions/SOFTPROPS_ACTION_GH_RELEASE index 3eefcb9dd5..815e68dd20 100644 --- a/versions/actions/SOFTPROPS_ACTION_GH_RELEASE +++ b/versions/actions/SOFTPROPS_ACTION_GH_RELEASE @@ -1 +1 @@ -1.0.0 +2.0.8