diff --git a/pkg/local_object_storage/shard/gc.go b/pkg/local_object_storage/shard/gc.go index 8be91fcaf..38baccd4b 100644 --- a/pkg/local_object_storage/shard/gc.go +++ b/pkg/local_object_storage/shard/gc.go @@ -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) diff --git a/pkg/local_object_storage/shard/gc_internal_test.go b/pkg/local_object_storage/shard/gc_internal_test.go index 9a4f52029..c8925e01f 100644 --- a/pkg/local_object_storage/shard/gc_internal_test.go +++ b/pkg/local_object_storage/shard/gc_internal_test.go @@ -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()))