From f62d60d9079ad0222cdbe932f1c3f10c1bc69970 Mon Sep 17 00:00:00 2001 From: kpango Date: Tue, 8 Sep 2020 16:31:30 +0900 Subject: [PATCH 01/12] use runtime.GC for reducing indexing memory Signed-off-by: kpango --- pkg/agent/core/ngt/service/ngt.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/agent/core/ngt/service/ngt.go b/pkg/agent/core/ngt/service/ngt.go index 95dbfa8da3..068617f348 100644 --- a/pkg/agent/core/ngt/service/ngt.go +++ b/pkg/agent/core/ngt/service/ngt.go @@ -538,8 +538,10 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) { } n.indexing.Store(true) atomic.StoreUint64(&n.ic, 0) + runtime.GC() t := time.Now().UnixNano() defer n.indexing.Store(false) + defer runtime.GC() log.Infof("create index operation started, uncommitted indexes = %d", ic) delList := make([]string, 0, ic) @@ -644,6 +646,7 @@ func (n *ngt) SaveIndex(ctx context.Context) (err error) { } func (n *ngt) saveIndex(ctx context.Context) (err error) { + defer runtime.GC() eg, ctx := errgroup.New(ctx) eg.Go(safety.RecoverFunc(func() error { From b2a6c97614a10b26fb8b4e4506965a0b49284744 Mon Sep 17 00:00:00 2001 From: kpango Date: Tue, 8 Sep 2020 18:22:04 +0900 Subject: [PATCH 02/12] downgrade go version for debug Signed-off-by: kpango --- versions/GO_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/GO_VERSION b/versions/GO_VERSION index ace44233b4..9be7846722 100644 --- a/versions/GO_VERSION +++ b/versions/GO_VERSION @@ -1 +1 @@ -1.15.1 +1.14.8 From 7ea859e803c3509d841586be977978c1dfb4c337 Mon Sep 17 00:00:00 2001 From: kpango Date: Tue, 8 Sep 2020 19:07:11 +0900 Subject: [PATCH 03/12] fix Signed-off-by: kpango --- versions/GO_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/GO_VERSION b/versions/GO_VERSION index 9be7846722..ace44233b4 100644 --- a/versions/GO_VERSION +++ b/versions/GO_VERSION @@ -1 +1 @@ -1.14.8 +1.15.1 From e16022e54d2f2ca06b3da15ae5f08b51c8f2bfd2 Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 10 Sep 2020 11:10:52 +0900 Subject: [PATCH 04/12] reduce create index & save index timing using busy loop and atomic countor Signed-off-by: kpango --- pkg/agent/core/ngt/service/ngt.go | 38 ++++++++++++++++++++----------- versions/GO_VERSION | 2 +- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/pkg/agent/core/ngt/service/ngt.go b/pkg/agent/core/ngt/service/ngt.go index 068617f348..874c402e44 100644 --- a/pkg/agent/core/ngt/service/ngt.go +++ b/pkg/agent/core/ngt/service/ngt.go @@ -76,8 +76,9 @@ type ngt struct { dvc *vcaches // deletion vector cache // statuses - indexing atomic.Value - saveMu sync.Mutex // creating or saving index + indexing atomic.Value + saving atomic.Value + lastNoice uint64 // last number of create index execution this value prevent unnecessary saveindex. // counters ic uint64 // insert count @@ -154,6 +155,7 @@ func New(cfg *config.NGT, opts ...Option) (nn NGT, err error) { } n.indexing.Store(false) + n.saving.Store(false) return n, nil } @@ -333,7 +335,7 @@ func (n *ngt) Start(ctx context.Context) <-chan error { } func (n *ngt) Search(vec []float32, size uint32, epsilon, radius float32) ([]model.Distance, error) { - if n.indexing.Load().(bool) { + if n.IsIndexing() { return make([]model.Distance, 0), nil } sr, err := n.core.Search(vec, int(size), epsilon, radius) @@ -360,7 +362,7 @@ func (n *ngt) Search(vec []float32, size uint32, epsilon, radius float32) ([]mod } func (n *ngt) SearchByID(uuid string, size uint32, epsilon, radius float32) (dst []model.Distance, err error) { - if n.indexing.Load().(bool) { + if n.IsIndexing() { log.Debug("SearchByID\t now indexing...") return make([]model.Distance, 0), nil } @@ -526,10 +528,7 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) { } }() - n.saveMu.Lock() - defer n.saveMu.Unlock() - - if n.indexing.Load().(bool) { + if n.IsIndexing() || n.IsSaving() { return nil } ic := atomic.LoadUint64(&n.ic) @@ -634,10 +633,6 @@ func (n *ngt) SaveIndex(ctx context.Context) (err error) { span.End() } }() - - n.saveMu.Lock() - defer n.saveMu.Unlock() - if len(n.path) != 0 && !n.inMem { err = n.saveIndex(ctx) } @@ -646,7 +641,18 @@ func (n *ngt) SaveIndex(ctx context.Context) (err error) { } func (n *ngt) saveIndex(ctx context.Context) (err error) { + noice := atomic.LoadUint64(&n.nocie) + if atomic.LoadUint64(&n.lastNoice) == noice { + return + } + atomic.SwapUint64(&n.lastNoice, noice) + // wait for not indexing & not saving + for n.IsIndexing() || n.IsSaving() { + } + n.saving.Store(true) defer runtime.GC() + defer n.saving.Store(false) + eg, ctx := errgroup.New(ctx) eg.Go(safety.RecoverFunc(func() error { @@ -733,8 +739,14 @@ func (n *ngt) insertCache(uuid string) (*vcache, bool) { return nil, false } +func (n *ngt) IsSaving() bool { + s, ok := n.saving.Load().(bool) + return s && ok +} + func (n *ngt) IsIndexing() bool { - return n.indexing.Load().(bool) + i, ok := n.indexing.Load().(bool) + return i && ok } func (n *ngt) UUIDs(ctx context.Context) (uuids []string) { diff --git a/versions/GO_VERSION b/versions/GO_VERSION index ace44233b4..42cf0675c5 100644 --- a/versions/GO_VERSION +++ b/versions/GO_VERSION @@ -1 +1 @@ -1.15.1 +1.15.2 From b673e5beedfb3623a2500631dde612e27503fe5e Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 10 Sep 2020 11:20:07 +0900 Subject: [PATCH 05/12] fix --- go.mod | 8 +- go.sum | 16 +- pkg/agent/core/ngt/service/ngt_test.go | 503 +++++++++++++++++++------ 3 files changed, 402 insertions(+), 125 deletions(-) diff --git a/go.mod b/go.mod index fde04e2846..01712641f2 100755 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 replace ( cloud.google.com/go => cloud.google.com/go v0.65.0 github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.2.0+incompatible - github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.34.18 + github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.34.20 github.com/boltdb/bolt => github.com/boltdb/bolt v1.3.1 github.com/coreos/etcd => go.etcd.io/etcd v3.3.25+incompatible github.com/docker/docker => github.com/moby/moby v1.13.1 @@ -21,10 +21,10 @@ replace ( github.com/gorilla/websocket => github.com/gorilla/websocket v1.4.2 github.com/hailocab/go-hostpool => github.com/monzo/go-hostpool v0.0.0-20200724120130-287edbb29340 github.com/hydrogen18/memlistener => github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91 - github.com/klauspost/compress => github.com/klauspost/compress v1.10.12-0.20200903102441-28b892527237 + github.com/klauspost/compress => github.com/klauspost/compress v1.11.1-0.20200908135004-a2bf5b1ec3aa github.com/tensorflow/tensorflow => github.com/tensorflow/tensorflow v2.1.0+incompatible golang.org/x/crypto => golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a - google.golang.org/grpc => google.golang.org/grpc v1.31.1 + google.golang.org/grpc => google.golang.org/grpc v1.32.0 google.golang.org/protobuf => google.golang.org/protobuf v1.25.0 k8s.io/api => k8s.io/api v0.18.8 k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.8 @@ -71,7 +71,7 @@ require ( go.uber.org/goleak v1.1.10 golang.org/x/net v0.0.0-20200904194848-62affa334b73 golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 - golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f + golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 gonum.org/v1/hdf5 v0.0.0-20200504100616-496fefe91614 gonum.org/v1/plot v0.8.0 google.golang.org/api v0.31.0 diff --git a/go.sum b/go.sum index b2b5744a4b..a934835c83 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/aws/aws-sdk-go v1.34.18 h1:Mo/Clq3u1dQFzpg8YQqBii8m+Vl3fWIfHi6kXs5wpuM= -github.com/aws/aws-sdk-go v1.34.18/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/aws/aws-sdk-go v1.34.20 h1:D9otznteZZyN5pRyFETqveYia/85Xzk7+RaPGB1I9fE= +github.com/aws/aws-sdk-go v1.34.20/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -286,8 +286,8 @@ github.com/jung-kurt/gofpdf v1.16.2 h1:jgbatWHfRlPYiK85qgevsZTHviWXKwB1TTiKdz5Pt github.com/jung-kurt/gofpdf v1.16.2/go.mod h1:1hl7y57EsiPAkLbOwzpzqgx1A30nQCk/YmFV8S2vmK0= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.10.12-0.20200903102441-28b892527237 h1:/d9euTqPnSaB1CVc/lFFns/hHf1JTZAxfEWS5dbn+x0= -github.com/klauspost/compress v1.10.12-0.20200903102441-28b892527237/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.11.1-0.20200908135004-a2bf5b1ec3aa h1:9xEtLQvhsiWZvijuoPGoFVxijpWuacg3KDA+kvlI4+4= +github.com/klauspost/compress v1.11.1-0.20200908135004-a2bf5b1ec3aa/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kpango/fastime v1.0.8/go.mod h1:Y5XY5bLG5yc7g2XmMUzc22XYV1XaH+KgUOHkDvLp4SA= @@ -622,8 +622,8 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200727154430-2d971f7391a4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f h1:Fqb3ao1hUmOR3GkUOg/Y+BadLwykBIzs5q8Ez2SbHyc= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 h1:W0lCpv29Hv0UaM1LXb9QlBHLNP8UFfcKjblhVCWftOM= +golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -746,8 +746,8 @@ google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200831141814-d751682dd103/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d h1:92D1fum1bJLKSdr11OJ+54YeCMCGYIygTA7R/YZxH5M= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/grpc v1.31.1 h1:SfXqXS5hkufcdZ/mHtYCh53P2b+92WQq/DZcKLgsFRs= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0= +google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= diff --git a/pkg/agent/core/ngt/service/ngt_test.go b/pkg/agent/core/ngt/service/ngt_test.go index fba0065b7c..45880e7ca7 100644 --- a/pkg/agent/core/ngt/service/ngt_test.go +++ b/pkg/agent/core/ngt/service/ngt_test.go @@ -20,7 +20,6 @@ package service import ( "context" "reflect" - "sync" "sync/atomic" "testing" "time" @@ -123,7 +122,8 @@ func Test_ngt_initNGT(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -174,7 +174,8 @@ func Test_ngt_initNGT(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -212,7 +213,8 @@ func Test_ngt_initNGT(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -256,7 +258,8 @@ func Test_ngt_initNGT(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -292,7 +295,8 @@ func Test_ngt_loadKVS(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -339,7 +343,8 @@ func Test_ngt_loadKVS(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -374,7 +379,8 @@ func Test_ngt_loadKVS(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -418,7 +424,8 @@ func Test_ngt_loadKVS(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -457,7 +464,8 @@ func Test_ngt_Start(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -508,7 +516,8 @@ func Test_ngt_Start(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -546,7 +555,8 @@ func Test_ngt_Start(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -590,7 +600,8 @@ func Test_ngt_Start(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -632,7 +643,8 @@ func Test_ngt_Search(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -690,7 +702,8 @@ func Test_ngt_Search(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -731,7 +744,8 @@ func Test_ngt_Search(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -775,7 +789,8 @@ func Test_ngt_Search(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -817,7 +832,8 @@ func Test_ngt_SearchByID(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -875,7 +891,8 @@ func Test_ngt_SearchByID(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -916,7 +933,8 @@ func Test_ngt_SearchByID(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -960,7 +978,8 @@ func Test_ngt_SearchByID(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -1000,7 +1019,8 @@ func Test_ngt_Insert(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -1052,7 +1072,8 @@ func Test_ngt_Insert(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1091,7 +1112,8 @@ func Test_ngt_Insert(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1135,7 +1157,8 @@ func Test_ngt_Insert(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -1177,7 +1200,8 @@ func Test_ngt_insert(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -1231,7 +1255,8 @@ func Test_ngt_insert(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1272,7 +1297,8 @@ func Test_ngt_insert(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1316,7 +1342,8 @@ func Test_ngt_insert(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -1355,7 +1382,8 @@ func Test_ngt_InsertMultiple(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -1406,7 +1434,8 @@ func Test_ngt_InsertMultiple(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1444,7 +1473,8 @@ func Test_ngt_InsertMultiple(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1488,7 +1518,8 @@ func Test_ngt_InsertMultiple(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -1528,7 +1559,8 @@ func Test_ngt_Update(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -1580,7 +1612,8 @@ func Test_ngt_Update(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1619,7 +1652,8 @@ func Test_ngt_Update(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1663,7 +1697,8 @@ func Test_ngt_Update(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -1702,7 +1737,8 @@ func Test_ngt_UpdateMultiple(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -1753,7 +1789,8 @@ func Test_ngt_UpdateMultiple(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1791,7 +1828,8 @@ func Test_ngt_UpdateMultiple(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1835,7 +1873,8 @@ func Test_ngt_UpdateMultiple(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -1874,7 +1913,8 @@ func Test_ngt_Delete(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -1925,7 +1965,8 @@ func Test_ngt_Delete(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -1963,7 +2004,8 @@ func Test_ngt_Delete(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2007,7 +2049,8 @@ func Test_ngt_Delete(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -2047,7 +2090,8 @@ func Test_ngt_delete(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -2099,7 +2143,8 @@ func Test_ngt_delete(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2138,7 +2183,8 @@ func Test_ngt_delete(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2182,7 +2228,8 @@ func Test_ngt_delete(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -2221,7 +2268,8 @@ func Test_ngt_DeleteMultiple(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -2272,7 +2320,8 @@ func Test_ngt_DeleteMultiple(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2310,7 +2359,8 @@ func Test_ngt_DeleteMultiple(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2354,7 +2404,8 @@ func Test_ngt_DeleteMultiple(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -2393,7 +2444,8 @@ func Test_ngt_GetObject(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -2448,7 +2500,8 @@ func Test_ngt_GetObject(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2486,7 +2539,8 @@ func Test_ngt_GetObject(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2530,7 +2584,8 @@ func Test_ngt_GetObject(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -2570,7 +2625,8 @@ func Test_ngt_CreateIndex(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -2622,7 +2678,8 @@ func Test_ngt_CreateIndex(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2661,7 +2718,8 @@ func Test_ngt_CreateIndex(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2705,7 +2763,8 @@ func Test_ngt_CreateIndex(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -2744,7 +2803,8 @@ func Test_ngt_SaveIndex(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -2795,7 +2855,8 @@ func Test_ngt_SaveIndex(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2833,7 +2894,8 @@ func Test_ngt_SaveIndex(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -2877,7 +2939,8 @@ func Test_ngt_SaveIndex(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -2916,7 +2979,8 @@ func Test_ngt_saveIndex(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -2967,7 +3031,8 @@ func Test_ngt_saveIndex(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3005,7 +3070,8 @@ func Test_ngt_saveIndex(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3049,7 +3115,8 @@ func Test_ngt_saveIndex(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -3089,7 +3156,8 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -3141,7 +3209,8 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3180,7 +3249,8 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3224,7 +3294,8 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -3263,7 +3334,8 @@ func Test_ngt_Exists(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -3318,7 +3390,8 @@ func Test_ngt_Exists(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3356,7 +3429,8 @@ func Test_ngt_Exists(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3400,7 +3474,8 @@ func Test_ngt_Exists(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -3439,7 +3514,8 @@ func Test_ngt_insertCache(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -3494,7 +3570,8 @@ func Test_ngt_insertCache(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3532,7 +3609,8 @@ func Test_ngt_insertCache(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3576,7 +3654,8 @@ func Test_ngt_insertCache(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -3604,6 +3683,172 @@ func Test_ngt_insertCache(t *testing.T) { } } +func Test_ngt_IsSaving(t *testing.T) { + type fields struct { + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool + } + type want struct { + want bool + } + type test struct { + name string + fields fields + want want + checkFunc func(want, bool) error + beforeFunc func() + afterFunc func() + } + 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, + ivc: vcaches{}, + dvc: vcaches{}, + indexing: nil, + saving: nil, + lastNoice: 0, + ic: 0, + nocie: 0, + inMem: false, + alen: 0, + lim: nil, + dur: nil, + sdur: nil, + minLit: nil, + maxLit: nil, + litFactor: nil, + path: "", + poolSize: 0, + radius: 0, + epsilon: 0, + idelay: nil, + dcd: false, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + core: nil, + eg: nil, + kvs: nil, + ivc: vcaches{}, + dvc: vcaches{}, + indexing: nil, + saving: nil, + lastNoice: 0, + ic: 0, + nocie: 0, + inMem: false, + alen: 0, + lim: nil, + dur: nil, + sdur: nil, + minLit: nil, + maxLit: nil, + litFactor: nil, + path: "", + poolSize: 0, + radius: 0, + epsilon: 0, + idelay: nil, + dcd: false, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + n := &ngt{ + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, + } + + got := n.IsSaving() + if err := test.checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + func Test_ngt_IsIndexing(t *testing.T) { type fields struct { core core.NGT @@ -3612,7 +3857,8 @@ func Test_ngt_IsIndexing(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -3659,7 +3905,8 @@ func Test_ngt_IsIndexing(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3694,7 +3941,8 @@ func Test_ngt_IsIndexing(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3738,7 +3986,8 @@ func Test_ngt_IsIndexing(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -3777,7 +4026,8 @@ func Test_ngt_UUIDs(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -3828,7 +4078,8 @@ func Test_ngt_UUIDs(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3866,7 +4117,8 @@ func Test_ngt_UUIDs(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -3910,7 +4162,8 @@ func Test_ngt_UUIDs(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -3946,7 +4199,8 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -3993,7 +4247,8 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4028,7 +4283,8 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4072,7 +4328,8 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -4108,7 +4365,8 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -4155,7 +4413,8 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4190,7 +4449,8 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4234,7 +4494,8 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -4270,7 +4531,8 @@ func Test_ngt_Len(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -4317,7 +4579,8 @@ func Test_ngt_Len(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4352,7 +4615,8 @@ func Test_ngt_Len(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4396,7 +4660,8 @@ func Test_ngt_Len(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -4432,7 +4697,8 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -4479,7 +4745,8 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4514,7 +4781,8 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4558,7 +4826,8 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -4594,7 +4863,8 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -4641,7 +4911,8 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4676,7 +4947,8 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4720,7 +4992,8 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, @@ -4759,7 +5032,8 @@ func Test_ngt_Close(t *testing.T) { ivc *vcaches dvc *vcaches indexing atomic.Value - saveMu sync.Mutex + saving atomic.Value + lastNoice uint64 ic uint64 nocie uint64 inMem bool @@ -4810,7 +5084,8 @@ func Test_ngt_Close(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4848,7 +5123,8 @@ func Test_ngt_Close(t *testing.T) { ivc: vcaches{}, dvc: vcaches{}, indexing: nil, - saveMu: sync.Mutex{}, + saving: nil, + lastNoice: 0, ic: 0, nocie: 0, inMem: false, @@ -4892,7 +5168,8 @@ func Test_ngt_Close(t *testing.T) { ivc: test.fields.ivc, dvc: test.fields.dvc, indexing: test.fields.indexing, - saveMu: test.fields.saveMu, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, ic: test.fields.ic, nocie: test.fields.nocie, inMem: test.fields.inMem, From c22261d7477e8550cb77cf9f5b77d23389e91c0f Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 10 Sep 2020 12:11:56 +0900 Subject: [PATCH 06/12] fix Signed-off-by: kpango --- charts/vald/values.yaml | 3 + internal/config/ngt.go | 3 + internal/net/http/middleware/timeout.go | 2 +- .../metrics/agent/core/ngt/ngt.go | 29 + .../metrics/agent/sidecar/sidecar_test.go | 663 ++++ .../metrics/db/kvs/redis/redis_test.go | 897 +++++ .../db/nosql/cassandra/cassandra_test.go | 603 +++ .../metrics/db/rdb/mysql/mysql_test.go | 692 ++++ .../metrics/manager/index/index_test.go | 386 ++ pkg/agent/core/ngt/config/config_test.go | 2 +- .../core/ngt/handler/grpc/handler_test.go | 45 +- .../core/ngt/handler/grpc/option_test.go | 19 +- .../core/ngt/handler/rest/handler_test.go | 31 +- .../core/ngt/handler/rest/option_test.go | 10 +- pkg/agent/core/ngt/router/option_test.go | 28 +- pkg/agent/core/ngt/router/router_test.go | 2 + pkg/agent/core/ngt/service/kvs/kvs_test.go | 9 + pkg/agent/core/ngt/service/kvs/ou_test.go | 13 + pkg/agent/core/ngt/service/kvs/uo_test.go | 14 + pkg/agent/core/ngt/service/ngt.go | 22 +- pkg/agent/core/ngt/service/ngt_test.go | 3359 ++++++++++------- pkg/agent/core/ngt/service/option.go | 9 + pkg/agent/core/ngt/service/option_test.go | 114 + pkg/agent/core/ngt/service/vcaches_test.go | 15 + pkg/agent/core/ngt/usecase/agentd.go | 1 + pkg/agent/core/ngt/usecase/agentd_test.go | 13 +- 26 files changed, 5514 insertions(+), 1470 deletions(-) create mode 100644 internal/observability/metrics/agent/sidecar/sidecar_test.go create mode 100644 internal/observability/metrics/db/kvs/redis/redis_test.go create mode 100644 internal/observability/metrics/db/nosql/cassandra/cassandra_test.go create mode 100644 internal/observability/metrics/db/rdb/mysql/mysql_test.go create mode 100644 internal/observability/metrics/manager/index/index_test.go diff --git a/charts/vald/values.yaml b/charts/vald/values.yaml index f0b6a8444e..510c64f748 100644 --- a/charts/vald/values.yaml +++ b/charts/vald/values.yaml @@ -1285,6 +1285,9 @@ agent: # agent.ngt.load_index_timeout_factor -- a factor of load index timeout. # timeout duration will be calculated by (index count to be loaded) * (factor). load_index_timeout_factor: 1ms + # @schema {"name": "agent.ngt.enable_proactive_gc", "type": "boolean"} + # agent.ngt.enable_proactive_gc -- proactive gc enabled + enable_proactive_gc: true # @schema {"name": "agent.sidecar", "type": "object"} sidecar: # @schema {"name": "agent.sidecar.enabled", "type": "boolean"} diff --git a/internal/config/ngt.go b/internal/config/ngt.go index 317f129906..4368ad08ca 100644 --- a/internal/config/ngt.go +++ b/internal/config/ngt.go @@ -75,6 +75,9 @@ type NGT struct { // LoadIndexTimeoutFactor represents a factor of load index timeout LoadIndexTimeoutFactor string `yaml:"load_index_timeout_factor" json:"load_index_timeout_factor"` + + // EnableProactiveGC enables more proactive GC call for reducing heap memory allocation + EnableProactiveGC bool `yaml:"enable_proactive_gc" json:"enable_proactive_gc"` } // Bind returns NGT object whose some string value is filed value or environment value. diff --git a/internal/net/http/middleware/timeout.go b/internal/net/http/middleware/timeout.go index 741cb622f3..42387c4258 100644 --- a/internal/net/http/middleware/timeout.go +++ b/internal/net/http/middleware/timeout.go @@ -78,7 +78,7 @@ func (t *timeout) Wrap(h rest.Func) rest.Func { case <-ctx.Done(): // timeout passed or parent context canceled first, // it is the responsibility for handler to response to the user - return http.StatusRequestTimeout, errors.ErrHandlerTimeout(ctx.Err(), time.Unix(0, fastime.UnixNanoNow()-start)) + return http.StatusRequestTimeout, errors.ErrHandlerTimeout(ctx.Err(), time.Duration(fastime.UnixNanoNow()-start)) } } } diff --git a/internal/observability/metrics/agent/core/ngt/ngt.go b/internal/observability/metrics/agent/core/ngt/ngt.go index bca633949b..54a27c2ee2 100644 --- a/internal/observability/metrics/agent/core/ngt/ngt.go +++ b/internal/observability/metrics/agent/core/ngt/ngt.go @@ -31,7 +31,9 @@ type ngtMetrics struct { insertVCacheCount metrics.Int64Measure deleteVCacheCount metrics.Int64Measure completedCreateIndexTotal metrics.Int64Measure + executedProactiveGCTotal metrics.Int64Measure isIndexing metrics.Int64Measure + isSaving metrics.Int64Measure } func New(n service.NGT) metrics.Metric { @@ -57,10 +59,18 @@ func New(n service.NGT) metrics.Metric { metrics.ValdOrg+"/ngt/completed_create_index_total", "the cumulative count of completed create index execution", metrics.UnitDimensionless), + executedProactiveGCTotal: *metrics.Int64( + metrics.ValdOrg+"/ngt/executed_proactive_gc_total", + "the cumulative count of proactive GC execution", + metrics.UnitDimensionless), isIndexing: *metrics.Int64( metrics.ValdOrg+"/ngt/is_indexing", "currently indexing or not", metrics.UnitDimensionless), + isSaving: *metrics.Int64( + metrics.ValdOrg+"/ngt/is_saving", + "currently saving or not", + metrics.UnitDimensionless), } } @@ -70,13 +80,20 @@ func (n *ngtMetrics) Measurement(ctx context.Context) ([]metrics.Measurement, er isIndexing = 1 } + var isSaving int64 + if n.ngt.IsSaving() { + isSaving = 1 + } + return []metrics.Measurement{ n.indexCount.M(int64(n.ngt.Len())), n.uncommittedIndexCount.M(int64(n.ngt.InsertVCacheLen() + n.ngt.DeleteVCacheLen())), n.insertVCacheCount.M(int64(n.ngt.InsertVCacheLen())), n.deleteVCacheCount.M(int64(n.ngt.DeleteVCacheLen())), n.completedCreateIndexTotal.M(int64(n.ngt.NumberOfCreateIndexExecution())), + n.executedProactiveGCTotal.M(int64(n.ngt.NumberOfProactiveGCExecution())), n.isIndexing.M(isIndexing), + n.isSaving.M(isSaving), }, nil } @@ -116,11 +133,23 @@ func (n *ngtMetrics) View() []*metrics.View { Measure: &n.completedCreateIndexTotal, Aggregation: metrics.LastValue(), }, + &metrics.View{ + Name: "ngt_executed_proactive_gc_total", + Description: n.executedProactiveGCTotal.Description(), + Measure: &n.executedProactiveGCTotal, + Aggregation: metrics.LastValue(), + }, &metrics.View{ Name: "ngt_is_indexing", Description: n.isIndexing.Description(), Measure: &n.isIndexing, Aggregation: metrics.LastValue(), }, + &metrics.View{ + Name: "ngt_is_indexing", + Description: n.isSaving.Description(), + Measure: &n.isSaving, + Aggregation: metrics.LastValue(), + }, } } diff --git a/internal/observability/metrics/agent/sidecar/sidecar_test.go b/internal/observability/metrics/agent/sidecar/sidecar_test.go new file mode 100644 index 0000000000..30db37b31d --- /dev/null +++ b/internal/observability/metrics/agent/sidecar/sidecar_test.go @@ -0,0 +1,663 @@ +// +// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Package sidecar provides functions for sidecar stats +package sidecar + +import ( + "context" + "reflect" + "sync" + "testing" + + "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/observability/metrics" + "github.com/vdaas/vald/pkg/agent/sidecar/service/observer" + "go.uber.org/goleak" +) + +func TestNew(t *testing.T) { + type want struct { + want MetricsHook + err error + } + type test struct { + name string + want want + checkFunc func(want, MetricsHook, error) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got MetricsHook, err error) error { + 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, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + got, err := New() + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_sidecarMetrics_Measurement(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + uploadTotal metrics.Int64Measure + uploadBytes metrics.Int64Measure + uploadLatency metrics.Float64Measure + storageTypeKey metrics.Key + bucketNameKey metrics.Key + filenameKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want []metrics.Measurement + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.Measurement, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.Measurement, err error) error { + 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 { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + sm := &sidecarMetrics{ + uploadTotal: test.fields.uploadTotal, + uploadBytes: test.fields.uploadBytes, + uploadLatency: test.fields.uploadLatency, + storageTypeKey: test.fields.storageTypeKey, + bucketNameKey: test.fields.bucketNameKey, + filenameKey: test.fields.filenameKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got, err := sm.Measurement(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_sidecarMetrics_MeasurementWithTags(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + uploadTotal metrics.Int64Measure + uploadBytes metrics.Int64Measure + uploadLatency metrics.Float64Measure + storageTypeKey metrics.Key + bucketNameKey metrics.Key + filenameKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want []metrics.MeasurementWithTags + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.MeasurementWithTags, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.MeasurementWithTags, err error) error { + 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 { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + sm := &sidecarMetrics{ + uploadTotal: test.fields.uploadTotal, + uploadBytes: test.fields.uploadBytes, + uploadLatency: test.fields.uploadLatency, + storageTypeKey: test.fields.storageTypeKey, + bucketNameKey: test.fields.bucketNameKey, + filenameKey: test.fields.filenameKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got, err := sm.MeasurementWithTags(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_sidecarMetrics_View(t *testing.T) { + type fields struct { + uploadTotal metrics.Int64Measure + uploadBytes metrics.Int64Measure + uploadLatency metrics.Float64Measure + storageTypeKey metrics.Key + bucketNameKey metrics.Key + filenameKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want []*metrics.View + } + type test struct { + name string + fields fields + want want + checkFunc func(want, []*metrics.View) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got []*metrics.View) error { + if !reflect.DeepEqual(got, w.want) { + return 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 { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + sm := &sidecarMetrics{ + uploadTotal: test.fields.uploadTotal, + uploadBytes: test.fields.uploadBytes, + uploadLatency: test.fields.uploadLatency, + storageTypeKey: test.fields.storageTypeKey, + bucketNameKey: test.fields.bucketNameKey, + filenameKey: test.fields.filenameKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got := sm.View() + if err := test.checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_sidecarMetrics_BeforeProcess(t *testing.T) { + type args struct { + ctx context.Context + info *observer.BackupInfo + } + type fields struct { + uploadTotal metrics.Int64Measure + uploadBytes metrics.Int64Measure + uploadLatency metrics.Float64Measure + storageTypeKey metrics.Key + bucketNameKey metrics.Key + filenameKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want context.Context + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, context.Context, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got context.Context, err error) error { + 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, + info: nil, + }, + fields: fields { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + info: nil, + }, + fields: fields { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + sm := &sidecarMetrics{ + uploadTotal: test.fields.uploadTotal, + uploadBytes: test.fields.uploadBytes, + uploadLatency: test.fields.uploadLatency, + storageTypeKey: test.fields.storageTypeKey, + bucketNameKey: test.fields.bucketNameKey, + filenameKey: test.fields.filenameKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got, err := sm.BeforeProcess(test.args.ctx, test.args.info) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_sidecarMetrics_AfterProcess(t *testing.T) { + type args struct { + ctx context.Context + info *observer.BackupInfo + } + type fields struct { + uploadTotal metrics.Int64Measure + uploadBytes metrics.Int64Measure + uploadLatency metrics.Float64Measure + storageTypeKey metrics.Key + bucketNameKey metrics.Key + filenameKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + info: nil, + }, + fields: fields { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + info: nil, + }, + fields: fields { + uploadTotal: nil, + uploadBytes: nil, + uploadLatency: nil, + storageTypeKey: nil, + bucketNameKey: nil, + filenameKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + sm := &sidecarMetrics{ + uploadTotal: test.fields.uploadTotal, + uploadBytes: test.fields.uploadBytes, + uploadLatency: test.fields.uploadLatency, + storageTypeKey: test.fields.storageTypeKey, + bucketNameKey: test.fields.bucketNameKey, + filenameKey: test.fields.filenameKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + err := sm.AfterProcess(test.args.ctx, test.args.info) + if err := test.checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} diff --git a/internal/observability/metrics/db/kvs/redis/redis_test.go b/internal/observability/metrics/db/kvs/redis/redis_test.go new file mode 100644 index 0000000000..9c232cf840 --- /dev/null +++ b/internal/observability/metrics/db/kvs/redis/redis_test.go @@ -0,0 +1,897 @@ +// +// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Package redis provides redis metrics functions +package redis + +import ( + "context" + "reflect" + "sync" + "testing" + + "github.com/vdaas/vald/internal/db/kvs/redis" + "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/observability/metrics" + "go.uber.org/goleak" +) + +func TestNew(t *testing.T) { + type want struct { + wantO MetricsHook + err error + } + type test struct { + name string + want want + checkFunc func(want, MetricsHook, error) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, gotO MetricsHook, err error) error { + 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", + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + gotO, err := New() + if err := test.checkFunc(test.want, gotO, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_redisMetrics_Measurement(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + pipelineTotal metrics.Int64Measure + pipelineLatency metrics.Float64Measure + cmdNameKey metrics.Key + numCmdKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want []metrics.Measurement + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.Measurement, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.Measurement, err error) error { + 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 { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + rm := &redisMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + pipelineTotal: test.fields.pipelineTotal, + pipelineLatency: test.fields.pipelineLatency, + cmdNameKey: test.fields.cmdNameKey, + numCmdKey: test.fields.numCmdKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got, err := rm.Measurement(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_redisMetrics_MeasurementWithTags(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + pipelineTotal metrics.Int64Measure + pipelineLatency metrics.Float64Measure + cmdNameKey metrics.Key + numCmdKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want []metrics.MeasurementWithTags + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.MeasurementWithTags, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.MeasurementWithTags, err error) error { + 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 { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + rm := &redisMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + pipelineTotal: test.fields.pipelineTotal, + pipelineLatency: test.fields.pipelineLatency, + cmdNameKey: test.fields.cmdNameKey, + numCmdKey: test.fields.numCmdKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got, err := rm.MeasurementWithTags(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_redisMetrics_View(t *testing.T) { + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + pipelineTotal metrics.Int64Measure + pipelineLatency metrics.Float64Measure + cmdNameKey metrics.Key + numCmdKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want []*metrics.View + } + type test struct { + name string + fields fields + want want + checkFunc func(want, []*metrics.View) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got []*metrics.View) error { + if !reflect.DeepEqual(got, w.want) { + return 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 { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + rm := &redisMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + pipelineTotal: test.fields.pipelineTotal, + pipelineLatency: test.fields.pipelineLatency, + cmdNameKey: test.fields.cmdNameKey, + numCmdKey: test.fields.numCmdKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got := rm.View() + if err := test.checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_redisMetrics_BeforeProcess(t *testing.T) { + type args struct { + ctx context.Context + cmd redis.Cmder + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + pipelineTotal metrics.Int64Measure + pipelineLatency metrics.Float64Measure + cmdNameKey metrics.Key + numCmdKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want context.Context + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, context.Context, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got context.Context, err error) error { + 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, + cmd: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + cmd: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + rm := &redisMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + pipelineTotal: test.fields.pipelineTotal, + pipelineLatency: test.fields.pipelineLatency, + cmdNameKey: test.fields.cmdNameKey, + numCmdKey: test.fields.numCmdKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got, err := rm.BeforeProcess(test.args.ctx, test.args.cmd) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_redisMetrics_AfterProcess(t *testing.T) { + type args struct { + ctx context.Context + cmd redis.Cmder + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + pipelineTotal metrics.Int64Measure + pipelineLatency metrics.Float64Measure + cmdNameKey metrics.Key + numCmdKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + cmd: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + cmd: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + rm := &redisMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + pipelineTotal: test.fields.pipelineTotal, + pipelineLatency: test.fields.pipelineLatency, + cmdNameKey: test.fields.cmdNameKey, + numCmdKey: test.fields.numCmdKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + err := rm.AfterProcess(test.args.ctx, test.args.cmd) + if err := test.checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_redisMetrics_BeforeProcessPipeline(t *testing.T) { + type args struct { + ctx context.Context + cmds []redis.Cmder + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + pipelineTotal metrics.Int64Measure + pipelineLatency metrics.Float64Measure + cmdNameKey metrics.Key + numCmdKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want context.Context + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, context.Context, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got context.Context, err error) error { + 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, + cmds: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + cmds: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + rm := &redisMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + pipelineTotal: test.fields.pipelineTotal, + pipelineLatency: test.fields.pipelineLatency, + cmdNameKey: test.fields.cmdNameKey, + numCmdKey: test.fields.numCmdKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got, err := rm.BeforeProcessPipeline(test.args.ctx, test.args.cmds) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_redisMetrics_AfterProcessPipeline(t *testing.T) { + type args struct { + ctx context.Context + cmds []redis.Cmder + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + pipelineTotal metrics.Int64Measure + pipelineLatency metrics.Float64Measure + cmdNameKey metrics.Key + numCmdKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + cmds: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + cmds: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + pipelineTotal: nil, + pipelineLatency: nil, + cmdNameKey: nil, + numCmdKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + rm := &redisMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + pipelineTotal: test.fields.pipelineTotal, + pipelineLatency: test.fields.pipelineLatency, + cmdNameKey: test.fields.cmdNameKey, + numCmdKey: test.fields.numCmdKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + err := rm.AfterProcessPipeline(test.args.ctx, test.args.cmds) + if err := test.checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} diff --git a/internal/observability/metrics/db/nosql/cassandra/cassandra_test.go b/internal/observability/metrics/db/nosql/cassandra/cassandra_test.go new file mode 100644 index 0000000000..7ee0e507d4 --- /dev/null +++ b/internal/observability/metrics/db/nosql/cassandra/cassandra_test.go @@ -0,0 +1,603 @@ +// +// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Package cassandra provides cassandra metrics functions +package cassandra + +import ( + "context" + "reflect" + "sync" + "testing" + + "github.com/vdaas/vald/internal/db/nosql/cassandra" + "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/observability/metrics" + "go.uber.org/goleak" +) + +func TestNew(t *testing.T) { + type want struct { + wantO Observer + err error + } + type test struct { + name string + want want + checkFunc func(want, Observer, error) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, gotO Observer, err error) error { + 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", + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + gotO, err := New() + if err := test.checkFunc(test.want, gotO, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_cassandraMetrics_Measurement(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + queryTotal metrics.Int64Measure + queryAttemptsTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + keyspaceKey metrics.Key + clusterNameKey metrics.Key + dataCenterKey metrics.Key + hostIDKey metrics.Key + hostPortKey metrics.Key + rackKey metrics.Key + versionKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want []metrics.Measurement + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.Measurement, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.Measurement, err error) error { + 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 { + queryTotal: nil, + queryAttemptsTotal: nil, + queryLatency: nil, + keyspaceKey: nil, + clusterNameKey: nil, + dataCenterKey: nil, + hostIDKey: nil, + hostPortKey: nil, + rackKey: nil, + versionKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + queryTotal: nil, + queryAttemptsTotal: nil, + queryLatency: nil, + keyspaceKey: nil, + clusterNameKey: nil, + dataCenterKey: nil, + hostIDKey: nil, + hostPortKey: nil, + rackKey: nil, + versionKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + cm := &cassandraMetrics{ + queryTotal: test.fields.queryTotal, + queryAttemptsTotal: test.fields.queryAttemptsTotal, + queryLatency: test.fields.queryLatency, + keyspaceKey: test.fields.keyspaceKey, + clusterNameKey: test.fields.clusterNameKey, + dataCenterKey: test.fields.dataCenterKey, + hostIDKey: test.fields.hostIDKey, + hostPortKey: test.fields.hostPortKey, + rackKey: test.fields.rackKey, + versionKey: test.fields.versionKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got, err := cm.Measurement(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_cassandraMetrics_MeasurementWithTags(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + queryTotal metrics.Int64Measure + queryAttemptsTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + keyspaceKey metrics.Key + clusterNameKey metrics.Key + dataCenterKey metrics.Key + hostIDKey metrics.Key + hostPortKey metrics.Key + rackKey metrics.Key + versionKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want []metrics.MeasurementWithTags + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.MeasurementWithTags, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.MeasurementWithTags, err error) error { + 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 { + queryTotal: nil, + queryAttemptsTotal: nil, + queryLatency: nil, + keyspaceKey: nil, + clusterNameKey: nil, + dataCenterKey: nil, + hostIDKey: nil, + hostPortKey: nil, + rackKey: nil, + versionKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + queryTotal: nil, + queryAttemptsTotal: nil, + queryLatency: nil, + keyspaceKey: nil, + clusterNameKey: nil, + dataCenterKey: nil, + hostIDKey: nil, + hostPortKey: nil, + rackKey: nil, + versionKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + cm := &cassandraMetrics{ + queryTotal: test.fields.queryTotal, + queryAttemptsTotal: test.fields.queryAttemptsTotal, + queryLatency: test.fields.queryLatency, + keyspaceKey: test.fields.keyspaceKey, + clusterNameKey: test.fields.clusterNameKey, + dataCenterKey: test.fields.dataCenterKey, + hostIDKey: test.fields.hostIDKey, + hostPortKey: test.fields.hostPortKey, + rackKey: test.fields.rackKey, + versionKey: test.fields.versionKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got, err := cm.MeasurementWithTags(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_cassandraMetrics_View(t *testing.T) { + type fields struct { + queryTotal metrics.Int64Measure + queryAttemptsTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + keyspaceKey metrics.Key + clusterNameKey metrics.Key + dataCenterKey metrics.Key + hostIDKey metrics.Key + hostPortKey metrics.Key + rackKey metrics.Key + versionKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + want []*metrics.View + } + type test struct { + name string + fields fields + want want + checkFunc func(want, []*metrics.View) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got []*metrics.View) error { + if !reflect.DeepEqual(got, w.want) { + return 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 { + queryTotal: nil, + queryAttemptsTotal: nil, + queryLatency: nil, + keyspaceKey: nil, + clusterNameKey: nil, + dataCenterKey: nil, + hostIDKey: nil, + hostPortKey: nil, + rackKey: nil, + versionKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + queryTotal: nil, + queryAttemptsTotal: nil, + queryLatency: nil, + keyspaceKey: nil, + clusterNameKey: nil, + dataCenterKey: nil, + hostIDKey: nil, + hostPortKey: nil, + rackKey: nil, + versionKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + cm := &cassandraMetrics{ + queryTotal: test.fields.queryTotal, + queryAttemptsTotal: test.fields.queryAttemptsTotal, + queryLatency: test.fields.queryLatency, + keyspaceKey: test.fields.keyspaceKey, + clusterNameKey: test.fields.clusterNameKey, + dataCenterKey: test.fields.dataCenterKey, + hostIDKey: test.fields.hostIDKey, + hostPortKey: test.fields.hostPortKey, + rackKey: test.fields.rackKey, + versionKey: test.fields.versionKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + got := cm.View() + if err := test.checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_cassandraMetrics_ObserveQuery(t *testing.T) { + type args struct { + ctx context.Context + q cassandra.ObservedQuery + } + type fields struct { + queryTotal metrics.Int64Measure + queryAttemptsTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + keyspaceKey metrics.Key + clusterNameKey metrics.Key + dataCenterKey metrics.Key + hostIDKey metrics.Key + hostPortKey metrics.Key + rackKey metrics.Key + versionKey metrics.Key + mu sync.Mutex + ms []metrics.MeasurementWithTags + } + type want struct { + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want) error { + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + q: nil, + }, + fields: fields { + queryTotal: nil, + queryAttemptsTotal: nil, + queryLatency: nil, + keyspaceKey: nil, + clusterNameKey: nil, + dataCenterKey: nil, + hostIDKey: nil, + hostPortKey: nil, + rackKey: nil, + versionKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + q: nil, + }, + fields: fields { + queryTotal: nil, + queryAttemptsTotal: nil, + queryLatency: nil, + keyspaceKey: nil, + clusterNameKey: nil, + dataCenterKey: nil, + hostIDKey: nil, + hostPortKey: nil, + rackKey: nil, + versionKey: nil, + mu: sync.Mutex{}, + ms: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + cm := &cassandraMetrics{ + queryTotal: test.fields.queryTotal, + queryAttemptsTotal: test.fields.queryAttemptsTotal, + queryLatency: test.fields.queryLatency, + keyspaceKey: test.fields.keyspaceKey, + clusterNameKey: test.fields.clusterNameKey, + dataCenterKey: test.fields.dataCenterKey, + hostIDKey: test.fields.hostIDKey, + hostPortKey: test.fields.hostPortKey, + rackKey: test.fields.rackKey, + versionKey: test.fields.versionKey, + mu: test.fields.mu, + ms: test.fields.ms, + } + + cm.ObserveQuery(test.args.ctx, test.args.q) + if err := test.checkFunc(test.want); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} diff --git a/internal/observability/metrics/db/rdb/mysql/mysql_test.go b/internal/observability/metrics/db/rdb/mysql/mysql_test.go new file mode 100644 index 0000000000..95e287b918 --- /dev/null +++ b/internal/observability/metrics/db/rdb/mysql/mysql_test.go @@ -0,0 +1,692 @@ +// +// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Package mysql provides mysql metrics functions +package mysql + +import ( + "context" + "reflect" + "sync" + "testing" + + "github.com/vdaas/vald/internal/db/rdb/mysql" + "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/observability/metrics" + "go.uber.org/goleak" +) + +func TestNew(t *testing.T) { + type want struct { + wantE EventReceiver + err error + } + type test struct { + name string + want want + checkFunc func(want, EventReceiver, error) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, gotE EventReceiver, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(gotE, w.wantE) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotE, w.wantE) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + gotE, err := New() + if err := test.checkFunc(test.want, gotE, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_mysqlMetrics_Measurement(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + mu sync.Mutex + ms []metrics.Measurement + NullEventReceiver mysql.NullEventReceiver + } + type want struct { + want []metrics.Measurement + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.Measurement, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.Measurement, err error) error { + 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 { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + mm := &mysqlMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + mu: test.fields.mu, + ms: test.fields.ms, + NullEventReceiver: test.fields.NullEventReceiver, + } + + got, err := mm.Measurement(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_mysqlMetrics_MeasurementWithTags(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + mu sync.Mutex + ms []metrics.Measurement + NullEventReceiver mysql.NullEventReceiver + } + type want struct { + want []metrics.MeasurementWithTags + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.MeasurementWithTags, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.MeasurementWithTags, err error) error { + 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 { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + mm := &mysqlMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + mu: test.fields.mu, + ms: test.fields.ms, + NullEventReceiver: test.fields.NullEventReceiver, + } + + got, err := mm.MeasurementWithTags(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_mysqlMetrics_View(t *testing.T) { + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + mu sync.Mutex + ms []metrics.Measurement + NullEventReceiver mysql.NullEventReceiver + } + type want struct { + want []*metrics.View + } + type test struct { + name string + fields fields + want want + checkFunc func(want, []*metrics.View) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got []*metrics.View) error { + if !reflect.DeepEqual(got, w.want) { + return 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 { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + mm := &mysqlMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + mu: test.fields.mu, + ms: test.fields.ms, + NullEventReceiver: test.fields.NullEventReceiver, + } + + got := mm.View() + if err := test.checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_mysqlMetrics_SpanStart(t *testing.T) { + type args struct { + ctx context.Context + eventName string + query string + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + mu sync.Mutex + ms []metrics.Measurement + NullEventReceiver mysql.NullEventReceiver + } + 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(args) + afterFunc func(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, + eventName: "", + query: "", + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + eventName: "", + query: "", + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + mm := &mysqlMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + mu: test.fields.mu, + ms: test.fields.ms, + NullEventReceiver: test.fields.NullEventReceiver, + } + + got := mm.SpanStart(test.args.ctx, test.args.eventName, test.args.query) + if err := test.checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_mysqlMetrics_SpanError(t *testing.T) { + type args struct { + ctx context.Context + err error + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + mu sync.Mutex + ms []metrics.Measurement + NullEventReceiver mysql.NullEventReceiver + } + type want struct { + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want) error { + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + err: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + err: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + mm := &mysqlMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + mu: test.fields.mu, + ms: test.fields.ms, + NullEventReceiver: test.fields.NullEventReceiver, + } + + mm.SpanError(test.args.ctx, test.args.err) + if err := test.checkFunc(test.want); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func Test_mysqlMetrics_SpanFinish(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + queryTotal metrics.Int64Measure + queryLatency metrics.Float64Measure + mu sync.Mutex + ms []metrics.Measurement + NullEventReceiver mysql.NullEventReceiver + } + type want struct { + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want) error { + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + queryTotal: nil, + queryLatency: nil, + mu: sync.Mutex{}, + ms: nil, + NullEventReceiver: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + mm := &mysqlMetrics{ + queryTotal: test.fields.queryTotal, + queryLatency: test.fields.queryLatency, + mu: test.fields.mu, + ms: test.fields.ms, + NullEventReceiver: test.fields.NullEventReceiver, + } + + mm.SpanFinish(test.args.ctx) + if err := test.checkFunc(test.want); 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 new file mode 100644 index 0000000000..9d1629af16 --- /dev/null +++ b/internal/observability/metrics/manager/index/index_test.go @@ -0,0 +1,386 @@ +// +// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Package index provides functions for indexer stats +package index + +import ( + "context" + "reflect" + "testing" + + "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/observability/metrics" + "github.com/vdaas/vald/pkg/manager/index/service" + "go.uber.org/goleak" +) + +func TestNew(t *testing.T) { + type args struct { + i service.Indexer + } + type want struct { + want metrics.Metric + } + type test struct { + name string + args args + want want + checkFunc func(want, metrics.Metric) error + beforeFunc func(args) + afterFunc func(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 { + i: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + i: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + got := New(test.args.i) + if err := test.checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_indexerMetrics_Measurement(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + indexer service.Indexer + uuidCount metrics.Int64Measure + uncommittedUUIDCount metrics.Int64Measure + isIndexing metrics.Int64Measure + } + type want struct { + want []metrics.Measurement + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.Measurement, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.Measurement, err error) error { + 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 { + indexer: nil, + uuidCount: nil, + uncommittedUUIDCount: nil, + isIndexing: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + indexer: nil, + uuidCount: nil, + uncommittedUUIDCount: nil, + isIndexing: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + i := &indexerMetrics{ + indexer: test.fields.indexer, + uuidCount: test.fields.uuidCount, + uncommittedUUIDCount: test.fields.uncommittedUUIDCount, + isIndexing: test.fields.isIndexing, + } + + got, err := i.Measurement(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_indexerMetrics_MeasurementWithTags(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + indexer service.Indexer + uuidCount metrics.Int64Measure + uncommittedUUIDCount metrics.Int64Measure + isIndexing metrics.Int64Measure + } + type want struct { + want []metrics.MeasurementWithTags + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []metrics.MeasurementWithTags, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got []metrics.MeasurementWithTags, err error) error { + 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 { + indexer: nil, + uuidCount: nil, + uncommittedUUIDCount: nil, + isIndexing: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + indexer: nil, + uuidCount: nil, + uncommittedUUIDCount: nil, + isIndexing: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + i := &indexerMetrics{ + indexer: test.fields.indexer, + uuidCount: test.fields.uuidCount, + uncommittedUUIDCount: test.fields.uncommittedUUIDCount, + isIndexing: test.fields.isIndexing, + } + + got, err := i.MeasurementWithTags(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_indexerMetrics_View(t *testing.T) { + type fields struct { + indexer service.Indexer + uuidCount metrics.Int64Measure + uncommittedUUIDCount metrics.Int64Measure + isIndexing metrics.Int64Measure + } + type want struct { + want []*metrics.View + } + type test struct { + name string + fields fields + want want + checkFunc func(want, []*metrics.View) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got []*metrics.View) error { + if !reflect.DeepEqual(got, w.want) { + return 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 { + indexer: nil, + uuidCount: nil, + uncommittedUUIDCount: nil, + isIndexing: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + indexer: nil, + uuidCount: nil, + uncommittedUUIDCount: nil, + isIndexing: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + i := &indexerMetrics{ + indexer: test.fields.indexer, + uuidCount: test.fields.uuidCount, + uncommittedUUIDCount: test.fields.uncommittedUUIDCount, + isIndexing: test.fields.isIndexing, + } + + got := i.View() + if err := test.checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} diff --git a/pkg/agent/core/ngt/config/config_test.go b/pkg/agent/core/ngt/config/config_test.go index eba18af56a..4b07b57620 100644 --- a/pkg/agent/core/ngt/config/config_test.go +++ b/pkg/agent/core/ngt/config/config_test.go @@ -80,7 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/handler/grpc/handler_test.go b/pkg/agent/core/ngt/handler/grpc/handler_test.go index ac83606c79..05f77f00a2 100644 --- a/pkg/agent/core/ngt/handler/grpc/handler_test.go +++ b/pkg/agent/core/ngt/handler/grpc/handler_test.go @@ -27,7 +27,6 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/agent/core/ngt/model" "github.com/vdaas/vald/pkg/agent/core/ngt/service" - "go.uber.org/goleak" ) @@ -82,7 +81,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -173,7 +172,7 @@ func Test_server_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -268,7 +267,7 @@ func Test_server_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -363,7 +362,7 @@ func Test_server_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -445,7 +444,7 @@ func Test_toSearchResponse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -529,7 +528,7 @@ func Test_server_StreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -617,7 +616,7 @@ func Test_server_StreamSearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -712,7 +711,7 @@ func Test_server_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -800,7 +799,7 @@ func Test_server_StreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -895,7 +894,7 @@ func Test_server_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -990,7 +989,7 @@ func Test_server_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1078,7 +1077,7 @@ func Test_server_StreamUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1173,7 +1172,7 @@ func Test_server_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1268,7 +1267,7 @@ func Test_server_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1356,7 +1355,7 @@ func Test_server_StreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1451,7 +1450,7 @@ func Test_server_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1546,7 +1545,7 @@ func Test_server_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1634,7 +1633,7 @@ func Test_server_StreamGetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1729,7 +1728,7 @@ func Test_server_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1824,7 +1823,7 @@ func Test_server_SaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1919,7 +1918,7 @@ func Test_server_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2014,7 +2013,7 @@ func Test_server_IndexInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/handler/grpc/option_test.go b/pkg/agent/core/ngt/handler/grpc/option_test.go index aae1ff1eef..dbdb548d34 100644 --- a/pkg/agent/core/ngt/handler/grpc/option_test.go +++ b/pkg/agent/core/ngt/handler/grpc/option_test.go @@ -21,11 +21,11 @@ import ( "testing" "github.com/vdaas/vald/pkg/agent/core/ngt/service" - "go.uber.org/goleak" ) func TestWithNGT(t *testing.T) { + // Change interface type to the type of object you are testing type T = interface{} type args struct { n service.NGT @@ -63,7 +63,7 @@ func TestWithNGT(t *testing.T) { /* defaultCheckFunc := func(w want, obj *T) error { if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.c) + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) } return nil } @@ -101,7 +101,7 @@ func TestWithNGT(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -122,7 +122,7 @@ func TestWithNGT(t *testing.T) { } */ - // Uncomment this block if the option returns an error, otherwise delete it + // Uncomment this block if the option do not return an error, otherwise delete it /* if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -130,7 +130,7 @@ func TestWithNGT(t *testing.T) { got := WithNGT(test.args.n) obj := new(T) got(obj) - if err := test.checkFunc(tt.want, obj); err != nil { + if err := test.checkFunc(test.want, obj); err != nil { tt.Errorf("error = %v", err) } */ @@ -139,6 +139,7 @@ func TestWithNGT(t *testing.T) { } func TestWithStreamConcurrency(t *testing.T) { + // Change interface type to the type of object you are testing type T = interface{} type args struct { c int @@ -176,7 +177,7 @@ func TestWithStreamConcurrency(t *testing.T) { /* defaultCheckFunc := func(w want, obj *T) error { if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.c) + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) } return nil } @@ -214,7 +215,7 @@ func TestWithStreamConcurrency(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -235,7 +236,7 @@ func TestWithStreamConcurrency(t *testing.T) { } */ - // Uncomment this block if the option returns an error, otherwise delete it + // Uncomment this block if the option do not return an error, otherwise delete it /* if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -243,7 +244,7 @@ func TestWithStreamConcurrency(t *testing.T) { got := WithStreamConcurrency(test.args.c) obj := new(T) got(obj) - if err := test.checkFunc(tt.want, obj); err != nil { + if err := test.checkFunc(test.want, obj); 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 index 38faa8d487..9659e184e3 100644 --- a/pkg/agent/core/ngt/handler/rest/handler_test.go +++ b/pkg/agent/core/ngt/handler/rest/handler_test.go @@ -24,7 +24,6 @@ import ( agent "github.com/vdaas/vald/apis/grpc/agent/core" "github.com/vdaas/vald/internal/errors" - "go.uber.org/goleak" ) @@ -79,7 +78,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -167,7 +166,7 @@ func Test_handler_Index(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -258,7 +257,7 @@ func Test_handler_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -349,7 +348,7 @@ func Test_handler_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -440,7 +439,7 @@ func Test_handler_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -531,7 +530,7 @@ func Test_handler_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -622,7 +621,7 @@ func Test_handler_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -713,7 +712,7 @@ func Test_handler_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -804,7 +803,7 @@ func Test_handler_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -895,7 +894,7 @@ func Test_handler_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -986,7 +985,7 @@ func Test_handler_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1077,7 +1076,7 @@ func Test_handler_SaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1168,7 +1167,7 @@ func Test_handler_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1259,7 +1258,7 @@ func Test_handler_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1350,7 +1349,7 @@ func Test_handler_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/handler/rest/option_test.go b/pkg/agent/core/ngt/handler/rest/option_test.go index de334329a1..93e0f39712 100644 --- a/pkg/agent/core/ngt/handler/rest/option_test.go +++ b/pkg/agent/core/ngt/handler/rest/option_test.go @@ -21,11 +21,11 @@ import ( "testing" agent "github.com/vdaas/vald/apis/grpc/agent/core" - "go.uber.org/goleak" ) func TestWithAgent(t *testing.T) { + // Change interface type to the type of object you are testing type T = interface{} type args struct { a agent.AgentServer @@ -63,7 +63,7 @@ func TestWithAgent(t *testing.T) { /* defaultCheckFunc := func(w want, obj *T) error { if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.c) + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) } return nil } @@ -101,7 +101,7 @@ func TestWithAgent(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -122,7 +122,7 @@ func TestWithAgent(t *testing.T) { } */ - // Uncomment this block if the option returns an error, otherwise delete it + // Uncomment this block if the option do not return an error, otherwise delete it /* if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -130,7 +130,7 @@ func TestWithAgent(t *testing.T) { got := WithAgent(test.args.a) obj := new(T) got(obj) - if err := test.checkFunc(tt.want, obj); err != nil { + if err := test.checkFunc(test.want, obj); err != nil { tt.Errorf("error = %v", err) } */ diff --git a/pkg/agent/core/ngt/router/option_test.go b/pkg/agent/core/ngt/router/option_test.go index b9b45f99a7..6ec1ab28de 100644 --- a/pkg/agent/core/ngt/router/option_test.go +++ b/pkg/agent/core/ngt/router/option_test.go @@ -22,11 +22,11 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/agent/core/ngt/handler/rest" - "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { + // Change interface type to the type of object you are testing type T = interface{} type args struct { h rest.Handler @@ -64,7 +64,7 @@ func TestWithHandler(t *testing.T) { /* defaultCheckFunc := func(w want, obj *T) error { if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.c) + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) } return nil } @@ -102,7 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -123,7 +123,7 @@ func TestWithHandler(t *testing.T) { } */ - // Uncomment this block if the option returns an error, otherwise delete it + // Uncomment this block if the option do not return an error, otherwise delete it /* if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -131,7 +131,7 @@ func TestWithHandler(t *testing.T) { got := WithHandler(test.args.h) obj := new(T) got(obj) - if err := test.checkFunc(tt.want, obj); err != nil { + if err := test.checkFunc(test.want, obj); err != nil { tt.Errorf("error = %v", err) } */ @@ -140,6 +140,7 @@ func TestWithHandler(t *testing.T) { } func TestWithTimeout(t *testing.T) { + // Change interface type to the type of object you are testing type T = interface{} type args struct { timeout string @@ -177,7 +178,7 @@ func TestWithTimeout(t *testing.T) { /* defaultCheckFunc := func(w want, obj *T) error { if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.c) + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) } return nil } @@ -215,7 +216,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -236,7 +237,7 @@ func TestWithTimeout(t *testing.T) { } */ - // Uncomment this block if the option returns an error, otherwise delete it + // Uncomment this block if the option do not return an error, otherwise delete it /* if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -244,7 +245,7 @@ func TestWithTimeout(t *testing.T) { got := WithTimeout(test.args.timeout) obj := new(T) got(obj) - if err := test.checkFunc(tt.want, obj); err != nil { + if err := test.checkFunc(test.want, obj); err != nil { tt.Errorf("error = %v", err) } */ @@ -253,6 +254,7 @@ func TestWithTimeout(t *testing.T) { } func TestWithErrGroup(t *testing.T) { + // Change interface type to the type of object you are testing type T = interface{} type args struct { eg errgroup.Group @@ -290,7 +292,7 @@ func TestWithErrGroup(t *testing.T) { /* defaultCheckFunc := func(w want, obj *T) error { if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.c) + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) } return nil } @@ -328,7 +330,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -349,7 +351,7 @@ func TestWithErrGroup(t *testing.T) { } */ - // Uncomment this block if the option returns an error, otherwise delete it + // Uncomment this block if the option do not return an error, otherwise delete it /* if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -357,7 +359,7 @@ func TestWithErrGroup(t *testing.T) { got := WithErrGroup(test.args.eg) obj := new(T) got(obj) - if err := test.checkFunc(tt.want, obj); err != nil { + if err := test.checkFunc(test.want, obj); err != nil { tt.Errorf("error = %v", err) } */ diff --git a/pkg/agent/core/ngt/router/router_test.go b/pkg/agent/core/ngt/router/router_test.go index 25eaec0bef..e02106ae0e 100644 --- a/pkg/agent/core/ngt/router/router_test.go +++ b/pkg/agent/core/ngt/router/router_test.go @@ -23,6 +23,7 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -76,6 +77,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/service/kvs/kvs_test.go b/pkg/agent/core/ngt/service/kvs/kvs_test.go index de68009bda..8c5262baad 100644 --- a/pkg/agent/core/ngt/service/kvs/kvs_test.go +++ b/pkg/agent/core/ngt/service/kvs/kvs_test.go @@ -22,6 +22,7 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -65,6 +66,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -155,6 +157,7 @@ func Test_bidi_Get(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -250,6 +253,7 @@ func Test_bidi_GetInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -340,6 +344,7 @@ func Test_bidi_Set(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +439,7 @@ func Test_bidi_Delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -529,6 +535,7 @@ func Test_bidi_DeleteInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -619,6 +626,7 @@ func Test_bidi_Range(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -699,6 +707,7 @@ func Test_bidi_Len(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/pkg/agent/core/ngt/service/kvs/ou_test.go b/pkg/agent/core/ngt/service/kvs/ou_test.go index ebd55d7a89..62413f54b6 100644 --- a/pkg/agent/core/ngt/service/kvs/ou_test.go +++ b/pkg/agent/core/ngt/service/kvs/ou_test.go @@ -24,6 +24,7 @@ import ( "unsafe" "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func Test_newEntryOu(t *testing.T) { @@ -77,6 +78,7 @@ func Test_newEntryOu(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -170,6 +172,7 @@ func Test_ou_Load(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -250,6 +253,7 @@ func Test_entryOu_load(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -341,6 +345,7 @@ func Test_ou_Store(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -426,6 +431,7 @@ func Test_entryOu_tryStore(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -499,6 +505,7 @@ func Test_entryOu_unexpungeLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -578,6 +585,7 @@ func Test_entryOu_storeLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -665,6 +673,7 @@ func Test_ou_Delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -740,6 +749,7 @@ func Test_entryOu_delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -818,6 +828,7 @@ func Test_ou_missLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -898,6 +909,7 @@ func Test_ou_dirtyLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -973,6 +985,7 @@ func Test_entryOu_tryExpungeLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/pkg/agent/core/ngt/service/kvs/uo_test.go b/pkg/agent/core/ngt/service/kvs/uo_test.go index 27f705db30..c0528020c2 100644 --- a/pkg/agent/core/ngt/service/kvs/uo_test.go +++ b/pkg/agent/core/ngt/service/kvs/uo_test.go @@ -24,6 +24,7 @@ import ( "unsafe" "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func Test_newEntryUo(t *testing.T) { @@ -77,6 +78,7 @@ func Test_newEntryUo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -170,6 +172,7 @@ func Test_uo_Load(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -250,6 +253,7 @@ func Test_entryUo_load(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -341,6 +345,7 @@ func Test_uo_Store(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -426,6 +431,7 @@ func Test_entryUo_tryStore(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -499,6 +505,7 @@ func Test_entryUo_unexpungeLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -578,6 +585,7 @@ func Test_entryUo_storeLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -665,6 +673,7 @@ func Test_uo_Delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -740,6 +749,7 @@ func Test_entryUo_delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -828,6 +838,7 @@ func Test_uo_Range(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -908,6 +919,7 @@ func Test_uo_missLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -988,6 +1000,7 @@ func Test_uo_dirtyLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -1063,6 +1076,7 @@ func Test_entryUo_tryExpungeLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/pkg/agent/core/ngt/service/ngt.go b/pkg/agent/core/ngt/service/ngt.go index 874c402e44..9850fcc1c5 100644 --- a/pkg/agent/core/ngt/service/ngt.go +++ b/pkg/agent/core/ngt/service/ngt.go @@ -58,8 +58,10 @@ type NGT interface { Exists(string) (uint32, bool) CreateAndSaveIndex(ctx context.Context, poolSize uint32) (err error) IsIndexing() bool + IsSaving() bool Len() uint64 NumberOfCreateIndexExecution() uint64 + NumberOfProactiveGCExecution() uint64 UUIDs(context.Context) (uuids []string) UncommittedUUIDs() (uuids []string) DeleteVCacheLen() uint64 @@ -83,6 +85,7 @@ type ngt struct { // counters ic uint64 // insert count nocie uint64 // number of create index execution + nogce uint64 // number of proactive GC execution // configurations inMem bool // in-memory mode @@ -97,6 +100,8 @@ type ngt struct { maxLit time.Duration // maximum load index timeout litFactor time.Duration // load index timeout factor + enableProactiveGC bool // if this value is true, agent component will purge GC memory more proactive + path string // index path poolSize uint32 // default pool size @@ -537,10 +542,10 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) { } n.indexing.Store(true) atomic.StoreUint64(&n.ic, 0) - runtime.GC() + n.gc() t := time.Now().UnixNano() defer n.indexing.Store(false) - defer runtime.GC() + defer n.gc() log.Infof("create index operation started, uncommitted indexes = %d", ic) delList := make([]string, 0, ic) @@ -650,7 +655,7 @@ func (n *ngt) saveIndex(ctx context.Context) (err error) { for n.IsIndexing() || n.IsSaving() { } n.saving.Store(true) - defer runtime.GC() + defer n.gc() defer n.saving.Store(false) eg, ctx := errgroup.New(ctx) @@ -774,6 +779,17 @@ func (n *ngt) NumberOfCreateIndexExecution() uint64 { return atomic.LoadUint64(&n.nocie) } +func (n *ngt) NumberOfProactiveGCExecution() uint64 { + return atomic.LoadUint64(&n.nogce) +} + +func (n *ngt) gc() { + if n.enableProactiveGC { + runtime.GC() + atomic.AddUint64(&n.nogce, 1) + } +} + func (n *ngt) Len() uint64 { return n.kvs.Len() } diff --git a/pkg/agent/core/ngt/service/ngt_test.go b/pkg/agent/core/ngt/service/ngt_test.go index 45880e7ca7..6a74d8e418 100644 --- a/pkg/agent/core/ngt/service/ngt_test.go +++ b/pkg/agent/core/ngt/service/ngt_test.go @@ -116,30 +116,32 @@ func Test_ngt_initNGT(t *testing.T) { opts []core.Option } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -178,6 +180,7 @@ func Test_ngt_initNGT(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -186,6 +189,7 @@ func Test_ngt_initNGT(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -217,6 +221,7 @@ func Test_ngt_initNGT(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -225,6 +230,7 @@ func Test_ngt_initNGT(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -252,30 +258,32 @@ func Test_ngt_initNGT(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.initNGT(test.args.opts...) @@ -289,30 +297,32 @@ func Test_ngt_initNGT(t *testing.T) { func Test_ngt_loadKVS(t *testing.T) { type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -347,6 +357,7 @@ func Test_ngt_loadKVS(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -355,6 +366,7 @@ func Test_ngt_loadKVS(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -383,6 +395,7 @@ func Test_ngt_loadKVS(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -391,6 +404,7 @@ func Test_ngt_loadKVS(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -418,30 +432,32 @@ func Test_ngt_loadKVS(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.loadKVS() @@ -458,30 +474,32 @@ func Test_ngt_Start(t *testing.T) { ctx context.Context } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { want <-chan error @@ -520,6 +538,7 @@ func Test_ngt_Start(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -528,6 +547,7 @@ func Test_ngt_Start(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -559,6 +579,7 @@ func Test_ngt_Start(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -567,6 +588,7 @@ func Test_ngt_Start(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -594,30 +616,32 @@ func Test_ngt_Start(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } got := n.Start(test.args.ctx) @@ -637,30 +661,32 @@ func Test_ngt_Search(t *testing.T) { radius float32 } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { want []model.Distance @@ -706,6 +732,7 @@ func Test_ngt_Search(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -714,6 +741,7 @@ func Test_ngt_Search(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -748,6 +776,7 @@ func Test_ngt_Search(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -756,6 +785,7 @@ func Test_ngt_Search(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -783,30 +813,32 @@ func Test_ngt_Search(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } got, err := n.Search(test.args.vec, test.args.size, test.args.epsilon, test.args.radius) @@ -826,30 +858,32 @@ func Test_ngt_SearchByID(t *testing.T) { radius float32 } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { wantDst []model.Distance @@ -895,6 +929,7 @@ func Test_ngt_SearchByID(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -903,6 +938,7 @@ func Test_ngt_SearchByID(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -937,6 +973,7 @@ func Test_ngt_SearchByID(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -945,6 +982,7 @@ func Test_ngt_SearchByID(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -972,30 +1010,32 @@ func Test_ngt_SearchByID(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } gotDst, err := n.SearchByID(test.args.uuid, test.args.size, test.args.epsilon, test.args.radius) @@ -1013,30 +1053,32 @@ func Test_ngt_Insert(t *testing.T) { vec []float32 } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -1076,6 +1118,7 @@ func Test_ngt_Insert(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1084,6 +1127,7 @@ func Test_ngt_Insert(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1116,6 +1160,7 @@ func Test_ngt_Insert(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1124,6 +1169,7 @@ func Test_ngt_Insert(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1151,30 +1197,32 @@ func Test_ngt_Insert(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.Insert(test.args.uuid, test.args.vec) @@ -1194,30 +1242,32 @@ func Test_ngt_insert(t *testing.T) { validation bool } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -1259,6 +1309,7 @@ func Test_ngt_insert(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1267,6 +1318,7 @@ func Test_ngt_insert(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1301,6 +1353,7 @@ func Test_ngt_insert(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1309,6 +1362,7 @@ func Test_ngt_insert(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1336,30 +1390,32 @@ func Test_ngt_insert(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.insert(test.args.uuid, test.args.vec, test.args.t, test.args.validation) @@ -1376,30 +1432,32 @@ func Test_ngt_InsertMultiple(t *testing.T) { vecs map[string][]float32 } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -1438,6 +1496,7 @@ func Test_ngt_InsertMultiple(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1446,6 +1505,7 @@ func Test_ngt_InsertMultiple(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1477,6 +1537,7 @@ func Test_ngt_InsertMultiple(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1485,6 +1546,7 @@ func Test_ngt_InsertMultiple(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1512,30 +1574,32 @@ func Test_ngt_InsertMultiple(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.InsertMultiple(test.args.vecs) @@ -1553,30 +1617,32 @@ func Test_ngt_Update(t *testing.T) { vec []float32 } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -1616,6 +1682,7 @@ func Test_ngt_Update(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1624,6 +1691,7 @@ func Test_ngt_Update(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1656,6 +1724,7 @@ func Test_ngt_Update(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1664,6 +1733,7 @@ func Test_ngt_Update(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1691,30 +1761,32 @@ func Test_ngt_Update(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.Update(test.args.uuid, test.args.vec) @@ -1731,30 +1803,32 @@ func Test_ngt_UpdateMultiple(t *testing.T) { vecs map[string][]float32 } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -1793,6 +1867,7 @@ func Test_ngt_UpdateMultiple(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1801,6 +1876,7 @@ func Test_ngt_UpdateMultiple(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1832,6 +1908,7 @@ func Test_ngt_UpdateMultiple(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1840,6 +1917,7 @@ func Test_ngt_UpdateMultiple(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -1867,30 +1945,32 @@ func Test_ngt_UpdateMultiple(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.UpdateMultiple(test.args.vecs) @@ -1907,30 +1987,32 @@ func Test_ngt_Delete(t *testing.T) { uuid string } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -1969,6 +2051,7 @@ func Test_ngt_Delete(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -1977,6 +2060,7 @@ func Test_ngt_Delete(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2008,6 +2092,7 @@ func Test_ngt_Delete(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2016,6 +2101,7 @@ func Test_ngt_Delete(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2043,30 +2129,32 @@ func Test_ngt_Delete(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.Delete(test.args.uuid) @@ -2084,30 +2172,32 @@ func Test_ngt_delete(t *testing.T) { t int64 } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -2147,6 +2237,7 @@ func Test_ngt_delete(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2155,6 +2246,7 @@ func Test_ngt_delete(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2187,6 +2279,7 @@ func Test_ngt_delete(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2195,6 +2288,7 @@ func Test_ngt_delete(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2222,30 +2316,32 @@ func Test_ngt_delete(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.delete(test.args.uuid, test.args.t) @@ -2262,30 +2358,32 @@ func Test_ngt_DeleteMultiple(t *testing.T) { uuids []string } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -2324,6 +2422,7 @@ func Test_ngt_DeleteMultiple(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2332,6 +2431,7 @@ func Test_ngt_DeleteMultiple(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2363,6 +2463,7 @@ func Test_ngt_DeleteMultiple(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2371,6 +2472,7 @@ func Test_ngt_DeleteMultiple(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2398,30 +2500,32 @@ func Test_ngt_DeleteMultiple(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.DeleteMultiple(test.args.uuids...) @@ -2438,30 +2542,32 @@ func Test_ngt_GetObject(t *testing.T) { uuid string } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { wantVec []float32 @@ -2504,6 +2610,7 @@ func Test_ngt_GetObject(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2512,6 +2619,7 @@ func Test_ngt_GetObject(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2543,6 +2651,7 @@ func Test_ngt_GetObject(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2551,6 +2660,7 @@ func Test_ngt_GetObject(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2578,30 +2688,32 @@ func Test_ngt_GetObject(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } gotVec, err := n.GetObject(test.args.uuid) @@ -2619,30 +2731,32 @@ func Test_ngt_CreateIndex(t *testing.T) { poolSize uint32 } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -2682,6 +2796,7 @@ func Test_ngt_CreateIndex(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2690,6 +2805,7 @@ func Test_ngt_CreateIndex(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2722,6 +2838,7 @@ func Test_ngt_CreateIndex(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2730,6 +2847,7 @@ func Test_ngt_CreateIndex(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2757,30 +2875,32 @@ func Test_ngt_CreateIndex(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.CreateIndex(test.args.ctx, test.args.poolSize) @@ -2797,30 +2917,32 @@ func Test_ngt_SaveIndex(t *testing.T) { ctx context.Context } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -2859,6 +2981,7 @@ func Test_ngt_SaveIndex(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2867,6 +2990,7 @@ func Test_ngt_SaveIndex(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2898,6 +3022,7 @@ func Test_ngt_SaveIndex(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -2906,6 +3031,7 @@ func Test_ngt_SaveIndex(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -2933,30 +3059,32 @@ func Test_ngt_SaveIndex(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.SaveIndex(test.args.ctx) @@ -2973,30 +3101,32 @@ func Test_ngt_saveIndex(t *testing.T) { ctx context.Context } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -3035,6 +3165,7 @@ func Test_ngt_saveIndex(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3043,6 +3174,7 @@ func Test_ngt_saveIndex(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3074,6 +3206,7 @@ func Test_ngt_saveIndex(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3082,6 +3215,7 @@ func Test_ngt_saveIndex(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3109,30 +3243,32 @@ func Test_ngt_saveIndex(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.saveIndex(test.args.ctx) @@ -3150,30 +3286,32 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { poolSize uint32 } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -3213,6 +3351,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3221,6 +3360,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3253,6 +3393,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3261,6 +3402,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3288,30 +3430,32 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.CreateAndSaveIndex(test.args.ctx, test.args.poolSize) @@ -3328,30 +3472,32 @@ func Test_ngt_Exists(t *testing.T) { uuid string } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { wantOid uint32 @@ -3394,6 +3540,7 @@ func Test_ngt_Exists(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3402,6 +3549,7 @@ func Test_ngt_Exists(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3433,6 +3581,7 @@ func Test_ngt_Exists(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3441,6 +3590,7 @@ func Test_ngt_Exists(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3468,30 +3618,32 @@ func Test_ngt_Exists(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } gotOid, gotOk := n.Exists(test.args.uuid) @@ -3508,30 +3660,32 @@ func Test_ngt_insertCache(t *testing.T) { uuid string } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { want *vcache @@ -3574,6 +3728,7 @@ func Test_ngt_insertCache(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3582,6 +3737,7 @@ func Test_ngt_insertCache(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3613,6 +3769,7 @@ func Test_ngt_insertCache(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3621,6 +3778,7 @@ func Test_ngt_insertCache(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3648,30 +3806,32 @@ func Test_ngt_insertCache(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } got, got1 := n.insertCache(test.args.uuid) @@ -3685,30 +3845,32 @@ func Test_ngt_insertCache(t *testing.T) { func Test_ngt_IsSaving(t *testing.T) { type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { want bool @@ -3743,6 +3905,7 @@ func Test_ngt_IsSaving(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3751,6 +3914,7 @@ func Test_ngt_IsSaving(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3779,6 +3943,7 @@ func Test_ngt_IsSaving(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3787,6 +3952,7 @@ func Test_ngt_IsSaving(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3814,30 +3980,32 @@ func Test_ngt_IsSaving(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } got := n.IsSaving() @@ -3851,30 +4019,32 @@ func Test_ngt_IsSaving(t *testing.T) { func Test_ngt_IsIndexing(t *testing.T) { type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { want bool @@ -3909,6 +4079,7 @@ func Test_ngt_IsIndexing(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3917,6 +4088,7 @@ func Test_ngt_IsIndexing(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3945,6 +4117,7 @@ func Test_ngt_IsIndexing(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -3953,6 +4126,7 @@ func Test_ngt_IsIndexing(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -3980,30 +4154,32 @@ func Test_ngt_IsIndexing(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } got := n.IsIndexing() @@ -4020,30 +4196,32 @@ func Test_ngt_UUIDs(t *testing.T) { ctx context.Context } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { wantUuids []string @@ -4082,6 +4260,7 @@ func Test_ngt_UUIDs(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4090,6 +4269,7 @@ func Test_ngt_UUIDs(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4121,6 +4301,7 @@ func Test_ngt_UUIDs(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4129,6 +4310,7 @@ func Test_ngt_UUIDs(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4156,30 +4338,32 @@ func Test_ngt_UUIDs(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } gotUuids := n.UUIDs(test.args.ctx) @@ -4193,30 +4377,32 @@ func Test_ngt_UUIDs(t *testing.T) { func Test_ngt_UncommittedUUIDs(t *testing.T) { type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { wantUuids []string @@ -4251,6 +4437,7 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4259,6 +4446,7 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4287,6 +4475,7 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4295,6 +4484,7 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4322,30 +4512,32 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } gotUuids := n.UncommittedUUIDs() @@ -4359,30 +4551,32 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { want uint64 @@ -4417,6 +4611,7 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4425,6 +4620,7 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4453,6 +4649,7 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4461,6 +4658,7 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4488,30 +4686,32 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } got := n.NumberOfCreateIndexExecution() @@ -4523,32 +4723,377 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { } } +func Test_ngt_NumberOfProactiveGCExecution(t *testing.T) { + type fields struct { + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool + } + type want struct { + want uint64 + } + type test struct { + name string + fields fields + want want + checkFunc func(want, uint64) error + beforeFunc func() + afterFunc func() + } + 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, + ivc: vcaches{}, + dvc: vcaches{}, + indexing: nil, + saving: nil, + lastNoice: 0, + ic: 0, + nocie: 0, + nogce: 0, + inMem: false, + alen: 0, + lim: nil, + dur: nil, + sdur: nil, + minLit: nil, + maxLit: nil, + litFactor: nil, + enableProactiveGC: false, + path: "", + poolSize: 0, + radius: 0, + epsilon: 0, + idelay: nil, + dcd: false, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + core: nil, + eg: nil, + kvs: nil, + ivc: vcaches{}, + dvc: vcaches{}, + indexing: nil, + saving: nil, + lastNoice: 0, + ic: 0, + nocie: 0, + nogce: 0, + inMem: false, + alen: 0, + lim: nil, + dur: nil, + sdur: nil, + minLit: nil, + maxLit: nil, + litFactor: nil, + enableProactiveGC: false, + path: "", + poolSize: 0, + radius: 0, + epsilon: 0, + idelay: nil, + dcd: false, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + n := &ngt{ + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, + } + + got := n.NumberOfProactiveGCExecution() + if err := test.checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_ngt_gc(t *testing.T) { + type fields struct { + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool + } + type want struct { + } + type test struct { + name string + fields fields + want want + checkFunc func(want) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want) error { + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + core: nil, + eg: nil, + kvs: nil, + ivc: vcaches{}, + dvc: vcaches{}, + indexing: nil, + saving: nil, + lastNoice: 0, + ic: 0, + nocie: 0, + nogce: 0, + inMem: false, + alen: 0, + lim: nil, + dur: nil, + sdur: nil, + minLit: nil, + maxLit: nil, + litFactor: nil, + enableProactiveGC: false, + path: "", + poolSize: 0, + radius: 0, + epsilon: 0, + idelay: nil, + dcd: false, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + core: nil, + eg: nil, + kvs: nil, + ivc: vcaches{}, + dvc: vcaches{}, + indexing: nil, + saving: nil, + lastNoice: 0, + ic: 0, + nocie: 0, + nogce: 0, + inMem: false, + alen: 0, + lim: nil, + dur: nil, + sdur: nil, + minLit: nil, + maxLit: nil, + litFactor: nil, + enableProactiveGC: false, + path: "", + poolSize: 0, + radius: 0, + epsilon: 0, + idelay: nil, + dcd: false, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + n := &ngt{ + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, + } + + n.gc() + if err := test.checkFunc(test.want); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + func Test_ngt_Len(t *testing.T) { type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { want uint64 @@ -4583,6 +5128,7 @@ func Test_ngt_Len(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4591,6 +5137,7 @@ func Test_ngt_Len(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4619,6 +5166,7 @@ func Test_ngt_Len(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4627,6 +5175,7 @@ func Test_ngt_Len(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4654,30 +5203,32 @@ func Test_ngt_Len(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } got := n.Len() @@ -4691,30 +5242,32 @@ func Test_ngt_Len(t *testing.T) { func Test_ngt_InsertVCacheLen(t *testing.T) { type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { want uint64 @@ -4749,6 +5302,7 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4757,6 +5311,7 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4785,6 +5340,7 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4793,6 +5349,7 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4820,30 +5377,32 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } got := n.InsertVCacheLen() @@ -4857,30 +5416,32 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { func Test_ngt_DeleteVCacheLen(t *testing.T) { type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { want uint64 @@ -4915,6 +5476,7 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4923,6 +5485,7 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4951,6 +5514,7 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -4959,6 +5523,7 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -4986,30 +5551,32 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } got := n.DeleteVCacheLen() @@ -5026,30 +5593,32 @@ func Test_ngt_Close(t *testing.T) { ctx context.Context } type fields struct { - core core.NGT - eg errgroup.Group - kvs kvs.BidiMap - ivc *vcaches - dvc *vcaches - indexing atomic.Value - saving atomic.Value - lastNoice uint64 - ic uint64 - nocie uint64 - inMem bool - alen int - lim time.Duration - dur time.Duration - sdur time.Duration - minLit time.Duration - maxLit time.Duration - litFactor time.Duration - path string - poolSize uint32 - radius float32 - epsilon float32 - idelay time.Duration - dcd bool + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + ivc *vcaches + dvc *vcaches + indexing atomic.Value + saving atomic.Value + lastNoice uint64 + ic uint64 + nocie uint64 + nogce uint64 + inMem bool + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + path string + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool } type want struct { err error @@ -5088,6 +5657,7 @@ func Test_ngt_Close(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -5096,6 +5666,7 @@ func Test_ngt_Close(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -5127,6 +5698,7 @@ func Test_ngt_Close(t *testing.T) { lastNoice: 0, ic: 0, nocie: 0, + nogce: 0, inMem: false, alen: 0, lim: nil, @@ -5135,6 +5707,7 @@ func Test_ngt_Close(t *testing.T) { minLit: nil, maxLit: nil, litFactor: nil, + enableProactiveGC: false, path: "", poolSize: 0, radius: 0, @@ -5162,30 +5735,32 @@ func Test_ngt_Close(t *testing.T) { test.checkFunc = defaultCheckFunc } n := &ngt{ - core: test.fields.core, - eg: test.fields.eg, - kvs: test.fields.kvs, - ivc: test.fields.ivc, - dvc: test.fields.dvc, - indexing: test.fields.indexing, - saving: test.fields.saving, - lastNoice: test.fields.lastNoice, - ic: test.fields.ic, - nocie: test.fields.nocie, - inMem: test.fields.inMem, - 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, - path: test.fields.path, - poolSize: test.fields.poolSize, - radius: test.fields.radius, - epsilon: test.fields.epsilon, - idelay: test.fields.idelay, - dcd: test.fields.dcd, + core: test.fields.core, + eg: test.fields.eg, + kvs: test.fields.kvs, + ivc: test.fields.ivc, + dvc: test.fields.dvc, + indexing: test.fields.indexing, + saving: test.fields.saving, + lastNoice: test.fields.lastNoice, + ic: test.fields.ic, + nocie: test.fields.nocie, + nogce: test.fields.nogce, + inMem: test.fields.inMem, + 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, + path: test.fields.path, + poolSize: test.fields.poolSize, + radius: test.fields.radius, + epsilon: test.fields.epsilon, + idelay: test.fields.idelay, + dcd: test.fields.dcd, } err := n.Close(test.args.ctx) diff --git a/pkg/agent/core/ngt/service/option.go b/pkg/agent/core/ngt/service/option.go index 19091eabd7..9d8c7a7983 100644 --- a/pkg/agent/core/ngt/service/option.go +++ b/pkg/agent/core/ngt/service/option.go @@ -43,6 +43,7 @@ var ( WithDefaultPoolSize(core.DefaultPoolSize), WithDefaultRadius(core.DefaultRadius), WithDefaultEpsilon(core.DefaultEpsilon), + WithProactiveGC(true), } ) @@ -218,6 +219,7 @@ func WithDefaultRadius(rad float32) Option { return nil } } + func WithDefaultEpsilon(epsilon float32) Option { return func(n *ngt) error { n.epsilon = epsilon @@ -225,3 +227,10 @@ func WithDefaultEpsilon(epsilon float32) Option { return nil } } + +func WithProactiveGC(enabled bool) Option { + return func(n *ngt) error { + n.enableProactiveGC = enabled + return nil + } +} diff --git a/pkg/agent/core/ngt/service/option_test.go b/pkg/agent/core/ngt/service/option_test.go index 7aa24bb908..fe2561e1aa 100644 --- a/pkg/agent/core/ngt/service/option_test.go +++ b/pkg/agent/core/ngt/service/option_test.go @@ -1618,3 +1618,117 @@ func TestWithDefaultEpsilon(t *testing.T) { }) } } + +func TestWithProactiveGC(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + enabled bool + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(args) + afterFunc func(args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + enabled: false, + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + enabled: false, + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + got := WithProactiveGC(test.args.enabled) + obj := new(T) + if err := test.checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithProactiveGC(test.args.enabled) + obj := new(T) + got(obj) + if err := test.checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} diff --git a/pkg/agent/core/ngt/service/vcaches_test.go b/pkg/agent/core/ngt/service/vcaches_test.go index 242697694a..e8b4b4a3b5 100644 --- a/pkg/agent/core/ngt/service/vcaches_test.go +++ b/pkg/agent/core/ngt/service/vcaches_test.go @@ -24,6 +24,7 @@ import ( "unsafe" "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func Test_newEntryVCache(t *testing.T) { @@ -77,6 +78,7 @@ func Test_newEntryVCache(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -173,6 +175,7 @@ func Test_vcaches_Load(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +257,7 @@ func Test_entryVCache_load(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -348,6 +352,7 @@ func Test_vcaches_Store(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +439,7 @@ func Test_entryVCache_tryStore(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -507,6 +513,7 @@ func Test_entryVCache_unexpungeLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -586,6 +593,7 @@ func Test_entryVCache_storeLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -676,6 +684,7 @@ func Test_vcaches_Delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -752,6 +761,7 @@ func Test_entryVCache_delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -843,6 +853,7 @@ func Test_vcaches_Range(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -927,6 +938,7 @@ func Test_vcaches_missLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -1011,6 +1023,7 @@ func Test_vcaches_dirtyLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -1087,6 +1100,7 @@ func Test_entryVCache_tryExpungeLocked(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -1172,6 +1186,7 @@ func Test_vcaches_Len(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/pkg/agent/core/ngt/usecase/agentd.go b/pkg/agent/core/ngt/usecase/agentd.go index 97a6a775ba..dbd939453d 100644 --- a/pkg/agent/core/ngt/usecase/agentd.go +++ b/pkg/agent/core/ngt/usecase/agentd.go @@ -62,6 +62,7 @@ func New(cfg *config.Data) (r runner.Runner, err error) { service.WithDefaultPoolSize(cfg.NGT.DefaultPoolSize), service.WithDefaultRadius(cfg.NGT.DefaultRadius), service.WithDefaultEpsilon(cfg.NGT.DefaultEpsilon), + service.WithProactiveGC(cfg.NGT.EnableProactiveGC), ) if err != nil { return nil, err diff --git a/pkg/agent/core/ngt/usecase/agentd_test.go b/pkg/agent/core/ngt/usecase/agentd_test.go index e37dc8351e..12ec0d5eb3 100644 --- a/pkg/agent/core/ngt/usecase/agentd_test.go +++ b/pkg/agent/core/ngt/usecase/agentd_test.go @@ -28,7 +28,6 @@ import ( "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/agent/core/ngt/config" "github.com/vdaas/vald/pkg/agent/core/ngt/service" - "go.uber.org/goleak" ) @@ -87,7 +86,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -180,7 +179,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -284,7 +283,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -384,7 +383,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -484,7 +483,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -584,7 +583,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } From 409407aa9434be715d0845dd4188fb1eb48143b3 Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 10 Sep 2020 12:25:31 +0900 Subject: [PATCH 07/12] fix Signed-off-by: kpango --- internal/observability/metrics/agent/core/ngt/ngt.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/observability/metrics/agent/core/ngt/ngt.go b/internal/observability/metrics/agent/core/ngt/ngt.go index 54a27c2ee2..2215455aef 100644 --- a/internal/observability/metrics/agent/core/ngt/ngt.go +++ b/internal/observability/metrics/agent/core/ngt/ngt.go @@ -146,7 +146,7 @@ func (n *ngtMetrics) View() []*metrics.View { Aggregation: metrics.LastValue(), }, &metrics.View{ - Name: "ngt_is_indexing", + Name: "ngt_is_saving", Description: n.isSaving.Description(), Measure: &n.isSaving, Aggregation: metrics.LastValue(), From 5d72a6cdb21b81eaa61e7320edff4b159fb9a376 Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 10 Sep 2020 12:36:50 +0900 Subject: [PATCH 08/12] fix Signed-off-by: kpango --- pkg/agent/core/ngt/service/ngt.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/agent/core/ngt/service/ngt.go b/pkg/agent/core/ngt/service/ngt.go index 9850fcc1c5..98f9c2a587 100644 --- a/pkg/agent/core/ngt/service/ngt.go +++ b/pkg/agent/core/ngt/service/ngt.go @@ -651,8 +651,16 @@ func (n *ngt) saveIndex(ctx context.Context) (err error) { return } atomic.SwapUint64(&n.lastNoice, noice) + ticker := time.NewTicker(time.Second) + defer ticker.Stop() // wait for not indexing & not saving for n.IsIndexing() || n.IsSaving() { + runtime.Gosched() + select{ + case <- ctx.Done(): + return ctx.Err() + case <-ticker.C: + } } n.saving.Store(true) defer n.gc() From aac607ca7c554cfb473bd22e769798343cd9995f Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 10 Sep 2020 12:40:55 +0900 Subject: [PATCH 09/12] fix Signed-off-by: kpango --- internal/errors/http.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/errors/http.go b/internal/errors/http.go index a050fa94ad..a68560d69c 100644 --- a/internal/errors/http.go +++ b/internal/errors/http.go @@ -30,8 +30,8 @@ var ( return Wrap(err, "handler returned error") } - ErrHandlerTimeout = func(err error, t time.Time) error { - return Wrapf(err, "handler timeout %v", t) + ErrHandlerTimeout = func(err error, dur time.Duration) error { + return Wrapf(err, "handler timeout %s", dur.String()) } ErrRequestBodyCloseAndFlush = func(err error) error { From 1e42abb90139a060af63ed637e50f50b3359eacd Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 10 Sep 2020 12:56:57 +0900 Subject: [PATCH 10/12] fix Signed-off-by: kpango --- go.mod | 1 + go.sum | 2 +- hack/go.mod.default | 1 + pkg/agent/core/ngt/service/ngt.go | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 01712641f2..035e1b9f79 100755 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ replace ( github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.2.0+incompatible github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.34.20 github.com/boltdb/bolt => github.com/boltdb/bolt v1.3.1 + github.com/chzyer/logex => github.com/chzyer/logex v1.1.11-0.20170329064859-445be9e134b2 github.com/coreos/etcd => go.etcd.io/etcd v3.3.25+incompatible github.com/docker/docker => github.com/moby/moby v1.13.1 github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v0.4.1 diff --git a/go.sum b/go.sum index a934835c83..0431573679 100644 --- a/go.sum +++ b/go.sum @@ -76,7 +76,7 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/logex v1.1.11-0.20170329064859-445be9e134b2/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= diff --git a/hack/go.mod.default b/hack/go.mod.default index 3a12c43069..361b9d2f2c 100755 --- a/hack/go.mod.default +++ b/hack/go.mod.default @@ -7,6 +7,7 @@ replace ( github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.2.0 github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go latest github.com/boltdb/bolt => github.com/boltdb/bolt v1.3.1 + github.com/chzyer/logex => github.com/chzyer/logex master github.com/coreos/etcd => go.etcd.io/etcd latest github.com/docker/docker => github.com/moby/moby latest github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate latest diff --git a/pkg/agent/core/ngt/service/ngt.go b/pkg/agent/core/ngt/service/ngt.go index 98f9c2a587..715ce957d1 100644 --- a/pkg/agent/core/ngt/service/ngt.go +++ b/pkg/agent/core/ngt/service/ngt.go @@ -656,8 +656,8 @@ func (n *ngt) saveIndex(ctx context.Context) (err error) { // wait for not indexing & not saving for n.IsIndexing() || n.IsSaving() { runtime.Gosched() - select{ - case <- ctx.Done(): + select { + case <-ctx.Done(): return ctx.Err() case <-ticker.C: } From c6285c609ac546d81d16db091d6a29a246a03707 Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 10 Sep 2020 13:23:22 +0900 Subject: [PATCH 11/12] fix Signed-off-by: kpango --- go.mod | 1 - hack/go.mod.default | 1 - 2 files changed, 2 deletions(-) diff --git a/go.mod b/go.mod index 035e1b9f79..45d9d932c9 100755 --- a/go.mod +++ b/go.mod @@ -21,7 +21,6 @@ replace ( github.com/gophercloud/gophercloud => github.com/gophercloud/gophercloud v0.12.0 github.com/gorilla/websocket => github.com/gorilla/websocket v1.4.2 github.com/hailocab/go-hostpool => github.com/monzo/go-hostpool v0.0.0-20200724120130-287edbb29340 - github.com/hydrogen18/memlistener => github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91 github.com/klauspost/compress => github.com/klauspost/compress v1.11.1-0.20200908135004-a2bf5b1ec3aa github.com/tensorflow/tensorflow => github.com/tensorflow/tensorflow v2.1.0+incompatible golang.org/x/crypto => golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a diff --git a/hack/go.mod.default b/hack/go.mod.default index 361b9d2f2c..01f750d448 100755 --- a/hack/go.mod.default +++ b/hack/go.mod.default @@ -21,7 +21,6 @@ replace ( github.com/gophercloud/gophercloud => github.com/gophercloud/gophercloud latest github.com/gorilla/websocket => github.com/gorilla/websocket latest github.com/hailocab/go-hostpool => github.com/monzo/go-hostpool latest - github.com/hydrogen18/memlistener => github.com/hydrogen18/memlistener master github.com/klauspost/compress => github.com/klauspost/compress master github.com/tensorflow/tensorflow => github.com/tensorflow/tensorflow v2.1.0 golang.org/x/crypto => golang.org/x/crypto latest From 752ae71c2ca7aa5d5c0a845d90a11ead3ae02970 Mon Sep 17 00:00:00 2001 From: Yusuke Kato Date: Thu, 10 Sep 2020 13:46:25 +0900 Subject: [PATCH 12/12] Update charts/vald/values.yaml Co-authored-by: Rintaro Okamura --- charts/vald/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/vald/values.yaml b/charts/vald/values.yaml index 510c64f748..790f9cc0b4 100644 --- a/charts/vald/values.yaml +++ b/charts/vald/values.yaml @@ -1286,7 +1286,7 @@ agent: # timeout duration will be calculated by (index count to be loaded) * (factor). load_index_timeout_factor: 1ms # @schema {"name": "agent.ngt.enable_proactive_gc", "type": "boolean"} - # agent.ngt.enable_proactive_gc -- proactive gc enabled + # agent.ngt.enable_proactive_gc -- enable proactive GC call for reducing heap memory allocation enable_proactive_gc: true # @schema {"name": "agent.sidecar", "type": "object"} sidecar: