[#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 expiredCollectorBatchSize int
metrics GCMectrics metrics GCMectrics
testHookRemover func(ctx context.Context) gcRunResult
} }
func defaultGCCfg() gcCfg { func defaultGCCfg() gcCfg {
@ -209,7 +211,12 @@ func (gc *gc) tickRemover(ctx context.Context) {
case <-timer.C: case <-timer.C:
startedAt := time.Now() 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) timer.Reset(gc.removerInterval)
gc.metrics.AddRunDuration(time.Since(startedAt), result.success) gc.metrics.AddRunDuration(time.Since(startedAt), result.success)

View file

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