[#668] shard/test: Disable GC where it is not needed

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-08-31 18:17:55 +03:00 committed by Evgenii Stratonikov
parent 42696016de
commit 382eb8a485
2 changed files with 9 additions and 2 deletions

View file

@ -119,6 +119,8 @@ type gcCfg struct {
expiredCollectorBatchSize int
metrics GCMectrics
testHookRemover func(ctx context.Context) gcRunResult
}
func defaultGCCfg() gcCfg {
@ -209,7 +211,12 @@ func (gc *gc) tickRemover(ctx context.Context) {
case <-timer.C:
startedAt := time.Now()
result := gc.remover(ctx)
var result gcRunResult
if gc.testHookRemover != nil {
result = gc.testHookRemover(ctx)
} else {
result = gc.remover(ctx)
}
timer.Reset(gc.removerInterval)
gc.metrics.AddRunDuration(time.Since(startedAt), result.success)

View file

@ -75,7 +75,7 @@ func Test_ObjectNotFoundIfNotDeletedFromMetabase(t *testing.T) {
}
sh = New(opts...)
sh.gcCfg.testHookRemover = func(context.Context) gcRunResult { return gcRunResult{} }
require.NoError(t, sh.Open())
require.NoError(t, sh.Init(context.Background()))