From 71d4feb0e89623a78dcb4ddba803a8ad0c5866a5 Mon Sep 17 00:00:00 2001 From: Hiroto Funakoshi Date: Fri, 26 Jul 2024 10:54:18 +0900 Subject: [PATCH 1/5] fix: deleted unnecessary event path for docker build (#2538) Signed-off-by: hlts2 --- .github/workflows/dockers-agent-faiss-image.yml | 16 ---------------- .github/workflows/dockers-agent-image.yml | 13 ------------- .github/workflows/dockers-agent-ngt-image.yml | 16 ---------------- .../workflows/dockers-agent-sidecar-image.yml | 16 ---------------- .../workflows/dockers-benchmark-job-image.yml | 16 ---------------- .../dockers-benchmark-operator-image.yaml | 16 ---------------- .../workflows/dockers-ci-container-image.yml | 9 --------- .../workflows/dockers-dev-container-image.yml | 9 --------- .../workflows/dockers-discoverer-k8s-image.yml | 14 -------------- .../workflows/dockers-gateway-filter-image.yml | 17 ----------------- .github/workflows/dockers-gateway-lb-image.yml | 17 ----------------- .../workflows/dockers-gateway-mirror-image.yaml | 16 ---------------- .../workflows/dockers-helm-operator-image.yml | 12 ------------ .github/workflows/dockers-index-correction.yml | 14 -------------- .github/workflows/dockers-index-creation.yml | 14 -------------- .github/workflows/dockers-index-operator.yml | 14 -------------- .github/workflows/dockers-index-save.yml | 14 -------------- .github/workflows/dockers-loadtest-image.yml | 15 --------------- .../workflows/dockers-manager-index-image.yml | 15 --------------- .../workflows/dockers-readreplica-rotate.yml | 14 -------------- 20 files changed, 287 deletions(-) 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-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" From 6ca9f1c40e4f06cf45e0d1736d345f5b68506dd7 Mon Sep 17 00:00:00 2001 From: Hiroto Funakoshi Date: Fri, 26 Jul 2024 12:09:36 +0900 Subject: [PATCH 2/5] fix: fix info path location (#2542) Signed-off-by: hlts2 --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From a0648c9ec022dd0ba0423f3af7de7cf7cbc24287 Mon Sep 17 00:00:00 2001 From: Hiroto Funakoshi Date: Fri, 26 Jul 2024 13:49:39 +0900 Subject: [PATCH 3/5] fix: add checkout option (#2545) Signed-off-by: hlts2 --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 669ca12962..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: | From 09258fb35a209cd35827577ad5fcbd77ac5fc7fa Mon Sep 17 00:00:00 2001 From: Yusuke Kato Date: Fri, 26 Jul 2024 15:36:49 +0900 Subject: [PATCH 4/5] Implement ngt Statistics API (#2539) Signed-off-by: kpango --- .gitfiles | 112 + .github/ISSUE_TEMPLATE/bug_report.md | 11 +- .../ISSUE_TEMPLATE/security_issue_report.md | 11 +- .github/PULL_REQUEST_TEMPLATE.md | 12 +- Makefile | 49 +- Makefile.d/bench.mk | 6 + Makefile.d/build.mk | 8 +- Makefile.d/dependencies.mk | 49 +- Makefile.d/functions.mk | 11 +- Makefile.d/proto.mk | 7 +- Makefile.d/test.mk | 22 +- apis/docs/v1/docs.md | 74 +- apis/grpc/v1/agent/core/agent.pb.go | 1 + apis/grpc/v1/agent/core/agent_vtproto.pb.go | 5 +- apis/grpc/v1/agent/sidecar/sidecar.pb.go | 18 +- .../v1/agent/sidecar/sidecar_vtproto.pb.go | 6 +- apis/grpc/v1/discoverer/discoverer.pb.go | 1 + .../v1/discoverer/discoverer_vtproto.pb.go | 5 +- .../grpc/v1/filter/egress/egress_filter.pb.go | 1 + .../filter/egress/egress_filter_vtproto.pb.go | 4 +- .../v1/filter/ingress/ingress_filter.pb.go | 1 + .../ingress/ingress_filter_vtproto.pb.go | 4 +- apis/grpc/v1/mirror/mirror.pb.go | 1 + apis/grpc/v1/mirror/mirror_vtproto.pb.go | 3 +- apis/grpc/v1/payload/payload.pb.go | 1122 +- apis/grpc/v1/payload/payload.pb.json.go | 20 + apis/grpc/v1/payload/payload_vtproto.pb.go | 2242 ++- .../v1/rpc/errdetails/error_details.pb.go | 65 +- .../errdetails/error_details_vtproto.pb.go | 27 + apis/grpc/v1/vald/filter.pb.go | 1 + apis/grpc/v1/vald/filter_vtproto.pb.go | 14 +- apis/grpc/v1/vald/flush.pb.go | 1 + apis/grpc/v1/vald/flush_vtproto.pb.go | 3 +- apis/grpc/v1/vald/index.pb.go | 51 +- apis/grpc/v1/vald/index_vtproto.pb.go | 94 +- apis/grpc/v1/vald/insert.pb.go | 1 + apis/grpc/v1/vald/insert_vtproto.pb.go | 5 +- apis/grpc/v1/vald/object.pb.go | 1 + apis/grpc/v1/vald/object_vtproto.pb.go | 7 +- apis/grpc/v1/vald/remove.pb.go | 1 + apis/grpc/v1/vald/remove_vtproto.pb.go | 6 +- apis/grpc/v1/vald/search.pb.go | 1 + apis/grpc/v1/vald/search_vtproto.pb.go | 14 +- apis/grpc/v1/vald/update.pb.go | 1 + apis/grpc/v1/vald/update_vtproto.pb.go | 5 +- apis/grpc/v1/vald/upsert.pb.go | 1 + apis/grpc/v1/vald/upsert_vtproto.pb.go | 5 +- apis/grpc/v1/vald/vald.go | 6 +- apis/proto/v1/payload/payload.proto | 52 +- apis/proto/v1/vald/index.proto | 9 + apis/swagger/v1/vald/index.swagger.json | 201 + apis/swagger/v1/vald/remove.swagger.json | 4 +- .../vald-helm-operator/crds/valdrelease.yaml | 2 + charts/vald/README.md | 1 + charts/vald/values.schema.json | 4 + charts/vald/values.yaml | 3 + cmd/agent/core/faiss/main_test.go | 86 + cmd/agent/core/ngt/main_test.go | 3 +- cmd/agent/sidecar/main_test.go | 3 +- cmd/discoverer/k8s/main_test.go | 3 +- cmd/gateway/filter/main_test.go | 3 +- cmd/gateway/lb/main_test.go | 3 +- cmd/gateway/mirror/main_test.go | 86 + cmd/index/job/correction/main_test.go | 3 +- cmd/index/job/creation/main_test.go | 3 +- cmd/index/job/readreplica/rotate/main_test.go | 3 +- cmd/index/job/save/main_test.go | 3 +- cmd/index/operator/main_test.go | 86 + cmd/manager/index/main_test.go | 3 +- cmd/tools/benchmark/job/main_test.go | 86 + cmd/tools/benchmark/operator/main_test.go | 86 + cmd/tools/cli/benchmark/core/main_test.go | 10 +- cmd/tools/cli/loadtest/main_test.go | 3 +- cmd/tools/cli/vdctl/main_test.go | 3 +- dockers/agent/core/agent/Dockerfile | 2 +- example/client/go.mod | 6 +- example/client/go.sum | 8 +- go.mod | 56 +- go.sum | 93 +- hack/benchmark/assets/x1b/loader_test.go | 15 - .../core/benchmark/benchmark_test.go | 4 +- hack/benchmark/core/benchmark/option_test.go | 2 - .../strategy/bulk_insert_commit_test.go | 1 - .../benchmark/strategy/bulk_insert_test.go | 1 - .../benchmark/strategy/get_vector_test.go | 1 - .../benchmark/strategy/insert_commit_test.go | 1 - .../core/benchmark/strategy/insert_test.go | 1 - .../core/benchmark/strategy/remove_test.go | 1 - .../core/benchmark/strategy/search_test.go | 1 - .../strategy/strategy_option_test.go | 8 - .../core/benchmark/strategy/strategy_test.go | 15 +- .../core/benchmark/strategy/util_test.go | 4 - .../benchmark/internal/assets/dataset_test.go | 1 - .../internal/core/algorithm/ngt/ngt_test.go | 5 +- .../core/algorithm/ngt/option_test.go | 3 - .../internal/operation/insert_test.go | 2 - .../internal/operation/operation_test.go | 4 +- .../internal/operation/option_test.go | 2 - .../internal/operation/remove_test.go | 6 +- .../internal/operation/search_test.go | 12 +- .../benchmark/internal/operation/util_test.go | 6 +- hack/helm/schema/crd/main_test.go | 8 +- hack/helm/schema/gen/main_test.go | 7 +- internal/backoff/backoff_test.go | 1 - internal/backoff/context_test.go | 3 - internal/cache/gache/option_test.go | 1 - internal/cache/option_test.go | 1 - internal/circuitbreaker/breaker_test.go | 10 +- internal/circuitbreaker/counter_test.go | 16 +- internal/circuitbreaker/manager_test.go | 3 - internal/circuitbreaker/options_test.go | 8 - internal/circuitbreaker/state_test.go | 1 - internal/circuitbreaker/tripper_test.go | 2 - .../v1/client/agent/core/client_test.go | 492 +- .../v1/client/agent/core/option_test.go | 3 - .../v1/client/discoverer/discover_test.go | 804 +- .../v1/client/discoverer/option_test.go | 179 +- .../v1/client/filter/egress/client_test.go | 11 - .../v1/client/filter/egress/option_test.go | 2 - .../v1/client/filter/ingress/client_test.go | 11 - .../v1/client/filter/ingress/option_test.go | 2 - .../client/v1/client/mirror/mirror_test.go | 517 + .../client/v1/client/mirror/option_test.go | 186 + internal/client/v1/client/vald/option_test.go | 2 - internal/client/v1/client/vald/vald.go | 68 + internal/client/v1/client/vald/vald_test.go | 1850 +- internal/compress/mock_test.go | 8 - internal/config/benchmark_test.go | 1404 ++ internal/config/circuitbreaker_test.go | 1 - internal/config/compress_test.go | 1 - internal/config/config_test.go | 2 + internal/config/corrector_test.go | 1 - internal/config/discoverer_test.go | 17 - internal/config/faiss_test.go | 176 + internal/config/index_creation_test.go | 1 - internal/config/index_operator_test.go | 136 + internal/config/index_save_test.go | 1 - internal/config/lb_test.go | 96 + internal/config/mirror_test.go | 140 + internal/config/ngt.go | 3 + internal/config/readreplica_rotate_test.go | 9 +- internal/conv/conv_test.go | 1 - internal/core/algorithm/ngt/ngt.go | 123 + internal/core/algorithm/ngt/ngt_test.go | 9 + internal/core/algorithm/ngt/option.go | 3 + internal/core/algorithm/ngt/option_test.go | 20 +- internal/db/kvs/bbolt/bbolt_test.go | 3 - internal/db/kvs/bbolt/option_test.go | 10 - internal/db/kvs/pogreb/pogreb_test.go | 3 - internal/db/kvs/redis/option_test.go | 5 - internal/db/rdb/mysql/mysql_test.go | 3 +- internal/db/rdb/mysql/option_test.go | 2 - .../blob/cloudstorage/cloudstorage_test.go | 5 - .../storage/blob/cloudstorage/option_test.go | 12 - .../cloudstorage/urlopener/option_test.go | 3 - .../cloudstorage/urlopener/urlopener_test.go | 2 - .../db/storage/blob/s3/reader/io/io_test.go | 3 - internal/encoding/json/json_test.go | 2 - internal/errors/blob_test.go | 2 - internal/errors/circuitbreaker_test.go | 6 - internal/errors/errors_test.go | 3 - internal/errors/faiss_test.go | 189 + internal/errors/file_test.go | 1 - internal/errors/ngt.go | 4 + internal/errors/ngt_test.go | 2 - internal/errors/redis_test.go | 1 - internal/file/file_test.go | 103 +- internal/hash/hash_test.go | 3 +- internal/info/info_test.go | 978 + internal/io/copy_test.go | 3 - internal/io/io_test.go | 3 - internal/k8s/client/client_test.go | 538 +- internal/k8s/client/option_test.go | 1 - internal/k8s/job/job_test.go | 799 + internal/k8s/job/option_test.go | 441 + internal/k8s/metrics/node/node_test.go | 10 +- internal/k8s/metrics/node/option_test.go | 7 - internal/k8s/metrics/pod/option_test.go | 7 - internal/k8s/metrics/pod/pod_test.go | 10 +- internal/k8s/node/node_test.go | 18 +- internal/k8s/node/option_test.go | 7 - internal/k8s/option_test.go | 117 +- internal/k8s/pod/option_test.go | 9 +- internal/k8s/pod/pod_test.go | 24 +- internal/k8s/reconciler_test.go | 156 +- internal/k8s/service/option_test.go | 7 - internal/k8s/service/service_test.go | 11 +- internal/k8s/v2/pod/option_test.go | 696 + internal/k8s/v2/pod/pod_test.go | 936 + .../vald/benchmark/api/v1/job_types_test.go | 1559 ++ .../benchmark/api/v1/scenario_types_test.go | 811 + .../benchmark/job/job_template_option_test.go | 1206 ++ .../vald/benchmark/job/job_template_test.go | 223 + internal/k8s/vald/benchmark/job/job_test.go | 912 + .../k8s/vald/benchmark/job/option_test.go | 441 + .../vald/benchmark/scenario/option_test.go | 441 + .../vald/benchmark/scenario/scenario_test.go | 912 + .../vald/mirror/api/v1/target_types_test.go | 992 + internal/log/glg/glg_test.go | 48 +- internal/log/log_test.go | 16 +- internal/log/mock/logger_test.go | 16 +- internal/log/zap/zap_test.go | 1 - internal/net/dialer_test.go | 1 - internal/net/grpc/client_test.go | 18 - internal/net/grpc/context_test.go | 3 - .../interceptor/client/metric/metric_test.go | 187 + .../server/logging/accesslog_test.go | 3 - .../interceptor/server/metric/metric_test.go | 1 - .../server/recover/recover_test.go | 2 - .../interceptor/server/trace/trace_test.go | 2 - internal/net/grpc/metadata_test.go | 193 + internal/net/grpc/option_test.go | 31 - internal/net/grpc/pool/option_test.go | 12 - internal/net/grpc/pool/pool_test.go | 207 +- internal/net/grpc/proto/proto_test.go | 1 - internal/net/grpc/status/status_test.go | 26 +- internal/net/grpc/stream_test.go | 1 - internal/net/http/metrics/pprof_test.go | 75 + internal/net/http/routing/router_test.go | 1 - internal/net/option_test.go | 2 - .../observability/attribute/attribute_test.go | 4 - .../exporter/otlp/option_test.go | 8 - .../observability/exporter/otlp/otlp_test.go | 5 - .../metrics/agent/core/faiss/faiss_test.go | 291 + .../metrics/agent/core/ngt/ngt.go | 865 +- .../metrics/agent/core/ngt/ngt_test.go | 19 +- .../metrics/agent/sidecar/sidecar_test.go | 11 +- .../metrics/backoff/backoff_test.go | 9 +- .../circuitbreaker/circuitbreaker_test.go | 9 +- .../metrics/gateway/mirror/mirror_test.go | 291 + .../observability/metrics/grpc/grpc_test.go | 9 +- .../index/job/correction/correction_test.go | 9 +- .../observability/metrics/info/info_test.go | 10 +- .../metrics/manager/index/index_test.go | 9 +- .../metrics/mem/index/index_test.go | 259 + .../observability/metrics/mem/mem_test.go | 445 + internal/observability/metrics/metrics.go | 3 + .../observability/metrics/metrics_test.go | 173 - .../metrics/runtime/cgo/cgo_test.go | 9 +- .../runtime/goroutine/goroutine_test.go | 9 +- .../metrics/tools/benchmark/benchmark_test.go | 2 + .../metrics/version/version_test.go | 10 +- internal/observability/observability_test.go | 5 - internal/observability/option_test.go | 4 - internal/observability/trace/status_test.go | 18 - internal/observability/trace/trace_test.go | 3 - internal/runner/runner_test.go | 1 - internal/safety/safety_test.go | 2 - internal/servers/server/option_test.go | 6 - internal/servers/starter/starter_test.go | 3 - internal/sync/errgroup/group_test.go | 12 +- internal/sync/semaphore/semaphore_test.go | 12 +- internal/test/data/hdf5/hdf5_test.go | 78 + internal/test/data/hdf5/option_test.go | 2 + internal/test/data/vector/gen_test.go | 7 - internal/test/goleak/goleak_test.go | 6 +- internal/timeutil/rate/rate_test.go | 207 + internal/tls/tls_test.go | 1 - internal/worker/worker_option_test.go | 4 - k8s/agent/ngt/configmap.yaml | 1 + k8s/operator/helm/crds/valdrelease.yaml | 2 + pkg/agent/core/faiss/config/config_test.go | 105 + .../core/faiss/handler/grpc/flush_test.go | 145 + .../core/faiss/handler/grpc/handler_test.go | 349 + .../core/faiss/handler/grpc/index_test.go | 532 + .../core/faiss/handler/grpc/insert_test.go | 396 + .../faiss/handler/grpc/linear_search_test.go | 776 + .../core/faiss/handler/grpc/object_test.go | 396 + .../core/faiss/handler/grpc/option_test.go | 441 + .../core/faiss/handler/grpc/remove_test.go | 396 + .../core/faiss/handler/grpc/search_test.go | 776 + .../core/faiss/handler/grpc/update_test.go | 396 + .../core/faiss/handler/grpc/upsert_test.go | 396 + .../core/faiss/handler/rest/handler_test.go | 1781 ++ .../core/faiss/handler/rest/option_test.go | 101 + pkg/agent/core/faiss/router/option_test.go | 271 + pkg/agent/core/faiss/router/router_test.go | 101 + pkg/agent/core/faiss/service/faiss_test.go | 8401 ++++++++ pkg/agent/core/faiss/service/option_test.go | 1121 ++ pkg/agent/core/faiss/usecase/agentd_test.go | 679 + pkg/agent/core/ngt/handler/grpc/flush_test.go | 145 + .../core/ngt/handler/grpc/handler_test.go | 243 + pkg/agent/core/ngt/handler/grpc/index.go | 32 + pkg/agent/core/ngt/handler/grpc/index_test.go | 387 + .../ngt/handler/grpc/linear_search_test.go | 6 - .../core/ngt/handler/grpc/object_test.go | 1 - .../core/ngt/handler/grpc/remove_test.go | 2 - .../core/ngt/handler/grpc/search_test.go | 4 - .../core/ngt/handler/grpc/update_test.go | 2 - .../core/ngt/handler/grpc/upsert_test.go | 2 - .../core/ngt/handler/rest/handler_test.go | 1781 ++ .../core/ngt/handler/rest/option_test.go | 101 + pkg/agent/core/ngt/service/ngt.go | 66 +- pkg/agent/core/ngt/service/ngt_test.go | 16210 +++++++++++++--- pkg/agent/core/ngt/service/option.go | 9 + pkg/agent/core/ngt/service/option_test.go | 255 + pkg/agent/core/ngt/usecase/agentd.go | 1 + pkg/agent/core/ngt/usecase/agentd_test.go | 573 + pkg/agent/internal/kvs/kvs_test.go | 84 + pkg/agent/internal/kvs/option_test.go | 1 - pkg/agent/internal/metadata/metadata_test.go | 2 - pkg/agent/internal/vqueue/queue_test.go | 25 +- pkg/agent/sidecar/config/config_test.go | 3 - .../sidecar/handler/grpc/handler_test.go | 1 - pkg/agent/sidecar/handler/grpc/option_test.go | 1 - .../sidecar/handler/rest/handler_test.go | 206 + pkg/agent/sidecar/handler/rest/option_test.go | 101 + pkg/agent/sidecar/router/option_test.go | 186 + pkg/agent/sidecar/router/router_test.go | 101 + .../sidecar/service/observer/observer_test.go | 1103 +- .../sidecar/service/observer/option_test.go | 8 - .../sidecar/service/restorer/option_test.go | 5 - .../sidecar/service/restorer/restorer_test.go | 241 +- .../sidecar/service/storage/option_test.go | 11 - .../sidecar/service/storage/storage_test.go | 286 +- .../initcontainer/initcontainer_test.go | 573 + .../sidecar/usecase/sidecar/sidecar_test.go | 573 + pkg/agent/sidecar/usecase/sidecard_test.go | 1 - pkg/discoverer/k8s/config/config_test.go | 1 - .../k8s/handler/grpc/handler_test.go | 181 +- .../k8s/handler/grpc/option_test.go | 3 - .../k8s/handler/rest/handler_test.go | 416 + .../k8s/handler/rest/option_test.go | 101 + pkg/discoverer/k8s/router/option_test.go | 271 + pkg/discoverer/k8s/router/router_test.go | 101 + pkg/discoverer/k8s/service/discover_test.go | 37 +- pkg/discoverer/k8s/service/option_test.go | 5 - pkg/discoverer/k8s/usecase/discovered_test.go | 613 + pkg/gateway/filter/config/config_test.go | 1 - .../filter/handler/grpc/handler_test.go | 215 +- .../filter/handler/grpc/option_test.go | 14 - .../filter/handler/rest/handler_test.go | 3041 +++ .../filter/handler/rest/option_test.go | 101 + pkg/gateway/filter/router/option_test.go | 186 + pkg/gateway/filter/router/router_test.go | 101 + pkg/gateway/filter/usecase/vald_test.go | 613 + pkg/gateway/lb/config/config_test.go | 1 - .../lb/handler/grpc/aggregation_test.go | 1853 +- pkg/gateway/lb/handler/grpc/handler.go | 298 +- pkg/gateway/lb/handler/grpc/handler_test.go | 2422 ++- pkg/gateway/lb/handler/grpc/option_test.go | 8 - .../lb/handler/grpc/pairing_heap_test.go | 104 +- pkg/gateway/lb/handler/rest/handler_test.go | 2201 +++ pkg/gateway/lb/handler/rest/option_test.go | 101 + pkg/gateway/lb/router/option_test.go | 186 + pkg/gateway/lb/router/router_test.go | 101 + pkg/gateway/lb/service/gateway_test.go | 15 +- pkg/gateway/lb/service/option_test.go | 2 - pkg/gateway/lb/usecase/vald_test.go | 573 + pkg/gateway/mirror/config/config_test.go | 105 + .../mirror/handler/grpc/handler_test.go | 3440 +++- .../mirror/handler/grpc/option_test.go | 611 + .../mirror/handler/rest/handler_test.go | 2306 +++ .../mirror/handler/rest/option_test.go | 101 + pkg/gateway/mirror/router/option_test.go | 186 + pkg/gateway/mirror/router/router_test.go | 101 + .../mirror/service/discovery_option_test.go | 781 + pkg/gateway/mirror/service/discovery_test.go | 1288 ++ pkg/gateway/mirror/service/gateway_test.go | 753 + .../mirror/service/mirror_option_test.go | 441 + pkg/gateway/mirror/service/mirror_test.go | 360 +- pkg/gateway/mirror/service/option_test.go | 271 + pkg/gateway/mirror/usecase/vald_test.go | 759 + .../job/correction/config/config_test.go | 1 - .../job/correction/service/corrector_test.go | 1330 +- .../job/correction/service/options_test.go | 4 - .../job/correction/usecase/corrector_test.go | 573 + pkg/index/job/creation/config/config_test.go | 1 - .../job/creation/service/indexer_test.go | 196 + .../job/creation/service/options_test.go | 4 - .../job/creation/usecase/creation_test.go | 573 + .../readreplica/rotate/config/config_test.go | 1 - .../rotate/service/options_test.go | 3 - .../rotate/service/rotator_test.go | 1036 +- .../readreplica/rotate/usecase/rotate_test.go | 573 + pkg/index/job/save/config/config_test.go | 1 - pkg/index/job/save/service/indexer_test.go | 204 +- pkg/index/job/save/service/options_test.go | 3 - pkg/index/job/save/usecase/save_test.go | 573 + pkg/index/operator/config/config_test.go | 105 + pkg/index/operator/service/operator_test.go | 759 + pkg/index/operator/service/options_test.go | 441 + pkg/index/operator/usecase/operator_test.go | 679 + pkg/manager/index/config/config_test.go | 1 - .../index/handler/grpc/handler_test.go | 3 - pkg/manager/index/handler/grpc/option_test.go | 1 - .../index/handler/rest/handler_test.go | 311 + pkg/manager/index/handler/rest/option_test.go | 101 + pkg/manager/index/router/option_test.go | 186 + pkg/manager/index/router/router_test.go | 101 + pkg/manager/index/service/indexer_test.go | 840 +- pkg/manager/index/service/option_test.go | 31 +- pkg/manager/index/usecase/indexer_test.go | 573 + pkg/tools/benchmark/job/config/config_test.go | 2 + .../job/handler/grpc/handler_test.go | 198 + .../job/handler/rest/handler_test.go | 101 + pkg/tools/benchmark/job/router/option_test.go | 271 + pkg/tools/benchmark/job/router/router_test.go | 101 + .../benchmark/job/service/insert_test.go | 197 + pkg/tools/benchmark/job/service/job_test.go | 892 + .../benchmark/job/service/object_test.go | 378 + .../benchmark/job/service/option_test.go | 1631 ++ .../benchmark/job/service/remove_test.go | 197 + .../benchmark/job/service/search_test.go | 197 + .../benchmark/job/service/update_test.go | 197 + .../benchmark/job/service/upsert_test.go | 197 + .../benchmark/job/usecase/benchmarkd_test.go | 699 + .../benchmark/operator/config/config_test.go | 105 + .../operator/handler/grpc/handler_test.go | 198 + .../operator/handler/rest/handler_test.go | 101 + .../benchmark/operator/router/option_test.go | 271 + .../benchmark/operator/router/router_test.go | 101 + .../operator/service/operator_test.go | 872 +- .../benchmark/operator/service/option_test.go | 611 + .../operator/usecase/benchmarkd_test.go | 699 + pkg/tools/cli/loadtest/assets/dataset_test.go | 92 +- .../cli/loadtest/assets/hdf5_loader_test.go | 296 +- .../cli/loadtest/assets/large_dataset_test.go | 123 +- .../cli/loadtest/assets/small_dataset_test.go | 369 +- pkg/tools/cli/loadtest/config/config_test.go | 3 - pkg/tools/cli/loadtest/service/insert_test.go | 557 + .../loadtest/service/loader_option_test.go | 8 - pkg/tools/cli/loadtest/service/loader_test.go | 145 +- pkg/tools/cli/loadtest/service/search_test.go | 373 + pkg/tools/cli/loadtest/usecase/load_test.go | 533 + rust/bin/agent/src/handler/index.rs | 15 + rust/libs/proto/src/payload.v1.rs | 88 +- rust/libs/proto/src/vald.v1.tonic.rs | 182 +- versions/DOCKER_VERSION | 1 + versions/NGT_VERSION | 2 +- versions/OPERATOR_SDK_VERSION | 2 +- versions/actions/GITHUB_CODEQL_ACTION_ANALYZE | 2 +- .../actions/GITHUB_CODEQL_ACTION_AUTOBUILD | 2 +- versions/actions/GITHUB_CODEQL_ACTION_INIT | 2 +- .../actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF | 2 +- 435 files changed, 106275 insertions(+), 7997 deletions(-) create mode 100644 cmd/agent/core/faiss/main_test.go create mode 100644 cmd/gateway/mirror/main_test.go create mode 100644 cmd/index/operator/main_test.go create mode 100644 cmd/tools/benchmark/job/main_test.go create mode 100644 cmd/tools/benchmark/operator/main_test.go create mode 100644 internal/client/v1/client/mirror/mirror_test.go create mode 100644 internal/client/v1/client/mirror/option_test.go create mode 100644 internal/config/benchmark_test.go create mode 100644 internal/config/faiss_test.go create mode 100644 internal/config/index_operator_test.go create mode 100644 internal/config/mirror_test.go create mode 100644 internal/errors/faiss_test.go create mode 100644 internal/info/info_test.go create mode 100644 internal/k8s/job/job_test.go create mode 100644 internal/k8s/job/option_test.go create mode 100644 internal/k8s/v2/pod/option_test.go create mode 100644 internal/k8s/v2/pod/pod_test.go create mode 100644 internal/k8s/vald/benchmark/api/v1/job_types_test.go create mode 100644 internal/k8s/vald/benchmark/api/v1/scenario_types_test.go create mode 100644 internal/k8s/vald/benchmark/job/job_template_option_test.go create mode 100644 internal/k8s/vald/benchmark/job/job_template_test.go create mode 100644 internal/k8s/vald/benchmark/job/job_test.go create mode 100644 internal/k8s/vald/benchmark/job/option_test.go create mode 100644 internal/k8s/vald/benchmark/scenario/option_test.go create mode 100644 internal/k8s/vald/benchmark/scenario/scenario_test.go create mode 100644 internal/k8s/vald/mirror/api/v1/target_types_test.go create mode 100644 internal/net/grpc/interceptor/client/metric/metric_test.go create mode 100644 internal/net/grpc/metadata_test.go create mode 100644 internal/observability/metrics/agent/core/faiss/faiss_test.go create mode 100644 internal/observability/metrics/gateway/mirror/mirror_test.go create mode 100644 internal/observability/metrics/mem/index/index_test.go create mode 100644 internal/observability/metrics/mem/mem_test.go create mode 100644 internal/timeutil/rate/rate_test.go create mode 100644 pkg/agent/core/faiss/config/config_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/flush_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/handler_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/index_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/insert_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/linear_search_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/object_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/option_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/remove_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/search_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/update_test.go create mode 100644 pkg/agent/core/faiss/handler/grpc/upsert_test.go create mode 100644 pkg/agent/core/faiss/handler/rest/handler_test.go create mode 100644 pkg/agent/core/faiss/handler/rest/option_test.go create mode 100644 pkg/agent/core/faiss/router/option_test.go create mode 100644 pkg/agent/core/faiss/router/router_test.go create mode 100644 pkg/agent/core/faiss/service/faiss_test.go create mode 100644 pkg/agent/core/faiss/service/option_test.go create mode 100644 pkg/agent/core/faiss/usecase/agentd_test.go create mode 100644 pkg/agent/core/ngt/handler/grpc/flush_test.go create mode 100644 pkg/agent/core/ngt/handler/rest/handler_test.go create mode 100644 pkg/agent/core/ngt/handler/rest/option_test.go create mode 100644 pkg/agent/sidecar/handler/rest/handler_test.go create mode 100644 pkg/agent/sidecar/handler/rest/option_test.go create mode 100644 pkg/agent/sidecar/router/option_test.go create mode 100644 pkg/agent/sidecar/router/router_test.go create mode 100644 pkg/discoverer/k8s/handler/rest/handler_test.go create mode 100644 pkg/discoverer/k8s/handler/rest/option_test.go create mode 100644 pkg/discoverer/k8s/router/option_test.go create mode 100644 pkg/discoverer/k8s/router/router_test.go create mode 100644 pkg/gateway/filter/handler/rest/handler_test.go create mode 100644 pkg/gateway/filter/handler/rest/option_test.go create mode 100644 pkg/gateway/filter/router/option_test.go create mode 100644 pkg/gateway/filter/router/router_test.go create mode 100644 pkg/gateway/lb/handler/rest/handler_test.go create mode 100644 pkg/gateway/lb/handler/rest/option_test.go create mode 100644 pkg/gateway/lb/router/option_test.go create mode 100644 pkg/gateway/lb/router/router_test.go create mode 100644 pkg/gateway/mirror/config/config_test.go create mode 100644 pkg/gateway/mirror/handler/grpc/option_test.go create mode 100644 pkg/gateway/mirror/handler/rest/handler_test.go create mode 100644 pkg/gateway/mirror/handler/rest/option_test.go create mode 100644 pkg/gateway/mirror/router/option_test.go create mode 100644 pkg/gateway/mirror/router/router_test.go create mode 100644 pkg/gateway/mirror/service/discovery_option_test.go create mode 100644 pkg/gateway/mirror/service/gateway_test.go create mode 100644 pkg/gateway/mirror/service/mirror_option_test.go create mode 100644 pkg/gateway/mirror/service/option_test.go create mode 100644 pkg/gateway/mirror/usecase/vald_test.go create mode 100644 pkg/index/operator/config/config_test.go create mode 100644 pkg/index/operator/service/options_test.go create mode 100644 pkg/index/operator/usecase/operator_test.go create mode 100644 pkg/manager/index/handler/rest/handler_test.go create mode 100644 pkg/manager/index/handler/rest/option_test.go create mode 100644 pkg/manager/index/router/option_test.go create mode 100644 pkg/manager/index/router/router_test.go create mode 100644 pkg/tools/benchmark/job/handler/grpc/handler_test.go create mode 100644 pkg/tools/benchmark/job/handler/rest/handler_test.go create mode 100644 pkg/tools/benchmark/job/router/option_test.go create mode 100644 pkg/tools/benchmark/job/router/router_test.go create mode 100644 pkg/tools/benchmark/job/service/insert_test.go create mode 100644 pkg/tools/benchmark/job/service/job_test.go create mode 100644 pkg/tools/benchmark/job/service/object_test.go create mode 100644 pkg/tools/benchmark/job/service/option_test.go create mode 100644 pkg/tools/benchmark/job/service/remove_test.go create mode 100644 pkg/tools/benchmark/job/service/search_test.go create mode 100644 pkg/tools/benchmark/job/service/update_test.go create mode 100644 pkg/tools/benchmark/job/service/upsert_test.go create mode 100644 pkg/tools/benchmark/job/usecase/benchmarkd_test.go create mode 100644 pkg/tools/benchmark/operator/config/config_test.go create mode 100644 pkg/tools/benchmark/operator/handler/grpc/handler_test.go create mode 100644 pkg/tools/benchmark/operator/handler/rest/handler_test.go create mode 100644 pkg/tools/benchmark/operator/router/option_test.go create mode 100644 pkg/tools/benchmark/operator/router/router_test.go create mode 100644 pkg/tools/benchmark/operator/service/option_test.go create mode 100644 pkg/tools/benchmark/operator/usecase/benchmarkd_test.go create mode 100644 pkg/tools/cli/loadtest/service/insert_test.go create mode 100644 pkg/tools/cli/loadtest/service/search_test.go create mode 100644 versions/DOCKER_VERSION diff --git a/.gitfiles b/.gitfiles index cb4b43dac7..13f61ddc34 100644 --- a/.gitfiles +++ b/.gitfiles @@ -457,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 @@ -477,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 @@ -491,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 @@ -753,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 @@ -791,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 @@ -808,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 @@ -818,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 @@ -828,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 @@ -971,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 @@ -1023,6 +1035,7 @@ internal/hash/hash.go internal/hash/hash_test.go internal/info/info.go internal/info/info_bench_test.go +internal/info/info_test.go internal/info/option.go internal/info/option_test.go internal/io/copy.go @@ -1035,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 @@ -1062,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 @@ -1134,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 @@ -1147,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 @@ -1206,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 @@ -1215,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 @@ -1224,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 @@ -1344,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 @@ -1524,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 @@ -1570,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 @@ -1603,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 @@ -1636,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 @@ -1657,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 @@ -1677,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 @@ -1689,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 @@ -1743,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 @@ -1756,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 @@ -1772,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 @@ -1815,11 +1924,13 @@ 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 @@ -1889,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 9e36ab8918..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.5 -- Rust Version: 1.77.2 -- Docker Version: 20.10.8 +- 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 -- NGT Version: 2.2.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 88dd195341..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.5 -- Rust Version: 1.77.2 -- Docker Version: 20.10.8 +- 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 -- NGT Version: 2.2.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 efabc89305..831b078b81 100755 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -15,12 +15,14 @@ ### Versions - -- Go Version: 1.22.5 -- Rust Version: 1.77.2 -- Docker Version: 20.10.8 +- 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 -- NGT Version: 2.2.3 +- Helm Version: v3.15.3 +- NGT Version: v2.2.4 +- Faiss Version: v1.8.0 ### Checklist diff --git a/Makefile b/Makefile index 2ad989b1a1..9986a575ac 100644 --- a/Makefile +++ b/Makefile @@ -77,9 +77,10 @@ CARGO_HOME ?= $(RUST_HOME)/cargo RUST_VERSION := $(eval RUST_VERSION := $(shell cat versions/RUST_VERSION))$(RUST_VERSION) 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) @@ -95,9 +96,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 @@ -140,6 +139,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) @@ -472,11 +478,11 @@ format/go: \ 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)/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 - 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 '.*\.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 @@ -489,7 +495,7 @@ format/go/test: \ find $(ROOTDIR) -name '*_test.go' | xargs -P$(CORES) $(GOBIN)/golines -w -m $(GOLINES_MAX_WIDTH) 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 + 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 @@ -568,6 +574,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: @@ -599,7 +615,14 @@ 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)" . + 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) @@ -613,18 +636,18 @@ $(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 -DCMAKE_BUILD_TYPE=Release \ + cmake -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=OFF \ -DBUILD_STATIC_EXECS=ON \ -DBUILD_TESTING=OFF \ - -DCMAKE_C_FLAGS="-fPIC" \ + -DCMAKE_C_FLAGS="$(LDFLAGS)" \ -DCMAKE_INSTALL_PREFIX=$(USR_LOCAL) \ -DFAISS_ENABLE_PYTHON=OFF \ -DFAISS_ENABLE_GPU=OFF \ -DBLA_VENDOR=OpenBLAS \ - -DCMAKE_EXE_LINKER_FLAGS="-lopenblas -llapack -lgfortran -lm" \ + -DCMAKE_EXE_LINKER_FLAGS="$(FAISS_LDFLAGS)" \ -B build . && \ - make -C build -j faiss && \ + make -C build -j$(CORES) faiss && \ make -C build install rm -rf v$(FAISS_VERSION).tar.gz rm -rf $(TEMP_DIR)/faiss-$(FAISS_VERSION) 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 a7440181c8..c2132a1630 100644 --- a/Makefile.d/build.mk +++ b/Makefile.d/build.mk @@ -40,12 +40,12 @@ binary/build: \ 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 -flto -march=native -fno-plt -Ofast -fvisibility=hidden -ffp-contract=fast $(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',-static -fPIC -pthread -fopenmp -std=gnu++20 -lstdc++ -lopenblas -llapack -lgfortran -lm -z relro -z now -flto -march=native -fno-plt -Ofast -fvisibility=hidden -ffp-contract=fast, 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) @@ -93,7 +93,7 @@ cmd/index/operator/index-operator: cmd/tools/benchmark/job/job: $(eval CGO_ENABLED = 1) - $(call go-build,tools/benchmark/job,-linkmode 'external',-static -fPIC -pthread -fopenmp -std=gnu++20 -lhdf5 -lhdf5_hl -lsz -laec -lz -lm -ldl, cgo,$(HDF5_VERSION),$@) + $(call go-build,tools/benchmark/job,-linkmode 'external',$(LDFLAGS) $(HDF5_LDFLAGS), cgo,$(HDF5_VERSION),$@) cmd/tools/benchmark/operator/operator: $(eval CGO_ENABLED = 0) @@ -101,7 +101,7 @@ cmd/tools/benchmark/operator/operator: cmd/tools/cli/loadtest/loadtest: $(eval CGO_ENABLED = 1) - $(call go-build,tools/cli/loadtest,-linkmode 'external',-static -fPIC -pthread -fopenmp -std=gnu++20 -lhdf5 -lhdf5_hl -lsz -laec -lz -lm -ldl, cgo,$(HDF5_VERSION),$@) + $(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 diff --git a/Makefile.d/dependencies.mk b/Makefile.d/dependencies.mk index 521af54040..8e01f2fb07 100644 --- a/Makefile.d/dependencies.mk +++ b/Makefile.d/dependencies.mk @@ -121,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: @@ -219,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/functions.mk b/Makefile.d/functions.mk index 880555e086..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 \ diff --git a/Makefile.d/proto.mk b/Makefile.d/proto.mk index dd0ff92f1a..50669a111f 100644 --- a/Makefile.d/proto.mk +++ b/Makefile.d/proto.mk @@ -54,9 +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%any%any%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/apis/docs/v1/docs.md b/apis/docs/v1/docs.md index 8bbcfa7f47..2289344848 100644 --- a/apis/docs/v1/docs.md +++ b/apis/docs/v1/docs.md @@ -25,6 +25,9 @@ - [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) @@ -317,6 +320,67 @@ Represent the index count for each Agents message. | 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 @@ -1497,10 +1561,12 @@ Flush service provides ways to flush all indexed vectors. 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. | +| 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. | diff --git a/apis/grpc/v1/agent/core/agent.pb.go b/apis/grpc/v1/agent/core/agent.pb.go index 61eb7d6243..42f03029a9 100644 --- a/apis/grpc/v1/agent/core/agent.pb.go +++ b/apis/grpc/v1/agent/core/agent.pb.go @@ -80,6 +80,7 @@ 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 } + 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 diff --git a/apis/grpc/v1/agent/core/agent_vtproto.pb.go b/apis/grpc/v1/agent/core/agent_vtproto.pb.go index 9c2a729b4f..93f689fa9c 100644 --- a/apis/grpc/v1/agent/core/agent_vtproto.pb.go +++ b/apis/grpc/v1/agent/core/agent_vtproto.pb.go @@ -105,17 +105,18 @@ type AgentServer interface { } // 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) { 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) { diff --git a/apis/grpc/v1/agent/sidecar/sidecar.pb.go b/apis/grpc/v1/agent/sidecar/sidecar.pb.go index 748befbf7b..bcaf02c7c6 100644 --- a/apis/grpc/v1/agent/sidecar/sidecar.pb.go +++ b/apis/grpc/v1/agent/sidecar/sidecar.pb.go @@ -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 = []any{} -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 be173f2223..f95d2f8cbe 100644 --- a/apis/grpc/v1/discoverer/discoverer.pb.go +++ b/apis/grpc/v1/discoverer/discoverer.pb.go @@ -81,6 +81,7 @@ var file_v1_discoverer_discoverer_proto_goTypes = []any{ (*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 6fc5d237ef..a1153195c6 100644 --- a/apis/grpc/v1/discoverer/discoverer_vtproto.pb.go +++ b/apis/grpc/v1/discoverer/discoverer_vtproto.pb.go @@ -105,19 +105,20 @@ 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) { return nil, status.Errorf(codes.Unimplemented, "method Pods not implemented") } + 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) { diff --git a/apis/grpc/v1/filter/egress/egress_filter.pb.go b/apis/grpc/v1/filter/egress/egress_filter.pb.go index 20a683a69c..5d60c42564 100644 --- a/apis/grpc/v1/filter/egress/egress_filter.pb.go +++ b/apis/grpc/v1/filter/egress/egress_filter.pb.go @@ -76,6 +76,7 @@ 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 ffe26943c8..fc9d0d34e2 100644 --- a/apis/grpc/v1/filter/egress/egress_filter_vtproto.pb.go +++ b/apis/grpc/v1/filter/egress/egress_filter_vtproto.pb.go @@ -90,14 +90,14 @@ 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) { return nil, status.Errorf(codes.Unimplemented, "method FilterDistance not implemented") } + func (UnimplementedFilterServer) FilterVector( context.Context, *payload.Object_Vector, ) (*payload.Object_Vector, error) { diff --git a/apis/grpc/v1/filter/ingress/ingress_filter.pb.go b/apis/grpc/v1/filter/ingress/ingress_filter.pb.go index e357a893a9..4c76d06ed6 100644 --- a/apis/grpc/v1/filter/ingress/ingress_filter.pb.go +++ b/apis/grpc/v1/filter/ingress/ingress_filter.pb.go @@ -76,6 +76,7 @@ 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 8b13821505..acea57e809 100644 --- a/apis/grpc/v1/filter/ingress/ingress_filter_vtproto.pb.go +++ b/apis/grpc/v1/filter/ingress/ingress_filter_vtproto.pb.go @@ -90,14 +90,14 @@ 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) { return nil, status.Errorf(codes.Unimplemented, "method GenVector not implemented") } + func (UnimplementedFilterServer) FilterVector( context.Context, *payload.Object_Vector, ) (*payload.Object_Vector, error) { diff --git a/apis/grpc/v1/mirror/mirror.pb.go b/apis/grpc/v1/mirror/mirror.pb.go index 8a51475751..429706e1c3 100644 --- a/apis/grpc/v1/mirror/mirror.pb.go +++ b/apis/grpc/v1/mirror/mirror.pb.go @@ -65,6 +65,7 @@ var file_v1_mirror_mirror_proto_rawDesc = []byte{ 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 4fd44fcf1b..5b733bf39d 100644 --- a/apis/grpc/v1/mirror/mirror_vtproto.pb.go +++ b/apis/grpc/v1/mirror/mirror_vtproto.pb.go @@ -75,8 +75,7 @@ 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, diff --git a/apis/grpc/v1/payload/payload.pb.go b/apis/grpc/v1/payload/payload.pb.go index 5925f81550..1d034ff92e 100644 --- a/apis/grpc/v1/payload/payload.pb.go +++ b/apis/grpc/v1/payload/payload.pb.go @@ -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() { @@ -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() { @@ -4799,9 +4802,9 @@ type Info_Index_Detail struct { 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"` + 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"` + 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"` } @@ -4898,6 +4901,359 @@ func (*Info_Index_UUID) Descriptor() ([]byte, []int) { 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. type Info_Index_UUID_Committed struct { state protoimpl.MessageState @@ -4910,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[84] + mi := &file_v1_payload_payload_proto_msgTypes[86] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4923,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[84] + mi := &file_v1_payload_payload_proto_msgTypes[86] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4958,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[85] + mi := &file_v1_payload_payload_proto_msgTypes[87] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4971,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[85] + mi := &file_v1_payload_payload_proto_msgTypes[87] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -5001,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"` } @@ -5009,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[88] + mi := &file_v1_payload_payload_proto_msgTypes[91] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5022,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[88] + mi := &file_v1_payload_payload_proto_msgTypes[91] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -5065,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[89] + mi := &file_v1_payload_payload_proto_msgTypes[92] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -5078,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[89] + mi := &file_v1_payload_payload_proto_msgTypes[92] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -5468,8 +5824,8 @@ var file_v1_payload_payload_proto_rawDesc = []byte{ 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, 0xee, 0x0e, - 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0xac, 0x03, 0x0a, 0x05, 0x49, 0x6e, 0x64, 0x65, 0x78, + 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, @@ -5496,114 +5852,232 @@ var file_v1_payload_payload_proto_rawDesc = []byte{ 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, 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, + 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, 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, } var ( @@ -5618,104 +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, 90) -var 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 - nil, // 85: payload.v1.Info.Index.Detail.CountsEntry - (*Info_Index_UUID_Committed)(nil), // 86: payload.v1.Info.Index.UUID.Committed - (*Info_Index_UUID_Uncommitted)(nil), // 87: payload.v1.Info.Index.UUID.Uncommitted - nil, // 88: payload.v1.Info.Labels.LabelsEntry - nil, // 89: payload.v1.Info.Annotations.AnnotationsEntry - (*Mirror_Target)(nil), // 90: payload.v1.Mirror.Target - (*Mirror_Targets)(nil), // 91: payload.v1.Mirror.Targets - (*wrapperspb.FloatValue)(nil), // 92: google.protobuf.FloatValue - (*status.Status)(nil), // 93: 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 @@ -5727,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 - 92, // 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 - 93, // 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 @@ -5765,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 - 93, // 48: payload.v1.Object.StreamDistance.status:type_name -> google.rpc.Status + 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 - 93, // 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 - 93, // 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 - 93, // 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 - 93, // 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 @@ -5786,19 +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 - 88, // 69: payload.v1.Info.Labels.labels:type_name -> payload.v1.Info.Labels.LabelsEntry - 89, // 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 - 85, // 74: payload.v1.Info.Index.Detail.counts:type_name -> payload.v1.Info.Index.Detail.CountsEntry - 82, // 75: payload.v1.Info.Index.Detail.CountsEntry.value:type_name -> payload.v1.Info.Index.Count - 90, // 76: payload.v1.Mirror.Targets.targets:type_name -> payload.v1.Mirror.Target - 77, // [77:77] is the sub-list for method output_type - 77, // [77:77] is the sub-list for method input_type - 77, // [77:77] is the sub-list for extension type_name - 77, // [77:77] is the sub-list for extension extendee - 0, // [0:77] 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() } @@ -6803,7 +7285,31 @@ func file_v1_payload_payload_proto_init() { return nil } } + 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 @@ -6815,7 +7321,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[85].Exporter = func(v any, i int) any { + 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 @@ -6827,7 +7333,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[88].Exporter = func(v any, i int) any { + 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 @@ -6839,7 +7345,7 @@ func file_v1_payload_payload_proto_init() { return nil } } - file_v1_payload_payload_proto_msgTypes[89].Exporter = func(v any, i int) any { + 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 @@ -6882,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: 90, + 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 96c5c74495..159ebc555c 100644 --- a/apis/grpc/v1/payload/payload.pb.json.go +++ b/apis/grpc/v1/payload/payload.pb.json.go @@ -731,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 3daa37f0af..b2a6c8d654 100644 --- a/apis/grpc/v1/payload/payload_vtproto.pb.go +++ b/apis/grpc/v1/payload/payload_vtproto.pb.go @@ -1549,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) @@ -1951,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 @@ -1984,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 @@ -2006,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 @@ -2039,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 @@ -2064,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 @@ -2097,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 @@ -2143,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 @@ -2179,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 @@ -2212,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 @@ -2240,6 +2333,7 @@ func (this *Search_StreamResponse) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Search_StreamResponse_Response) EqualVT( thatIface isSearch_StreamResponse_Payload, ) bool { @@ -2312,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 @@ -2334,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 @@ -2367,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 @@ -2383,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 @@ -2405,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 @@ -2438,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 @@ -2463,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 @@ -2496,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 @@ -2521,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 @@ -2537,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 @@ -2559,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 @@ -2592,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 @@ -2617,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 @@ -2650,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 @@ -2678,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 @@ -2694,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 @@ -2716,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 @@ -2749,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 @@ -2774,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 @@ -2807,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 @@ -2835,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 @@ -2851,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 @@ -2873,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 @@ -2906,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 @@ -2939,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 @@ -2961,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 @@ -2983,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 @@ -2999,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 @@ -3015,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 @@ -3031,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 @@ -3053,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 @@ -3075,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 @@ -3103,6 +3229,7 @@ func (this *Object_StreamDistance) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_StreamDistance_Distance) EqualVT( thatIface isObject_StreamDistance_Payload, ) bool { @@ -3178,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 @@ -3203,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 @@ -3234,6 +3363,7 @@ func (this *Object_Vector) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_TimestampRequest) EqualVT(that *Object_TimestampRequest) bool { if this == that { return true @@ -3253,6 +3383,7 @@ func (this *Object_TimestampRequest) EqualMessageVT(thatMsg proto.Message) bool } return this.EqualVT(that) } + func (this *Object_Timestamp) EqualVT(that *Object_Timestamp) bool { if this == that { return true @@ -3275,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 @@ -3308,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 @@ -3336,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 { @@ -3418,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 @@ -3440,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 @@ -3468,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 { @@ -3553,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 @@ -3581,6 +3719,7 @@ func (this *Object_StreamLocation) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Object_StreamLocation_Location) EqualVT( thatIface isObject_StreamLocation_Payload, ) bool { @@ -3670,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 @@ -3686,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 @@ -3714,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 { @@ -3784,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 @@ -3800,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 @@ -3819,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 @@ -3835,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 @@ -3860,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 @@ -3876,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 @@ -3904,6 +4052,7 @@ 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 @@ -3946,6 +4095,7 @@ func (this *Info_Index_Detail) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Index_UUID_Committed) EqualVT(that *Info_Index_UUID_Committed) bool { if this == that { return true @@ -3965,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 @@ -3984,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 @@ -4000,6 +4152,178 @@ func (this *Info_Index_UUID) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + +func (this *Info_Index_Statistics) EqualVT(that *Info_Index_Statistics) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Valid != that.Valid { + return false + } + if this.MedianIndegree != that.MedianIndegree { + return false + } + if this.MedianOutdegree != that.MedianOutdegree { + return false + } + if this.MaxNumberOfIndegree != that.MaxNumberOfIndegree { + return false + } + if this.MaxNumberOfOutdegree != that.MaxNumberOfOutdegree { + return false + } + if this.MinNumberOfIndegree != that.MinNumberOfIndegree { + return false + } + if this.MinNumberOfOutdegree != that.MinNumberOfOutdegree { + return false + } + if this.ModeIndegree != that.ModeIndegree { + return false + } + if this.ModeOutdegree != that.ModeOutdegree { + return false + } + if this.NodesSkippedFor10Edges != that.NodesSkippedFor10Edges { + return false + } + if this.NodesSkippedForIndegreeDistance != that.NodesSkippedForIndegreeDistance { + return false + } + if this.NumberOfEdges != that.NumberOfEdges { + return false + } + if this.NumberOfIndexedObjects != that.NumberOfIndexedObjects { + return false + } + if this.NumberOfNodes != that.NumberOfNodes { + return false + } + if this.NumberOfNodesWithoutEdges != that.NumberOfNodesWithoutEdges { + return false + } + if this.NumberOfNodesWithoutIndegree != that.NumberOfNodesWithoutIndegree { + return false + } + if this.NumberOfObjects != that.NumberOfObjects { + return false + } + if this.NumberOfRemovedObjects != that.NumberOfRemovedObjects { + return false + } + if this.SizeOfObjectRepository != that.SizeOfObjectRepository { + return false + } + if this.SizeOfRefinementObjectRepository != that.SizeOfRefinementObjectRepository { + return false + } + if this.VarianceOfIndegree != that.VarianceOfIndegree { + return false + } + if this.VarianceOfOutdegree != that.VarianceOfOutdegree { + return false + } + 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.OutdegreeHistogram) != len(that.OutdegreeHistogram) { + return false + } + for i, vx := range this.OutdegreeHistogram { + vy := that.OutdegreeHistogram[i] + if vx != vy { + return false + } + } + if len(this.IndegreeHistogram) != len(that.IndegreeHistogram) { + 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_Index_Statistics) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Info_Index_Statistics) + if !ok { + return false + } + return this.EqualVT(that) +} + +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 len(this.Details) != len(that.Details) { + return false + } + 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 @@ -4016,6 +4340,7 @@ func (this *Info_Index) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Pod) EqualVT(that *Info_Pod) bool { if this == that { return true @@ -4053,6 +4378,7 @@ func (this *Info_Pod) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Node) EqualVT(that *Info_Node) bool { if this == that { return true @@ -4087,6 +4413,7 @@ func (this *Info_Node) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Service) EqualVT(that *Info_Service) bool { if this == that { return true @@ -4141,6 +4468,7 @@ func (this *Info_Service) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_ServicePort) EqualVT(that *Info_ServicePort) bool { if this == that { return true @@ -4163,6 +4491,7 @@ func (this *Info_ServicePort) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } + func (this *Info_Labels) EqualVT(that *Info_Labels) bool { if this == that { return true @@ -4191,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 @@ -4219,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 @@ -4244,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 @@ -4269,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 @@ -4302,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 @@ -4335,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 @@ -4368,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 @@ -4393,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 @@ -4409,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 @@ -4431,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 @@ -4464,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 @@ -4480,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 @@ -4496,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 @@ -5054,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]) @@ -5085,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 @@ -6645,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]) @@ -6676,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 @@ -7007,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]) @@ -7038,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 @@ -7207,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]) @@ -7238,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 @@ -7355,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]) @@ -7386,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 @@ -7525,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]) @@ -7556,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 @@ -8021,7 +8375,7 @@ func (m *Info_Index_UUID) MarshalToSizedBufferVT(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Info_Index) MarshalVT() (dAtA []byte, err error) { +func (m *Info_Index_Statistics) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -8034,12 +8388,12 @@ func (m *Info_Index) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Info_Index) MarshalToVT(dAtA []byte) (int, error) { +func (m *Info_Index_Statistics) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *Info_Index) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *Info_Index_Statistics) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -8051,7 +8405,357 @@ func (m *Info_Index) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - return len(dAtA) - i, nil + 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 + } + 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) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Info_Index) 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_Pod) MarshalVT() (dAtA []byte, err error) { @@ -9144,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 @@ -9162,6 +9867,7 @@ func (m *Search_StreamResponse_Status) SizeVT() (n int) { } return n } + func (m *Search) SizeVT() (n int) { if m == nil { return 0 @@ -9699,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 @@ -9717,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 @@ -9839,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 @@ -9857,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 @@ -9921,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 @@ -9939,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 @@ -9988,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 @@ -10006,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 @@ -10057,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 @@ -10075,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 @@ -10239,47 +10955,191 @@ func (m *Info_Index_UUID) SizeVT() (n int) { return n } -func (m *Info_Index) SizeVT() (n int) { +func (m *Info_Index_Statistics) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - n += len(m.unknownFields) - return n -} - -func (m *Info_Pod) SizeVT() (n int) { - if m == nil { - return 0 + if m.Valid { + n += 2 } - var l int - _ = l - l = len(m.AppName) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + if m.MedianIndegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MedianIndegree)) } - l = len(m.Name) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + if m.MedianOutdegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MedianOutdegree)) } - l = len(m.Namespace) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + if m.MaxNumberOfIndegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MaxNumberOfIndegree)) } - l = len(m.Ip) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + if m.MaxNumberOfOutdegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MaxNumberOfOutdegree)) } - if m.Cpu != nil { - l = m.Cpu.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + if m.MinNumberOfIndegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MinNumberOfIndegree)) } - if m.Memory != nil { - l = m.Memory.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + if m.MinNumberOfOutdegree != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MinNumberOfOutdegree)) } - if m.Node != nil { + 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 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *Info_Pod) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AppName) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Namespace) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Ip) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Cpu != nil { + l = m.Cpu.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Memory != nil { + l = m.Memory.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Node != nil { l = m.Node.SizeVT() n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } @@ -10718,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 @@ -10803,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 @@ -10922,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 @@ -11007,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 @@ -11164,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 @@ -11249,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 @@ -11538,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 @@ -11655,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 @@ -11740,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 @@ -11889,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 @@ -11940,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 @@ -12042,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 @@ -12127,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 @@ -12178,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 @@ -12301,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 @@ -12386,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 @@ -12545,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 @@ -12630,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 @@ -12756,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 @@ -12807,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 @@ -12930,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 @@ -13015,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 @@ -13174,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 @@ -13259,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 @@ -13405,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 @@ -13456,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 @@ -13579,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 @@ -13664,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 @@ -13823,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 @@ -13908,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 @@ -14054,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 @@ -14105,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 @@ -14228,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 @@ -14313,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 @@ -14398,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 @@ -14487,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 @@ -14577,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 @@ -14628,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 @@ -14679,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 @@ -14730,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 @@ -14853,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 @@ -14947,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 @@ -15096,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 @@ -15179,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 @@ -15262,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 @@ -15418,6 +16323,7 @@ func (m *Object_Vector) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_TimestampRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15505,6 +16411,7 @@ func (m *Object_TimestampRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Object_Timestamp) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -15607,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 @@ -15692,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 @@ -15841,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 @@ -16002,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 @@ -16119,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 @@ -16268,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 @@ -16415,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 @@ -16564,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 @@ -16649,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 @@ -16700,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 @@ -16849,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 @@ -16900,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 @@ -16951,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 @@ -17021,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 @@ -17072,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 @@ -17219,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 @@ -17270,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 @@ -17399,6 +18323,7 @@ func (m *Info_Index_Count) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *Info_Index_Detail) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -17617,7 +18542,999 @@ func (m *Info_Index_Detail) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *Info_Index_UUID_Committed) UnmarshalVT(dAtA []byte) error { + +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) + } + 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 + } + } + 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 + } + 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) + } + 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_StatisticsDetail) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -17640,17 +19557,17 @@ 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_StatisticsDetail: 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_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 @@ -17660,106 +19577,120 @@ func (m *Info_Index_UUID_Committed) 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_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) + if m.Details == nil { + m.Details = make(map[string]*Info_Index_Statistics) } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF + 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 + } } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= 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 } } - 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]) + m.Details[mapkey] = mapvalue iNdEx = postIndex default: iNdEx = preIndex @@ -17783,57 +19714,7 @@ func (m *Info_Index_UUID_Uncommitted) UnmarshalVT(dAtA []byte) error { } 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) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -17885,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 @@ -18172,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 @@ -18427,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 @@ -18680,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 @@ -18782,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 @@ -18960,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 @@ -19138,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 @@ -19222,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 @@ -19306,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 @@ -19391,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 @@ -19476,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 @@ -19561,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 @@ -19644,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 @@ -19695,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 @@ -19797,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 @@ -19882,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 @@ -19933,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 810ebcbd5a..ff9e1c42cf 100644 --- a/apis/grpc/v1/rpc/errdetails/error_details.pb.go +++ b/apis/grpc/v1/rpc/errdetails/error_details.pb.go @@ -73,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 @@ -215,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() { @@ -435,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"` @@ -505,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() { @@ -635,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"` } @@ -696,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 @@ -762,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. // @@ -870,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"` } @@ -930,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() { @@ -1087,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 = []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_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 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 0127478783..580f165e44 100644 --- a/apis/grpc/v1/rpc/errdetails/error_details_vtproto.pb.go +++ b/apis/grpc/v1/rpc/errdetails/error_details_vtproto.pb.go @@ -354,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 @@ -373,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 @@ -401,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 @@ -423,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 @@ -456,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 @@ -481,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 @@ -514,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 @@ -536,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 @@ -569,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 @@ -591,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 @@ -619,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 @@ -641,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 @@ -674,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 @@ -696,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 @@ -1888,6 +1902,7 @@ func (m *ErrorInfo) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *RetryInfo) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1975,6 +1990,7 @@ func (m *RetryInfo) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *DebugInfo) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2090,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 @@ -2205,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 @@ -2290,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 @@ -2437,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 @@ -2522,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 @@ -2637,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 @@ -2722,6 +2744,7 @@ func (m *BadRequest) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *RequestInfo) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2837,6 +2860,7 @@ func (m *RequestInfo) UnmarshalVT(dAtA []byte) error { } return nil } + func (m *ResourceInfo) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3016,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 @@ -3131,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 @@ -3216,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 9ccddf7140..8309d71f5b 100644 --- a/apis/grpc/v1/vald/filter.pb.go +++ b/apis/grpc/v1/vald/filter.pb.go @@ -154,6 +154,7 @@ var file_v1_vald_filter_proto_goTypes = []any{ (*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 a73d2576fd..54963521a7 100644 --- a/apis/grpc/v1/vald/filter_vtproto.pb.go +++ b/apis/grpc/v1/vald/filter_vtproto.pb.go @@ -328,56 +328,66 @@ 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) { return nil, status.Errorf(codes.Unimplemented, "method SearchObject not implemented") } + 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) { 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) { return nil, status.Errorf(codes.Unimplemented, "method MultiInsertObject not implemented") } + 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) { return nil, status.Errorf(codes.Unimplemented, "method MultiUpdateObject not implemented") } + 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) { diff --git a/apis/grpc/v1/vald/flush.pb.go b/apis/grpc/v1/vald/flush.pb.go index 0091641d77..282dbd0590 100644 --- a/apis/grpc/v1/vald/flush.pb.go +++ b/apis/grpc/v1/vald/flush.pb.go @@ -64,6 +64,7 @@ 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 29a8ac2a90..fd1978bec8 100644 --- a/apis/grpc/v1/vald/flush_vtproto.pb.go +++ b/apis/grpc/v1/vald/flush_vtproto.pb.go @@ -75,8 +75,7 @@ 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, diff --git a/apis/grpc/v1/vald/index.pb.go b/apis/grpc/v1/vald/index.pb.go index 624f1336d2..46cef675f7 100644 --- a/apis/grpc/v1/vald/index.pb.go +++ b/apis/grpc/v1/vald/index.pb.go @@ -46,7 +46,7 @@ var file_v1_vald_index_proto_rawDesc = []byte{ 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, 0xb2, 0x01, 0x0a, 0x05, 0x49, 0x6e, 0x64, 0x65, 0x78, + 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, @@ -57,27 +57,48 @@ var file_v1_vald_index_proto_rawDesc = []byte{ 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, 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, + 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.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 - 1, // 2: vald.v1.Index.IndexInfo:output_type -> payload.v1.Info.Index.Count - 2, // 3: vald.v1.Index.IndexDetail:output_type -> payload.v1.Info.Index.Detail - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type + 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 diff --git a/apis/grpc/v1/vald/index_vtproto.pb.go b/apis/grpc/v1/vald/index_vtproto.pb.go index ae10c65015..cda0a74ab3 100644 --- a/apis/grpc/v1/vald/index_vtproto.pb.go +++ b/apis/grpc/v1/vald/index_vtproto.pb.go @@ -46,6 +46,10 @@ type IndexClient interface { 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 { @@ -78,6 +82,28 @@ func (c *indexClient) IndexDetail( 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 @@ -86,23 +112,39 @@ type IndexServer interface { 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 { -} +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. @@ -156,6 +198,46 @@ func _Index_IndexDetail_Handler( 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) @@ -171,6 +253,14 @@ var Index_ServiceDesc = grpc.ServiceDesc{ 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 329618f243..26f4a05fe7 100644 --- a/apis/grpc/v1/vald/insert.pb.go +++ b/apis/grpc/v1/vald/insert.pb.go @@ -80,6 +80,7 @@ var file_v1_vald_insert_proto_goTypes = []any{ (*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 4274c79f0a..4adde0acb5 100644 --- a/apis/grpc/v1/vald/insert_vtproto.pb.go +++ b/apis/grpc/v1/vald/insert_vtproto.pb.go @@ -127,17 +127,18 @@ 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) { 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) { diff --git a/apis/grpc/v1/vald/object.pb.go b/apis/grpc/v1/vald/object.pb.go index 3ccfeea9f5..f911467104 100644 --- a/apis/grpc/v1/vald/object.pb.go +++ b/apis/grpc/v1/vald/object.pb.go @@ -96,6 +96,7 @@ var file_v1_vald_object_proto_goTypes = []any{ (*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 diff --git a/apis/grpc/v1/vald/object_vtproto.pb.go b/apis/grpc/v1/vald/object_vtproto.pb.go index d3beaa6dcd..1df7b6eadf 100644 --- a/apis/grpc/v1/vald/object_vtproto.pb.go +++ b/apis/grpc/v1/vald/object_vtproto.pb.go @@ -180,27 +180,30 @@ type ObjectServer interface { } // 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) { return nil, status.Errorf(codes.Unimplemented, "method Exists not implemented") } + 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 { return status.Errorf(codes.Unimplemented, "method StreamListObject not implemented") } + func (UnimplementedObjectServer) GetTimestamp( context.Context, *payload.Object_TimestampRequest, ) (*payload.Object_Timestamp, error) { diff --git a/apis/grpc/v1/vald/remove.pb.go b/apis/grpc/v1/vald/remove.pb.go index bbb48c7b84..cf58d5f1eb 100644 --- a/apis/grpc/v1/vald/remove.pb.go +++ b/apis/grpc/v1/vald/remove.pb.go @@ -88,6 +88,7 @@ var file_v1_vald_remove_proto_goTypes = []any{ (*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 7a41f97a34..68219d9faa 100644 --- a/apis/grpc/v1/vald/remove_vtproto.pb.go +++ b/apis/grpc/v1/vald/remove_vtproto.pb.go @@ -142,22 +142,24 @@ 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) { return nil, status.Errorf(codes.Unimplemented, "method Remove not implemented") } + 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) { diff --git a/apis/grpc/v1/vald/search.pb.go b/apis/grpc/v1/vald/search.pb.go index 6d930bd2db..2577281aa7 100644 --- a/apis/grpc/v1/vald/search.pb.go +++ b/apis/grpc/v1/vald/search.pb.go @@ -141,6 +141,7 @@ var file_v1_vald_search_proto_goTypes = []any{ (*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 d161a299bc..bf69c0fbba 100644 --- a/apis/grpc/v1/vald/search_vtproto.pb.go +++ b/apis/grpc/v1/vald/search_vtproto.pb.go @@ -332,56 +332,66 @@ 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) { return nil, status.Errorf(codes.Unimplemented, "method Search not implemented") } + 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) { return nil, status.Errorf(codes.Unimplemented, "method MultiSearch not implemented") } + 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) { return nil, status.Errorf(codes.Unimplemented, "method LinearSearch not implemented") } + 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) { return nil, status.Errorf(codes.Unimplemented, "method MultiLinearSearch not implemented") } + func (UnimplementedSearchServer) MultiLinearSearchByID( context.Context, *payload.Search_MultiIDRequest, ) (*payload.Search_Responses, error) { diff --git a/apis/grpc/v1/vald/update.pb.go b/apis/grpc/v1/vald/update.pb.go index 91e54a214a..ad05fbe50c 100644 --- a/apis/grpc/v1/vald/update.pb.go +++ b/apis/grpc/v1/vald/update.pb.go @@ -80,6 +80,7 @@ var file_v1_vald_update_proto_goTypes = []any{ (*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 d29106eb95..60f92fd0a8 100644 --- a/apis/grpc/v1/vald/update_vtproto.pb.go +++ b/apis/grpc/v1/vald/update_vtproto.pb.go @@ -127,17 +127,18 @@ 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) { 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) { diff --git a/apis/grpc/v1/vald/upsert.pb.go b/apis/grpc/v1/vald/upsert.pb.go index 124857f1ca..3c1a741dc1 100644 --- a/apis/grpc/v1/vald/upsert.pb.go +++ b/apis/grpc/v1/vald/upsert.pb.go @@ -80,6 +80,7 @@ var file_v1_vald_upsert_proto_goTypes = []any{ (*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 b5e846f1f3..1a28a9461a 100644 --- a/apis/grpc/v1/vald/upsert_vtproto.pb.go +++ b/apis/grpc/v1/vald/upsert_vtproto.pb.go @@ -127,17 +127,18 @@ 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) { 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) { diff --git a/apis/grpc/v1/vald/vald.go b/apis/grpc/v1/vald/vald.go index fb5d97dc54..a67e7c97ef 100644 --- a/apis/grpc/v1/vald/vald.go +++ b/apis/grpc/v1/vald/vald.go @@ -135,8 +135,10 @@ const ( StreamGetObjectRPCName = "StreamGetObject" StreamListObjectRPCName = "StreamListObject" - IndexInfoRPCName = "IndexInfo" - IndexDetailRPCName = "IndexDetail" + IndexInfoRPCName = "IndexInfo" + IndexDetailRPCName = "IndexDetail" + IndexStatisticsRPCName = "IndexStatistics" + IndexStatisticsDetailRPCName = "IndexStatisticsDetail" ) type client struct { diff --git a/apis/proto/v1/payload/payload.proto b/apis/proto/v1/payload/payload.proto index 2e5100f318..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; @@ -544,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/vald/index.proto b/apis/proto/v1/vald/index.proto index 2fd589588a..037132e59a 100644 --- a/apis/proto/v1/vald/index.proto +++ b/apis/proto/v1/vald/index.proto @@ -36,4 +36,13 @@ service Index { 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/swagger/v1/vald/index.swagger.json b/apis/swagger/v1/vald/index.swagger.json index 6a0745eee2..8a42e80373 100644 --- a/apis/swagger/v1/vald/index.swagger.json +++ b/apis/swagger/v1/vald/index.swagger.json @@ -53,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": { @@ -103,6 +145,165 @@ }, "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/remove.swagger.json b/apis/swagger/v1/vald/remove.swagger.json index c7fc121426..34695978e5 100644 --- a/apis/swagger/v1/vald/remove.swagger.json +++ b/apis/swagger/v1/vald/remove.swagger.json @@ -150,7 +150,7 @@ "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", @@ -274,7 +274,7 @@ "type": "object", "$ref": "#/definitions/v1RemoveTimestamp" }, - "description": "The timestamp comparison list. If more than one is specified, the `AND` search is applied." + "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/charts/vald-helm-operator/crds/valdrelease.yaml b/charts/vald-helm-operator/crds/valdrelease.yaml index 219a7d8ee6..88657d76e0 100644 --- a/charts/vald-helm-operator/crds/valdrelease.yaml +++ b/charts/vald-helm-operator/crds/valdrelease.yaml @@ -332,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/README.md b/charts/vald/README.md index 36ca5b06c3..31f0ef1494 100644 --- a/charts/vald/README.md +++ b/charts/vald/README.md @@ -112,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/values.schema.json b/charts/vald/values.schema.json index b7f77c1936..772d20c328 100644 --- a/charts/vald/values.schema.json +++ b/charts/vald/values.schema.json @@ -369,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 9ee5c7019c..4d7c2a052b 100644 --- a/charts/vald/values.yaml +++ b/charts/vald/values.yaml @@ -2174,6 +2174,9 @@ 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"} 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/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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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 d3833ad073..c13f258679 100644 --- a/dockers/agent/core/agent/Dockerfile +++ b/dockers/agent/core/agent/Dockerfile @@ -36,8 +36,8 @@ ENV ORG=vdaas ENV PKG=agent/core/agent ENV REPO=vald ENV RUST_HOME=/usr/loacl/lib/rust -ENV CARGO_HOME=${RUST_HOME}/cargo 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"] diff --git a/example/client/go.mod b/example/client/go.mod index 4736ad8483..79923afce1 100644 --- a/example/client/go.mod +++ b/example/client/go.mod @@ -11,9 +11,9 @@ replace ( 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-20240723171418-e6d459c13d2a - google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a - google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a + 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 diff --git a/example/client/go.sum b/example/client/go.sum index 87c323dd58..80e249dcb9 100644 --- a/example/client/go.sum +++ b/example/client/go.sum @@ -33,10 +33,10 @@ 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-20240723171418-e6d459c13d2a h1:YIa/rzVqMEokBkPtydCkx1VLmv3An1Uw7w1P1m6EhOY= -google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a h1:hqK4+jJZXCU4pW7jsAdGOVFIfLHQeV7LaizZKnZ84HI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +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= diff --git a/go.mod b/go.mod index 417bcf42fa..9d60dce779 100644 --- a/go.mod +++ b/go.mod @@ -5,17 +5,17 @@ go 1.22.5 replace ( 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.3 + 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.15.0 - cloud.google.com/go/iam => cloud.google.com/go/iam v1.1.11 - cloud.google.com/go/kms => cloud.google.com/go/kms v1.18.3 - cloud.google.com/go/monitoring => cloud.google.com/go/monitoring v1.20.2 + 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.4 + 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.10 - code.cloudfoundry.org/bytefmt => code.cloudfoundry.org/bytefmt v0.0.0-20240722180632-e94c220fe743 + 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 @@ -44,13 +44,13 @@ replace ( 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.55.1 + 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.8 + 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 @@ -164,7 +164,7 @@ replace ( 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.20.0 + 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 @@ -214,7 +214,7 @@ 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.4.0 + 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 @@ -226,7 +226,7 @@ replace ( 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.19.0 - github.com/onsi/gomega => github.com/onsi/gomega v1.33.1 + 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 @@ -287,13 +287,13 @@ replace ( 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-20240705175910-70002002b310 + 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 + 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 @@ -316,9 +316,9 @@ replace ( gonum.org/v1/plot => gonum.org/v1/plot v0.14.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-20240723171418-e6d459c13d2a - google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a - google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a + 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 @@ -353,11 +353,11 @@ require ( 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 @@ -382,7 +382,7 @@ 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/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.28.0 @@ -405,8 +405,8 @@ require ( 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-20240722135656-d784300faade - google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade + 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 @@ -458,7 +458,7 @@ 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-20240722153945-304e4f0156b8 // indirect @@ -466,7 +466,7 @@ require ( 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.5 // 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.20.0 // indirect @@ -501,7 +501,7 @@ 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/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 @@ -513,8 +513,8 @@ require ( 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.188.0 // indirect - google.golang.org/genproto v0.0.0-20240722135656-d784300faade // 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.1 // indirect diff --git a/go.sum b/go.sum index edb0e952d8..5e3d7727bb 100644 --- a/go.sum +++ b/go.sum @@ -35,6 +35,9 @@ cloud.google.com/go/baremetalsolution v1.2.9/go.mod h1:eFlsoR4Im039D+EVn1fKXEKWN 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= @@ -42,7 +45,8 @@ cloud.google.com/go/channel v1.17.10/go.mod h1:TzcYuXlpeex8O483ofkxbY/DKRF49NBum 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.3/go.mod h1:5GuDo3l1k9CFhfIHK1sXqlqOW/iWX4/eBlO5FtxDhvQ= +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/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.4.0/go.mod h1:SIQh1Kkb4ZJ8zJ874fqVkslA29PRXuleyj6vOzlbK7M= @@ -72,7 +76,7 @@ cloud.google.com/go/errorreporting v0.3.1/go.mod h1:6xVQXU1UuntfAf+bVkFk6nld41+C 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.15.0/go.mod h1:GWOxFXcv8GZUtYpWHw/w6IuYNux/BtmeVTMmjrm4yhk= +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= @@ -80,16 +84,19 @@ cloud.google.com/go/gkehub v0.14.10/go.mod h1:+bqT9oyCDQG2Dc2pUJKYVNJGvrKgIfm7c+ 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.11 h1:0mQ8UKSfdHLut6pH9FM3bI55KWR46ketn0PuXleDyxw= -cloud.google.com/go/iam v1.1.11/go.mod h1:biXoiLWYIKntto2joP+62sd9uW5EpkZmKIvfNcTWlnQ= +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.3/go.mod h1:y/Lcf6fyhbdn7MrG1VaDqXxM8rhOBc5rWcWAhcvZjQU= +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.5.5/go.mod h1:WV2LAxD8/rg5Z1cNW6FJ/ZpX4E4VnDnoTk0yawPBB7s= +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.7/go.mod h1:8GClkudohy1Fxm3owmBGid8W0pSgodEMwEAztp38Xng= cloud.google.com/go/longrunning v0.5.9/go.mod h1:HD+0l9/OOW0za6UWdKJtXoFAX/BGg/3Wj8p10NeWF7c= cloud.google.com/go/longrunning v0.5.10 h1:eB/BniENNRKhjz/xgiillrdcH3G74TGSl3BXinGlI7E= @@ -99,7 +106,7 @@ cloud.google.com/go/maps v1.11.4/go.mod h1:RQ2Vv/f2HKGlvCtj8xyJp8gJbVqh/CWy0xR2N 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.2/go.mod h1:36rpg/7fdQ7NX5pG5x1FA7cXTVXusOp6Zg9r9e1+oek= +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= @@ -125,7 +132,7 @@ cloud.google.com/go/resourcesettings v1.7.3/go.mod h1:lMSnOoQPDKzcF6LGJOBcQqGCY2 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.4/go.mod h1:SjKHs6rx0ELUqfbRWrWq4e7SiNKV7QMWZtvZsQm3k5w= +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= @@ -138,7 +145,7 @@ cloud.google.com/go/storagetransfer v1.10.9/go.mod h1:QKkg5Wau5jc0iXlPOZyEv3hH9m 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.10/go.mod h1:5b1BiSYQO27KgGRevNFfoIQ8czwpVgnkKbTLb4wV+XM= +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= @@ -149,8 +156,8 @@ cloud.google.com/go/vpcaccess v1.7.10/go.mod h1:69kdbMh8wvGcM3agEHP1YnHPyxIBSRcZ 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-20240722180632-e94c220fe743 h1:fOrDvk3V6DqIc2Dfe1VuVwOET7e+l1f/+j+xSA41dKM= -code.cloudfoundry.org/bytefmt v0.0.0-20240722180632-e94c220fe743/go.mod h1:/Mb4KbzA9wTtmZf3MVP6bAvvlxD/wxPx+k4xMsIoXlA= +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= @@ -203,8 +210,8 @@ 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.55.1 h1:ZTNPmbRMxaK5RlTJrBullX9r/rF1MPf3yAJOLlwDiT8= -github.com/aws/aws-sdk-go v1.55.1/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= +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= @@ -215,16 +222,16 @@ github.com/aws/aws-sdk-go-v2/credentials v1.17.27 h1:2raNba6gr2IfA0eqqiP2XiQ0UVO 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.8 h1:u1KOU1S15ufyZqmH/rA3POkiRH6EcDANHj2xHRzq+zc= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.8/go.mod h1:WPv2FRnkIOoDv/8j2gSUsI4qDc7392w5anFB/I89GZ8= +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/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= @@ -237,8 +244,8 @@ github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2 h1:sZXIzO38GZOU+O0C+INqbH7C2yALw 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.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/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= @@ -261,6 +268,7 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL 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/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= @@ -401,6 +409,8 @@ github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9 github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= 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= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= @@ -410,6 +420,13 @@ 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.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s= @@ -427,8 +444,8 @@ github.com/grafana/pyroscope-go/godeltaprof v0.1.7 h1:C11j63y7gymiW8VugJ9ZW0pWfx 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.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= +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.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= @@ -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.4.0 h1:Vy79D6mHeJJjiPdFEL2yku1kl0chZpJfZcPpb16BRl8= -github.com/moby/spdystream v0.4.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI= +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= @@ -532,8 +549,8 @@ 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.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= -github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= -github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= +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= @@ -624,10 +641,9 @@ 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.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.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/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +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= @@ -646,8 +662,8 @@ go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+ 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-20240705175910-70002002b310 h1:tEAOMoNmN2MqVNi0MMEWpTtPI4YNCXgxmAGtuv3mST0= -go.starlark.net v0.0.0-20240705175910-70002002b310/go.mod h1:YKMCv9b1WrfWmeqdV5MAuEHWsu5iC+fe6kYl2sQjdI8= +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= @@ -660,8 +676,8 @@ 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= +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= @@ -708,13 +724,13 @@ gonum.org/v1/plot v0.14.0/go.mod h1:MLdR9424SJed+5VqC6MsouEpig9pZX2VZ57H9ko2bXU= 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-20240723171418-e6d459c13d2a h1:hPbLwHFm59QoSKUT0uGaL19YN4U9W5lY4+iNXlUBNj0= -google.golang.org/genproto v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:+7gIV7FP6jBo5hiY2lsWA//NkNORQVj0J1Isc/4HzR4= -google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a h1:YIa/rzVqMEokBkPtydCkx1VLmv3An1Uw7w1P1m6EhOY= -google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys= +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-20240723171418-e6d459c13d2a h1:hqK4+jJZXCU4pW7jsAdGOVFIfLHQeV7LaizZKnZ84HI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +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= @@ -781,6 +797,7 @@ 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.4 h1:87+guW1zhvuPLh1PHybKdYFLU0YJp4FhJRmiHvm5BZw= diff --git a/hack/benchmark/assets/x1b/loader_test.go b/hack/benchmark/assets/x1b/loader_test.go index f87e045f8c..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) // } -// // }) // } // } @@ -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) // } -// // }) // } // } @@ -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) // } -// // }) // } // } @@ -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_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_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_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_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_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_option_test.go b/hack/benchmark/core/benchmark/strategy/strategy_option_test.go index e1c4195e76..1fe64495e6 100644 --- a/hack/benchmark/core/benchmark/strategy/strategy_option_test.go +++ b/hack/benchmark/core/benchmark/strategy/strategy_option_test.go @@ -100,7 +100,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -186,7 +185,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -272,7 +270,6 @@ package strategy // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -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 3ac36b05db..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) // } -// // }) // } // } @@ -249,7 +248,6 @@ package strategy // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -402,7 +400,6 @@ package strategy // if err := checkFunc(test.want, got, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -428,8 +425,7 @@ package strategy // 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 @@ -569,8 +565,7 @@ package strategy // 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 @@ -704,8 +699,7 @@ package strategy // 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 @@ -854,8 +848,7 @@ package strategy // 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_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/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/ngt/ngt_test.go b/hack/benchmark/internal/core/algorithm/ngt/ngt_test.go index 0a5221aa47..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) // } -// // }) // } // } @@ -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/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_test.go b/hack/benchmark/internal/operation/util_test.go index 33ea3d320e..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 @@ -106,8 +105,7 @@ package operation // message string // details []any // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args 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/internal/backoff/backoff_test.go b/internal/backoff/backoff_test.go index 4cf3bc2df3..0549983bbb 100644 --- a/internal/backoff/backoff_test.go +++ b/internal/backoff/backoff_test.go @@ -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/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_test.go b/internal/circuitbreaker/breaker_test.go index e521f84c14..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) // } -// // }) // } // } @@ -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_test.go b/internal/circuitbreaker/manager_test.go index cf587067db..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) // } -// // }) // } // } @@ -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_test.go b/internal/client/v1/client/agent/core/client_test.go index 525a1a055b..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.ObjectTimestampRequest -// 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.ObjectTimestampRequest -// 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/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_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_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_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_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 6e5220d344..00957b7b7b 100644 --- a/internal/client/v1/client/vald/vald.go +++ b/internal/client/v1/client/vald/vald.go @@ -784,6 +784,50 @@ func (c *client) IndexDetail( 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) { @@ -1202,6 +1246,30 @@ func (c *singleClient) IndexDetail( 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) { 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/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/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_test.go b/internal/config/config_test.go index 1591b11099..8f3520a950 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -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/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_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/ngt/ngt.go b/internal/core/algorithm/ngt/ngt.go index 69d2a17ab2..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 { @@ -856,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_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/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/rdb/mysql/mysql_test.go b/internal/db/rdb/mysql/mysql_test.go index d0de5b6d7c..c741df72cd 100644 --- a/internal/db/rdb/mysql/mysql_test.go +++ b/internal/db/rdb/mysql/mysql_test.go @@ -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_test.go b/internal/db/storage/blob/cloudstorage/option_test.go index b3e75bc3c8..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,7 +181,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -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,7 +946,6 @@ package cloudstorage // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -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_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_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/encoding/json/json_test.go b/internal/encoding/json/json_test.go index cb0ecd46ac..e7cebc7d53 100644 --- a/internal/encoding/json/json_test.go +++ b/internal/encoding/json/json_test.go @@ -315,7 +315,6 @@ func TestMarshalIndent(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -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/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_test.go b/internal/errors/errors_test.go index e4e8e67008..3e69498d23 100644 --- a/internal/errors/errors_test.go +++ b/internal/errors/errors_test.go @@ -1815,7 +1815,6 @@ func TestJoin(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1904,7 +1903,6 @@ func TestJoin(t *testing.T) { // if err := checkFunc(test.want, gotStr); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1993,7 +1991,6 @@ func TestJoin(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 b2f13f9bff..0d14e62b86 100644 --- a/internal/errors/file_test.go +++ b/internal/errors/file_test.go @@ -325,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/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/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/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_test.go b/internal/info/info_test.go new file mode 100644 index 0000000000..41f4150860 --- /dev/null +++ b/internal/info/info_test.go @@ -0,0 +1,978 @@ +// 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 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() +// }, +// } +// }(), +// */ +// } +// +// for _, tc := range tests { +// test := 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.Get() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_info_getDetail(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() +// }, +// } +// }(), +// */ +// } +// +// for _, tc := range tests { +// test := 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.getDetail() +// 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/io/copy_test.go b/internal/io/copy_test.go index 099afd9f1b..6f5cd48054 100644 --- a/internal/io/copy_test.go +++ b/internal/io/copy_test.go @@ -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_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_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_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_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_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_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_test.go b/internal/k8s/node/node_test.go index ada6e65b58..05d0bbb442 100644 --- a/internal/k8s/node/node_test.go +++ b/internal/k8s/node/node_test.go @@ -102,7 +102,6 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -119,8 +118,7 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // onReconcile func(nodes []Node) // lopts []client.ListOption // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -342,7 +340,6 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -451,14 +448,13 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // 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 { @@ -493,7 +489,7 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // { // name: "test_case_1", // args: args { -// in0:nil, +// ctx:nil, // mgr:nil, // }, // fields: fields { @@ -521,7 +517,7 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // return test { // name: "test_case_2", // args: args { -// in0:nil, +// ctx:nil, // mgr:nil, // }, // fields: fields { @@ -569,11 +565,10 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // 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) // } -// // }) // } // } @@ -686,7 +681,6 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -799,7 +793,6 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // if err := checkFunc(test.want, got, got1); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -916,7 +909,6 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // 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_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_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_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_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_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_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_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_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/log/glg/glg_test.go b/internal/log/glg/glg_test.go index 0c1493bd40..dfe07a2a99 100644 --- a/internal/log/glg/glg_test.go +++ b/internal/log/glg/glg_test.go @@ -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,7 +1227,6 @@ func TestErrorf(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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_test.go b/internal/log/log_test.go index e6ffb8d901..f3c0b5d96f 100644 --- a/internal/log/log_test.go +++ b/internal/log/log_test.go @@ -1149,7 +1149,6 @@ func TestFatalf(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1159,8 +1158,7 @@ func TestFatalf(t *testing.T) { // msg string // details []any // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1243,8 +1241,7 @@ func TestFatalf(t *testing.T) { // msg string // details []any // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1327,8 +1324,7 @@ func TestFatalf(t *testing.T) { // msg string // details []any // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1411,8 +1407,7 @@ func TestFatalf(t *testing.T) { // msg string // details []any // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1495,8 +1490,7 @@ func TestFatalf(t *testing.T) { // msg string // details []any // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args diff --git a/internal/log/mock/logger_test.go b/internal/log/mock/logger_test.go index 06f83867d4..e09ad01af7 100644 --- a/internal/log/mock/logger_test.go +++ b/internal/log/mock/logger_test.go @@ -845,8 +845,7 @@ func TestLogger_Fatalf(t *testing.T) { // FatalFunc func(vals ...any) // FatalfFunc func(format string, vals ...any) // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -978,8 +977,7 @@ func TestLogger_Fatalf(t *testing.T) { // FatalFunc func(vals ...any) // FatalfFunc func(format string, vals ...any) // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1111,8 +1109,7 @@ func TestLogger_Fatalf(t *testing.T) { // FatalFunc func(vals ...any) // FatalfFunc func(format string, vals ...any) // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1244,8 +1241,7 @@ func TestLogger_Fatalf(t *testing.T) { // FatalFunc func(vals ...any) // FatalfFunc func(format string, vals ...any) // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -1377,8 +1373,7 @@ func TestLogger_Fatalf(t *testing.T) { // FatalFunc func(vals ...any) // FatalfFunc func(format string, vals ...any) // } -// type want struct { -// } +// type want struct{} // type test struct { // name string // args args @@ -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/zap/zap_test.go b/internal/log/zap/zap_test.go index bc40f04833..35e2fbb67c 100644 --- a/internal/log/zap/zap_test.go +++ b/internal/log/zap/zap_test.go @@ -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/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/client_test.go b/internal/net/grpc/client_test.go index facab61fbc..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) // } -// // }) // } // } @@ -1233,7 +1227,6 @@ package grpc // if err := checkFunc(test.want, gotData, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1426,7 +1419,6 @@ package grpc // if err := checkFunc(test.want, gotData, err); err != nil { // tt.Errorf("error = %v", 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/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/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/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_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_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/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_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_test.go b/internal/net/grpc/status/status_test.go index 31c18c01d7..5d9f6d818f 100644 --- a/internal/net/grpc/status/status_test.go +++ b/internal/net/grpc/status/status_test.go @@ -238,7 +238,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -333,7 +332,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, gotSt); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -425,7 +423,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -517,7 +514,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -609,7 +605,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -701,7 +696,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -793,7 +787,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -885,7 +878,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -977,7 +969,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1069,7 +1060,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1161,7 +1151,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1253,7 +1242,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1345,7 +1333,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1437,7 +1424,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1529,7 +1515,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1621,7 +1606,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1713,7 +1697,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -1805,7 +1788,6 @@ func TestParseError(t *testing.T) { // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -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) // } -// // }) // } // } @@ -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) // } -// // }) // } // } @@ -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_test.go b/internal/net/grpc/stream_test.go index d8b715dca7..858df7feb1 100644 --- a/internal/net/grpc/stream_test.go +++ b/internal/net/grpc/stream_test.go @@ -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/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/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/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_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_test.go b/internal/observability/metrics/info/info_test.go index b6f793f3e2..dbcbcaf04e 100644 --- a/internal/observability/metrics/info/info_test.go +++ b/internal/observability/metrics/info/info_test.go @@ -102,7 +102,6 @@ package info // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -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_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_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_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/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/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/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/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_test.go b/internal/test/data/hdf5/option_test.go index 6d68d44f03..ea805cae8e 100644 --- a/internal/test/data/hdf5/option_test.go +++ b/internal/test/data/hdf5/option_test.go @@ -385,3 +385,5 @@ func TestWithFilePath(t *testing.T) { }) } } + +// NOT IMPLEMENTED BELOW 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/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_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_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 219a7d8ee6..88657d76e0 100644 --- a/k8s/operator/helm/crds/valdrelease.yaml +++ b/k8s/operator/helm/crds/valdrelease.yaml @@ -332,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/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_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_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_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_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_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_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_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_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_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_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_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_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 78cdd63e52..5f6d714c72 100644 --- a/pkg/agent/core/ngt/handler/grpc/handler_test.go +++ b/pkg/agent/core/ngt/handler/grpc/handler_test.go @@ -176,7 +176,250 @@ func newIndexedNGTService( // 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 439c382133..3a55be3983 100644 --- a/pkg/agent/core/ngt/handler/grpc/index.go +++ b/pkg/agent/core/ngt/handler/grpc/index.go @@ -208,3 +208,35 @@ func (s *server) IndexDetail( } 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/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_test.go b/pkg/agent/core/ngt/handler/grpc/object_test.go index 743736f435..39b5521bbb 100644 --- a/pkg/agent/core/ngt/handler/grpc/object_test.go +++ b/pkg/agent/core/ngt/handler/grpc/object_test.go @@ -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_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_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_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_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_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 dfeed90d5b..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 ( @@ -1422,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 } @@ -1980,6 +2029,21 @@ func (n *ngt) ListObjectFunc(ctx context.Context, f func(uuid string, oid uint32 }) } +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) { diff --git a/pkg/agent/core/ngt/service/ngt_test.go b/pkg/agent/core/ngt/service/ngt_test.go index d8bf88a23d..ce27e440c3 100644 --- a/pkg/agent/core/ngt/service/ngt_test.go +++ b/pkg/agent/core/ngt/service/ngt_test.go @@ -1692,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 // } @@ -1767,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, @@ -1784,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, @@ -1797,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, @@ -1824,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, @@ -1841,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, @@ -1854,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, @@ -1884,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{ @@ -2006,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, @@ -2018,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, @@ -2035,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, @@ -2048,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, @@ -2067,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, @@ -2079,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, @@ -2096,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, @@ -2109,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, @@ -2139,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{ @@ -2265,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, @@ -2277,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, @@ -2294,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, @@ -2307,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, @@ -2326,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, @@ -2338,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, @@ -2355,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, @@ -2368,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, @@ -2398,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{ @@ -2518,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, @@ -2528,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, @@ -2545,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, @@ -2558,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, @@ -2577,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, @@ -2587,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, @@ -2604,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, @@ -2617,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, @@ -2647,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{ @@ -2771,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, @@ -2781,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, @@ -2798,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, @@ -2811,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, @@ -2830,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, @@ -2840,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, @@ -2857,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, @@ -2870,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, @@ -2900,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) { @@ -3013,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, @@ -3024,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, @@ -3041,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, @@ -3054,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() // }, // }, @@ -3071,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, @@ -3082,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, @@ -3099,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, @@ -3112,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() // }, // } @@ -3132,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 // } @@ -3258,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, @@ -3268,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, @@ -3285,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, @@ -3298,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, @@ -3317,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, @@ -3327,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, @@ -3344,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, @@ -3357,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, @@ -3387,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{ @@ -3500,7 +12245,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// vecs:nil, +// uuid:"", // }, // fields: fields { // core:nil, @@ -3509,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, @@ -3526,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, @@ -3539,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, @@ -3557,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, @@ -3566,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, @@ -3583,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, @@ -3596,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, @@ -3626,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 @@ -3740,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, @@ -3750,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, @@ -3767,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, @@ -3780,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, @@ -3798,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, @@ -3808,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, @@ -3825,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, @@ -3838,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, @@ -3868,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 // } @@ -3981,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, @@ -3992,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, @@ -4009,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, @@ -4022,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() // }, // }, @@ -4039,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, @@ -4050,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, @@ -4067,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, @@ -4080,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() // }, // } @@ -4100,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 // } @@ -4223,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, @@ -4236,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, @@ -4253,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, @@ -4266,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() // }, // }, @@ -4283,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, @@ -4295,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, @@ -4312,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, @@ -4325,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() // }, // } @@ -4345,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 // } @@ -4467,9 +13351,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// vecs:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -4477,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, @@ -4494,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, @@ -4507,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() // }, // }, @@ -4524,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, @@ -4534,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, @@ -4551,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, @@ -4564,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() // }, // } @@ -4584,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 // } @@ -4708,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, @@ -4718,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, @@ -4735,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, @@ -4748,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, @@ -4766,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, @@ -4776,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, @@ -4793,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, @@ -4806,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, @@ -4836,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 // } @@ -4948,9 +13905,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuid:"", -// }, // fields: fields { // core:nil, // eg:nil, @@ -4958,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, @@ -4975,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, @@ -4988,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() // }, // }, @@ -5005,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, @@ -5015,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, @@ -5032,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, @@ -5045,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() // }, // } @@ -5065,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 // } @@ -5188,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, @@ -5199,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, @@ -5216,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, @@ -5229,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() // }, // }, @@ -5246,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, @@ -5257,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, @@ -5274,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, @@ -5287,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() // }, // } @@ -5307,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 // } @@ -5429,9 +14449,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuids:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -5439,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, @@ -5456,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, @@ -5469,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() // }, // }, @@ -5486,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, @@ -5496,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, @@ -5513,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, @@ -5526,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() // }, // } @@ -5546,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{ @@ -5669,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, @@ -5680,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, @@ -5697,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, @@ -5710,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() // }, // }, @@ -5727,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, @@ -5738,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, @@ -5755,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, @@ -5768,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() // }, // } @@ -5788,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 // } @@ -5911,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, @@ -5922,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, @@ -5939,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, @@ -5952,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() // }, // }, @@ -5969,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, @@ -5980,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, @@ -5997,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, @@ -6010,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() // }, // } @@ -6030,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 // } @@ -6152,9 +15260,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -6162,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, @@ -6179,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, @@ -6192,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() // }, // }, @@ -6209,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, @@ -6219,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, @@ -6236,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, @@ -6249,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() // }, // } @@ -6269,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 // } @@ -6392,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, @@ -6403,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, @@ -6420,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, @@ -6433,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() // }, // }, @@ -6450,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, @@ -6461,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, @@ -6478,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, @@ -6491,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() // }, // } @@ -6511,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 // } @@ -6637,9 +15804,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuid:"", -// }, // fields: fields { // core:nil, // eg:nil, @@ -6647,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, @@ -6664,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, @@ -6677,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() // }, // }, @@ -6694,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, @@ -6704,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, @@ -6721,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, @@ -6734,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() // }, // } @@ -6754,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 // } @@ -6884,9 +16076,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// uuid:"", -// }, // fields: fields { // core:nil, // eg:nil, @@ -6894,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, @@ -6911,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, @@ -6924,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() // }, // }, @@ -6941,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, @@ -6951,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, @@ -6968,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, @@ -6981,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() // }, // } @@ -7001,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{ @@ -7119,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, @@ -7126,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, @@ -7143,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, @@ -7156,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() // }, // }, @@ -7173,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, @@ -7180,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, @@ -7197,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, @@ -7210,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() // }, // } @@ -7230,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) // } @@ -7355,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, @@ -7372,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, @@ -7385,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, @@ -7409,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, @@ -7426,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, @@ -7439,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, @@ -7469,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 // } @@ -7581,9 +16904,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -7591,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, @@ -7608,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, @@ -7621,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() // }, // }, @@ -7638,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, @@ -7648,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, @@ -7665,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, @@ -7678,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() // }, // } @@ -7698,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 // } @@ -7816,6 +17184,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", +// args: args { +// sr:nil, +// }, // fields: fields { // core:nil, // eg:nil, @@ -7823,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, @@ -7840,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, @@ -7853,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() // }, // }, @@ -7870,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, @@ -7877,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, @@ -7894,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, @@ -7907,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() // }, // } @@ -7927,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 // } @@ -8052,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, @@ -8069,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, @@ -8082,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, @@ -8106,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, @@ -8123,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, @@ -8136,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, @@ -8166,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 // } @@ -8281,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, @@ -8298,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, @@ -8311,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, @@ -8335,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, @@ -8352,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, @@ -8365,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, @@ -8395,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 // } @@ -8510,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, @@ -8527,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, @@ -8540,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, @@ -8564,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, @@ -8581,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, @@ -8594,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, @@ -8624,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 // } @@ -8732,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, @@ -8739,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, @@ -8756,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, @@ -8769,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() // }, // }, @@ -8786,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, @@ -8793,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, @@ -8810,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, @@ -8823,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() // }, // } @@ -8843,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 // } @@ -8968,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, @@ -8985,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, @@ -8998,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, @@ -9022,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, @@ -9039,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, @@ -9052,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, @@ -9082,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 @@ -9204,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, @@ -9221,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, @@ -9234,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, @@ -9261,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, @@ -9278,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, @@ -9291,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, @@ -9321,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 // } @@ -9429,6 +19138,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", +// args: args { +// ctx:nil, +// }, // fields: fields { // core:nil, // eg:nil, @@ -9436,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, @@ -9453,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, @@ -9466,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() // }, // }, @@ -9483,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, @@ -9490,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, @@ -9507,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, @@ -9520,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() // }, // } @@ -9540,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{ @@ -9661,7 +19422,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// f:nil, // }, // fields: fields { // core:nil, @@ -9670,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, @@ -9687,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, @@ -9700,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, @@ -9719,7 +19490,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// f:nil, // }, // fields: fields { // core:nil, @@ -9728,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, @@ -9745,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, @@ -9758,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, @@ -9788,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_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_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_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_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_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_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_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_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_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_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_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_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_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_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 a25d06078e..acfdfad8f3 100644 --- a/pkg/gateway/lb/handler/grpc/handler.go +++ b/pkg/gateway/lb/handler/grpc/handler.go @@ -455,7 +455,7 @@ func (s *server) SearchByID( // 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)) } @@ -3765,3 +3765,299 @@ func (s *server) GetTimestamp( } 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/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_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_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_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_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/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_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_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_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_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_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_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_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_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_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_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_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_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_test.go b/pkg/manager/index/handler/grpc/handler_test.go index e937ff8a3a..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,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -320,7 +318,6 @@ package grpc // if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } 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_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_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_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_test.go b/pkg/manager/index/service/indexer_test.go index f5cb8a5ce8..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,6 @@ package service // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -710,13 +1349,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 @@ -749,13 +1389,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, @@ -782,13 +1423,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, @@ -827,13 +1469,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, @@ -843,7 +1486,6 @@ package service // if err := checkFunc(test.want, gotDetail); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } 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_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_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_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_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_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_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_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_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_test.go b/pkg/tools/cli/loadtest/assets/large_dataset_test.go index 1c9ce5525b..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 @@ -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) // } -// // }) // } // } @@ -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_test.go b/pkg/tools/cli/loadtest/assets/small_dataset_test.go index a3b0536f09..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 @@ -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) // } -// // }) // } // } @@ -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_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_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 963f89bc9c..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) // } -// // }) // } // } @@ -239,7 +238,6 @@ package service // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } -// // }) // } // } @@ -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_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/bin/agent/src/handler/index.rs b/rust/bin/agent/src/handler/index.rs index 5f3aff30c7..67888ee91d 100644 --- a/rust/bin/agent/src/handler/index.rs +++ b/rust/bin/agent/src/handler/index.rs @@ -61,4 +61,19 @@ impl index_server::Index for super::Agent { ) -> 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> { + todo!() + } } diff --git a/rust/libs/proto/src/payload.v1.rs b/rust/libs/proto/src/payload.v1.rs index 8b67f0a033..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, @@ -874,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 21f5bbe951..1ff23e3b46 100644 --- a/rust/libs/proto/src/vald.v1.tonic.rs +++ b/rust/libs/proto/src/vald.v1.tonic.rs @@ -1655,8 +1655,6 @@ pub mod index_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] use tonic::codegen::*; use tonic::codegen::http::Uri; - /** Represent the index manager service. -*/ #[derive(Debug, Clone)] pub struct IndexClient { inner: tonic::client::Grpc, @@ -1737,8 +1735,6 @@ pub mod index_client { self.inner = self.inner.max_encoding_message_size(limit); self } - /** Represent the RPC to get the index information. -*/ pub async fn index_info( &mut self, request: impl tonic::IntoRequest, @@ -1787,6 +1783,62 @@ pub mod index_client { 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. @@ -1796,8 +1848,6 @@ pub mod index_server { /// Generated trait containing gRPC methods that should be implemented for use with IndexServer. #[async_trait] pub trait Index: Send + Sync + 'static { - /** Represent the RPC to get the index information. -*/ async fn index_info( &self, request: tonic::Request, @@ -1814,9 +1864,27 @@ pub mod index_server { tonic::Response, tonic::Status, >; - } - /** Represent the index manager service. + /** 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, @@ -1994,6 +2062,104 @@ pub mod index_server { }; 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( 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/NGT_VERSION b/versions/NGT_VERSION index 585940699b..530cdd91a2 100644 --- a/versions/NGT_VERSION +++ b/versions/NGT_VERSION @@ -1 +1 @@ -2.2.3 +2.2.4 diff --git a/versions/OPERATOR_SDK_VERSION b/versions/OPERATOR_SDK_VERSION index 2f2ce0df61..251643f6ba 100644 --- a/versions/OPERATOR_SDK_VERSION +++ b/versions/OPERATOR_SDK_VERSION @@ -1 +1 @@ -v1.33 +v1.35 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE b/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE index cf8690732f..a36e9b0906 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE +++ b/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE @@ -1 +1 @@ -2.18.0 +2.18.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD b/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD index cf8690732f..a36e9b0906 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD +++ b/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD @@ -1 +1 @@ -2.18.0 +2.18.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_INIT b/versions/actions/GITHUB_CODEQL_ACTION_INIT index cf8690732f..a36e9b0906 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_INIT +++ b/versions/actions/GITHUB_CODEQL_ACTION_INIT @@ -1 +1 @@ -2.18.0 +2.18.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF b/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF index cf8690732f..a36e9b0906 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF +++ b/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF @@ -1 +1 @@ -2.18.0 +2.18.1 From caa8f03ff83c24d904edc018c72c0a39539a489e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:40:41 +0900 Subject: [PATCH 5/5] style: format code with Gofumpt and Prettier (#2531) This commit fixes the style issues introduced in 76eb8d7 according to the output from Gofumpt and Prettier. Details: None Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> Co-authored-by: Yusuke Kato --- docs/api/flush.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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