[#1320] shard: Fix TestGCDropsObjectInhumedFromWritecache flaky test
All checks were successful
DCO action / DCO (pull_request) Successful in 1m27s
Tests and linters / Run gofumpt (pull_request) Successful in 2m25s
Build / Build Components (1.23) (pull_request) Successful in 2m46s
Vulncheck / Vulncheck (pull_request) Successful in 2m37s
Build / Build Components (1.22) (pull_request) Successful in 2m55s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m50s
Tests and linters / Staticcheck (pull_request) Successful in 3m33s
Tests and linters / Lint (pull_request) Successful in 3m45s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m45s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m42s
Tests and linters / Tests with -race (pull_request) Successful in 4m22s
Tests and linters / gopls check (pull_request) Successful in 4m25s
All checks were successful
DCO action / DCO (pull_request) Successful in 1m27s
Tests and linters / Run gofumpt (pull_request) Successful in 2m25s
Build / Build Components (1.23) (pull_request) Successful in 2m46s
Vulncheck / Vulncheck (pull_request) Successful in 2m37s
Build / Build Components (1.22) (pull_request) Successful in 2m55s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m50s
Tests and linters / Staticcheck (pull_request) Successful in 3m33s
Tests and linters / Lint (pull_request) Successful in 3m45s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m45s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m42s
Tests and linters / Tests with -race (pull_request) Successful in 4m22s
Tests and linters / gopls check (pull_request) Successful in 4m25s
The `TestGCDropsObjectInhumedFromWritecache` test was flaky because a running asynchronous rebuild operation prevented GC from deleting the object. A test-only shard option `WithDisabledRebuild` has been added to fix this. Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
98fe24cdb7
commit
2b3fc50681
3 changed files with 13 additions and 3 deletions
|
@ -130,7 +130,7 @@ func (s *Shard) Init(ctx context.Context) error {
|
||||||
s.gc.init(ctx)
|
s.gc.init(ctx)
|
||||||
|
|
||||||
s.rb = newRebuilder(s.rebuildLimiter)
|
s.rb = newRebuilder(s.rebuildLimiter)
|
||||||
if !m.NoMetabase() {
|
if !m.NoMetabase() && !s.rebuildDisabled {
|
||||||
s.rb.Start(ctx, s.blobStor, s.metaBase, s.log)
|
s.rb.Start(ctx, s.blobStor, s.metaBase, s.log)
|
||||||
}
|
}
|
||||||
s.writecacheSealCancel.Store(dummyCancel)
|
s.writecacheSealCancel.Store(dummyCancel)
|
||||||
|
@ -398,7 +398,7 @@ func (s *Shard) Reload(ctx context.Context, opts ...Option) error {
|
||||||
defer unlock()
|
defer unlock()
|
||||||
|
|
||||||
s.rb.Stop(s.log)
|
s.rb.Stop(s.log)
|
||||||
if !s.info.Mode.NoMetabase() {
|
if !s.info.Mode.NoMetabase() && !s.rebuildDisabled {
|
||||||
defer func() {
|
defer func() {
|
||||||
s.rb.Start(ctx, s.blobStor, s.metaBase, s.log)
|
s.rb.Start(ctx, s.blobStor, s.metaBase, s.log)
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -187,7 +187,7 @@ func TestGCDropsObjectInhumedFromWritecache(t *testing.T) {
|
||||||
|
|
||||||
func testGCDropsObjectInhumedFromWritecache(t *testing.T, flushbeforeInhume bool) {
|
func testGCDropsObjectInhumedFromWritecache(t *testing.T, flushbeforeInhume bool) {
|
||||||
sh := newCustomShard(t, true, shardOptions{
|
sh := newCustomShard(t, true, shardOptions{
|
||||||
additionalShardOptions: []Option{WithDisabledGC()},
|
additionalShardOptions: []Option{WithDisabledGC(), WithDisabledRebuild()},
|
||||||
wcOpts: []writecache.Option{writecache.WithDisableBackgroundFlush()},
|
wcOpts: []writecache.Option{writecache.WithDisableBackgroundFlush()},
|
||||||
})
|
})
|
||||||
defer func() { require.NoError(t, sh.Close()) }()
|
defer func() { require.NoError(t, sh.Close()) }()
|
||||||
|
|
|
@ -139,6 +139,8 @@ type cfg struct {
|
||||||
reportErrorFunc func(selfID string, message string, err error)
|
reportErrorFunc func(selfID string, message string, err error)
|
||||||
|
|
||||||
rebuildLimiter RebuildWorkerLimiter
|
rebuildLimiter RebuildWorkerLimiter
|
||||||
|
|
||||||
|
rebuildDisabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultCfg() *cfg {
|
func defaultCfg() *cfg {
|
||||||
|
@ -410,6 +412,14 @@ func WithZeroCountCallback(cb EmptyContainersCallback) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithDisabledRebuild returns an option to disable a shard rebuild.
|
||||||
|
// For testing purposes only.
|
||||||
|
func WithDisabledRebuild() Option {
|
||||||
|
return func(c *cfg) {
|
||||||
|
c.rebuildDisabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Shard) fillInfo() {
|
func (s *Shard) fillInfo() {
|
||||||
s.cfg.info.MetaBaseInfo = s.metaBase.DumpInfo()
|
s.cfg.info.MetaBaseInfo = s.metaBase.DumpInfo()
|
||||||
s.cfg.info.BlobStorInfo = s.blobStor.DumpInfo()
|
s.cfg.info.BlobStorInfo = s.blobStor.DumpInfo()
|
||||||
|
|
Loading…
Reference in a new issue