From 945454f60c95ce424cb9eb77fccd2f75ea1d98d6 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 5 May 2023 16:17:29 +0300 Subject: [PATCH] [#321] engine/test: Execute tests in parallel Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/engine/delete_test.go | 2 ++ pkg/local_object_storage/engine/evacuate_test.go | 8 ++++++++ pkg/local_object_storage/engine/list_test.go | 6 +++++- pkg/local_object_storage/engine/lock_test.go | 6 ++++++ pkg/local_object_storage/engine/remove_copies_test.go | 4 ++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/engine/delete_test.go b/pkg/local_object_storage/engine/delete_test.go index 53c62981c..bbc27615a 100644 --- a/pkg/local_object_storage/engine/delete_test.go +++ b/pkg/local_object_storage/engine/delete_test.go @@ -18,6 +18,8 @@ import ( ) func TestDeleteBigObject(t *testing.T) { + t.Parallel() + defer os.RemoveAll(t.Name()) cnr := cidtest.ID() diff --git a/pkg/local_object_storage/engine/evacuate_test.go b/pkg/local_object_storage/engine/evacuate_test.go index bea6d4ff5..bc5b05ef0 100644 --- a/pkg/local_object_storage/engine/evacuate_test.go +++ b/pkg/local_object_storage/engine/evacuate_test.go @@ -77,6 +77,8 @@ func newEngineEvacuate(t *testing.T, shardNum int, objPerShard int) (*StorageEng } func TestEvacuateShard(t *testing.T) { + t.Parallel() + const objPerShard = 3 e, ids, objects := newEngineEvacuate(t, 3, objPerShard) @@ -132,6 +134,8 @@ func TestEvacuateShard(t *testing.T) { } func TestEvacuateNetwork(t *testing.T) { + t.Parallel() + var errReplication = errors.New("handler error") acceptOneOf := func(objects []*objectSDK.Object, max int) func(context.Context, oid.Address, *objectSDK.Object) error { @@ -154,6 +158,7 @@ func TestEvacuateNetwork(t *testing.T) { } t.Run("single shard", func(t *testing.T) { + t.Parallel() e, ids, objects := newEngineEvacuate(t, 1, 3) evacuateShardID := ids[0].String() @@ -173,6 +178,7 @@ func TestEvacuateNetwork(t *testing.T) { require.Equal(t, 2, res.Count()) }) t.Run("multiple shards, evacuate one", func(t *testing.T) { + t.Parallel() e, ids, objects := newEngineEvacuate(t, 2, 3) require.NoError(t, e.shards[ids[0].String()].SetMode(mode.ReadOnly)) @@ -195,6 +201,7 @@ func TestEvacuateNetwork(t *testing.T) { }) }) t.Run("multiple shards, evacuate many", func(t *testing.T) { + t.Parallel() e, ids, objects := newEngineEvacuate(t, 4, 5) evacuateIDs := ids[0:3] @@ -229,6 +236,7 @@ func TestEvacuateNetwork(t *testing.T) { } func TestEvacuateCancellation(t *testing.T) { + t.Parallel() e, ids, _ := newEngineEvacuate(t, 2, 3) require.NoError(t, e.shards[ids[0].String()].SetMode(mode.ReadOnly)) diff --git a/pkg/local_object_storage/engine/list_test.go b/pkg/local_object_storage/engine/list_test.go index 44062be68..5b927cf11 100644 --- a/pkg/local_object_storage/engine/list_test.go +++ b/pkg/local_object_storage/engine/list_test.go @@ -29,6 +29,8 @@ func sortAddresses(addrWithType []object.AddressWithType) []object.AddressWithTy } func TestListWithCursor(t *testing.T) { + t.Parallel() + tests := []struct { name string shardNum int @@ -60,8 +62,10 @@ func TestListWithCursor(t *testing.T) { batchSize: 100, }, } - for _, tt := range tests { + for i := range tests { + tt := tests[i] t.Run(tt.name, func(t *testing.T) { + t.Parallel() e := testNewEngine(t).setShardsNumOpts(t, tt.shardNum, func(id int) []shard.Option { return []shard.Option{ shard.WithLogger(&logger.Logger{Logger: zap.L()}), diff --git a/pkg/local_object_storage/engine/lock_test.go b/pkg/local_object_storage/engine/lock_test.go index 4c89b9226..7796913ea 100644 --- a/pkg/local_object_storage/engine/lock_test.go +++ b/pkg/local_object_storage/engine/lock_test.go @@ -31,6 +31,8 @@ func (t tss) IsTombstoneAvailable(ctx context.Context, _ oid.Address, epoch uint } func TestLockUserScenario(t *testing.T) { + t.Parallel() + // Tested user actions: // 1. stores some object // 2. locks the object @@ -146,6 +148,8 @@ func TestLockUserScenario(t *testing.T) { } func TestLockExpiration(t *testing.T) { + t.Parallel() + // Tested scenario: // 1. some object is stored // 2. lock object for it is stored, and the object is locked @@ -222,6 +226,8 @@ func TestLockExpiration(t *testing.T) { } func TestLockForceRemoval(t *testing.T) { + t.Parallel() + // Tested scenario: // 1. some object is stored // 2. lock object for it is stored, and the object is locked diff --git a/pkg/local_object_storage/engine/remove_copies_test.go b/pkg/local_object_storage/engine/remove_copies_test.go index c53e03bbf..8131fcf0d 100644 --- a/pkg/local_object_storage/engine/remove_copies_test.go +++ b/pkg/local_object_storage/engine/remove_copies_test.go @@ -17,6 +17,8 @@ import ( ) func TestRebalance(t *testing.T) { + t.Parallel() + te := newEngineWithErrorThreshold(t, "", 0) const ( @@ -101,6 +103,8 @@ loop: } func TestRebalanceSingleThread(t *testing.T) { + t.Parallel() + te := newEngineWithErrorThreshold(t, "", 0) obj := testutil.GenerateObjectWithCID(cidtest.ID())