From c5edf7723787d8c83d9afb6413b0b0e6b5a110c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Niewrza=C5=82?= Date: Fri, 20 May 2022 10:26:37 +0200 Subject: [PATCH] satellite/metabase: fix flaky TestCommitInlineSegment If TestCommitInlineSegment tests are taking longer time then zombieDeadline created at the beginning of test can be too far in the past. Creating zombieDeadline for each case should avoid flakines. Change-Id: Ieb011e8e470f6f1c32cf9365c8ae819317de6738 --- satellite/metabase/commit_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/satellite/metabase/commit_test.go b/satellite/metabase/commit_test.go index 6d03f3e5e..c830354b3 100644 --- a/satellite/metabase/commit_test.go +++ b/satellite/metabase/commit_test.go @@ -1678,8 +1678,6 @@ func TestCommitSegment(t *testing.T) { func TestCommitInlineSegment(t *testing.T) { metabasetest.Run(t, func(ctx *testcontext.Context, t *testing.T, db *metabase.DB) { obj := metabasetest.RandObjectStream() - now := time.Now() - zombieDeadline := now.Add(24 * time.Hour) for _, test := range metabasetest.InvalidObjectStreams(obj) { test := test t.Run(test.Name, func(t *testing.T) { @@ -1772,7 +1770,8 @@ func TestCommitInlineSegment(t *testing.T) { t.Run("duplicate", func(t *testing.T) { defer metabasetest.DeleteAll{}.Check(ctx, t, db) - now1 := time.Now() + now := time.Now() + zombieDeadline := now.Add(24 * time.Hour) metabasetest.BeginObjectExactVersion{ Opts: metabase.BeginObjectExactVersion{ @@ -1817,7 +1816,7 @@ func TestCommitInlineSegment(t *testing.T) { Objects: []metabase.RawObject{ { ObjectStream: obj, - CreatedAt: now1, + CreatedAt: now, Status: metabase.Pending, Encryption: metabasetest.DefaultEncryption, @@ -1846,7 +1845,8 @@ func TestCommitInlineSegment(t *testing.T) { t.Run("overwrite", func(t *testing.T) { defer metabasetest.DeleteAll{}.Check(ctx, t, db) - now1 := time.Now() + now := time.Now() + zombieDeadline := now.Add(24 * time.Hour) metabasetest.BeginObjectExactVersion{ Opts: metabase.BeginObjectExactVersion{ @@ -1891,7 +1891,7 @@ func TestCommitInlineSegment(t *testing.T) { Objects: []metabase.RawObject{ { ObjectStream: obj, - CreatedAt: now1, + CreatedAt: now, Status: metabase.Pending, Encryption: metabasetest.DefaultEncryption, @@ -1983,6 +1983,8 @@ func TestCommitInlineSegment(t *testing.T) { encryptedETag := testrand.Bytes(32) now := time.Now() + zombieDeadline := now.Add(24 * time.Hour) + metabasetest.BeginObjectExactVersion{ Opts: metabase.BeginObjectExactVersion{ ObjectStream: obj, @@ -2040,6 +2042,8 @@ func TestCommitInlineSegment(t *testing.T) { encryptedETag := testrand.Bytes(32) now := time.Now() + zombieDeadline := now.Add(24 * time.Hour) + metabasetest.BeginObjectExactVersion{ Opts: metabase.BeginObjectExactVersion{ ObjectStream: obj, @@ -2099,6 +2103,7 @@ func TestCommitInlineSegment(t *testing.T) { encryptedETag := testrand.Bytes(32) now := time.Now() + zombieDeadline := now.Add(24 * time.Hour) expectedExpiresAt := now.Add(33 * time.Hour) metabasetest.BeginObjectExactVersion{ Opts: metabase.BeginObjectExactVersion{