From 1b22801eed60949f853e63ccd069dea557b9c3d6 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 9 Nov 2023 10:25:46 +0300 Subject: [PATCH] [#788] engine: Fix flaky tests Signed-off-by: Dmitrii Stepanov --- pkg/local_object_storage/engine/lock_test.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/local_object_storage/engine/lock_test.go b/pkg/local_object_storage/engine/lock_test.go index d5c080222..ec18fc5e3 100644 --- a/pkg/local_object_storage/engine/lock_test.go +++ b/pkg/local_object_storage/engine/lock_test.go @@ -137,13 +137,12 @@ func TestLockUserScenario(t *testing.T) { // 5. e.HandleNewEpoch(lockerExpiresAfter + 1) - // delay for GC - time.Sleep(time.Second) - inhumePrm.WithTarget(tombAddr, objAddr) - _, err = e.Inhume(context.Background(), inhumePrm) - require.NoError(t, err) + require.Eventually(t, func() bool { + _, err = e.Inhume(context.Background(), inhumePrm) + return err == nil + }, 30*time.Second, time.Second) } func TestLockExpiration(t *testing.T) { @@ -213,15 +212,13 @@ func TestLockExpiration(t *testing.T) { // 3. e.HandleNewEpoch(lockerExpiresAfter + 1) - // delay for GC processing. It can't be estimated, but making it bigger - // will slow down test - time.Sleep(time.Second) - // 4. inhumePrm.WithTarget(oidtest.Address(), objectcore.AddressOf(obj)) - _, err = e.Inhume(context.Background(), inhumePrm) - require.NoError(t, err) + require.Eventually(t, func() bool { + _, err = e.Inhume(context.Background(), inhumePrm) + return err == nil + }, 30*time.Second, time.Second) } func TestLockForceRemoval(t *testing.T) {