[#321] metabase/test: execute tests in parallel

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-05-05 17:02:27 +03:00 committed by Evgenii Stratonikov
parent c8c5f14e2e
commit c62025c836
7 changed files with 65 additions and 22 deletions

View file

@ -15,6 +15,8 @@ import (
) )
func TestDB_Containers(t *testing.T) { func TestDB_Containers(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
const N = 10 const N = 10
@ -90,6 +92,8 @@ func TestDB_Containers(t *testing.T) {
} }
func TestDB_ContainersCount(t *testing.T) { func TestDB_ContainersCount(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
const R, T, SG, L = 10, 11, 12, 13 // amount of object per type const R, T, SG, L = 10, 11, 12, 13 // amount of object per type
@ -133,6 +137,8 @@ func TestDB_ContainersCount(t *testing.T) {
} }
func TestDB_ContainerSize(t *testing.T) { func TestDB_ContainerSize(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
const ( const (

View file

@ -2,6 +2,7 @@ package meta_test
import ( import (
"context" "context"
"os"
"testing" "testing"
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object" objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
@ -16,19 +17,23 @@ import (
const objCount = 10 const objCount = 10
func TestCounters(t *testing.T) { func TestCounters(t *testing.T) {
db := newDB(t) t.Parallel()
t.Cleanup(func() {
var c meta.ObjectCounters require.NoError(t, os.RemoveAll(t.Name()))
var err error })
t.Run("defaults", func(t *testing.T) { t.Run("defaults", func(t *testing.T) {
c, err = db.ObjectCounters() t.Parallel()
db := newDB(t)
c, err := db.ObjectCounters()
require.NoError(t, err) require.NoError(t, err)
require.Zero(t, c.Phy()) require.Zero(t, c.Phy())
require.Zero(t, c.Logic()) require.Zero(t, c.Logic())
}) })
t.Run("put", func(t *testing.T) { t.Run("put", func(t *testing.T) {
t.Parallel()
db := newDB(t)
oo := make([]*object.Object, 0, objCount) oo := make([]*object.Object, 0, objCount)
for i := 0; i < objCount; i++ { for i := 0; i < objCount; i++ {
oo = append(oo, testutil.GenerateObject()) oo = append(oo, testutil.GenerateObject())
@ -39,10 +44,10 @@ func TestCounters(t *testing.T) {
for i := 0; i < objCount; i++ { for i := 0; i < objCount; i++ {
prm.SetObject(oo[i]) prm.SetObject(oo[i])
_, err = db.Put(context.Background(), prm) _, err := db.Put(context.Background(), prm)
require.NoError(t, err) require.NoError(t, err)
c, err = db.ObjectCounters() c, err := db.ObjectCounters()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(i+1), c.Phy()) require.Equal(t, uint64(i+1), c.Phy())
@ -50,9 +55,9 @@ func TestCounters(t *testing.T) {
} }
}) })
require.NoError(t, db.Reset())
t.Run("delete", func(t *testing.T) { t.Run("delete", func(t *testing.T) {
t.Parallel()
db := newDB(t)
oo := putObjs(t, db, objCount, false) oo := putObjs(t, db, objCount, false)
var prm meta.DeletePrm var prm meta.DeletePrm
@ -63,7 +68,7 @@ func TestCounters(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(1), res.AvailableObjectsRemoved()) require.Equal(t, uint64(1), res.AvailableObjectsRemoved())
c, err = db.ObjectCounters() c, err := db.ObjectCounters()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(i), c.Phy()) require.Equal(t, uint64(i), c.Phy())
@ -71,9 +76,9 @@ func TestCounters(t *testing.T) {
} }
}) })
require.NoError(t, db.Reset())
t.Run("inhume", func(t *testing.T) { t.Run("inhume", func(t *testing.T) {
t.Parallel()
db := newDB(t)
oo := putObjs(t, db, objCount, false) oo := putObjs(t, db, objCount, false)
inhumedObjs := make([]oid.Address, objCount/2) inhumedObjs := make([]oid.Address, objCount/2)
@ -94,16 +99,16 @@ func TestCounters(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(len(inhumedObjs)), res.AvailableInhumed()) require.Equal(t, uint64(len(inhumedObjs)), res.AvailableInhumed())
c, err = db.ObjectCounters() c, err := db.ObjectCounters()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(objCount), c.Phy()) require.Equal(t, uint64(objCount), c.Phy())
require.Equal(t, uint64(objCount-len(inhumedObjs)), c.Logic()) require.Equal(t, uint64(objCount-len(inhumedObjs)), c.Logic())
}) })
require.NoError(t, db.Reset())
t.Run("put_split", func(t *testing.T) { t.Run("put_split", func(t *testing.T) {
t.Parallel()
db := newDB(t)
parObj := testutil.GenerateObject() parObj := testutil.GenerateObject()
// put objects and check that parent info // put objects and check that parent info
@ -116,16 +121,16 @@ func TestCounters(t *testing.T) {
require.NoError(t, putBig(db, o)) require.NoError(t, putBig(db, o))
c, err = db.ObjectCounters() c, err := db.ObjectCounters()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(i+1), c.Phy()) require.Equal(t, uint64(i+1), c.Phy())
require.Equal(t, uint64(i+1), c.Logic()) require.Equal(t, uint64(i+1), c.Logic())
} }
}) })
require.NoError(t, db.Reset())
t.Run("delete_split", func(t *testing.T) { t.Run("delete_split", func(t *testing.T) {
t.Parallel()
db := newDB(t)
oo := putObjs(t, db, objCount, true) oo := putObjs(t, db, objCount, true)
// delete objects that have parent info // delete objects that have parent info
@ -141,9 +146,9 @@ func TestCounters(t *testing.T) {
} }
}) })
require.NoError(t, db.Reset())
t.Run("inhume_split", func(t *testing.T) { t.Run("inhume_split", func(t *testing.T) {
t.Parallel()
db := newDB(t)
oo := putObjs(t, db, objCount, true) oo := putObjs(t, db, objCount, true)
inhumedObjs := make([]oid.Address, objCount/2) inhumedObjs := make([]oid.Address, objCount/2)
@ -160,10 +165,10 @@ func TestCounters(t *testing.T) {
prm.SetTombstoneAddress(oidtest.Address()) prm.SetTombstoneAddress(oidtest.Address())
prm.SetAddresses(inhumedObjs...) prm.SetAddresses(inhumedObjs...)
_, err = db.Inhume(context.Background(), prm) _, err := db.Inhume(context.Background(), prm)
require.NoError(t, err) require.NoError(t, err)
c, err = db.ObjectCounters() c, err := db.ObjectCounters()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, uint64(objCount), c.Phy()) require.Equal(t, uint64(objCount), c.Phy())

View file

@ -10,6 +10,8 @@ import (
) )
func TestGeneric(t *testing.T) { func TestGeneric(t *testing.T) {
t.Parallel()
defer func() { _ = os.RemoveAll(t.Name()) }() defer func() { _ = os.RemoveAll(t.Name()) }()
var n int var n int

View file

@ -66,6 +66,8 @@ func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) {
} }
func TestLisObjectsWithCursor(t *testing.T) { func TestLisObjectsWithCursor(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
const ( const (
@ -159,6 +161,8 @@ func TestLisObjectsWithCursor(t *testing.T) {
} }
func TestAddObjectDuringListingWithCursor(t *testing.T) { func TestAddObjectDuringListingWithCursor(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
const total = 5 const total = 5

View file

@ -17,6 +17,8 @@ import (
) )
func TestDB_Lock(t *testing.T) { func TestDB_Lock(t *testing.T) {
t.Parallel()
cnr := cidtest.ID() cnr := cidtest.ID()
db := newDB(t) db := newDB(t)
@ -171,6 +173,8 @@ func TestDB_Lock(t *testing.T) {
} }
func TestDB_Lock_Expired(t *testing.T) { func TestDB_Lock_Expired(t *testing.T) {
t.Parallel()
es := &epochState{e: 123} es := &epochState{e: 123}
db := newDB(t, meta.WithEpochState(es)) db := newDB(t, meta.WithEpochState(es))
@ -192,6 +196,8 @@ func TestDB_Lock_Expired(t *testing.T) {
} }
func TestDB_IsLocked(t *testing.T) { func TestDB_IsLocked(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
// existing and locked objs // existing and locked objs

View file

@ -20,6 +20,8 @@ import (
) )
func TestDB_SelectUserAttributes(t *testing.T) { func TestDB_SelectUserAttributes(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
cnr := cidtest.ID() cnr := cidtest.ID()
@ -142,6 +144,8 @@ func TestDB_SelectUserAttributes(t *testing.T) {
} }
func TestDB_SelectRootPhyParent(t *testing.T) { func TestDB_SelectRootPhyParent(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
cnr := cidtest.ID() cnr := cidtest.ID()
@ -293,6 +297,8 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
} }
func TestDB_SelectInhume(t *testing.T) { func TestDB_SelectInhume(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
cnr := cidtest.ID() cnr := cidtest.ID()
@ -325,6 +331,8 @@ func TestDB_SelectInhume(t *testing.T) {
} }
func TestDB_SelectPayloadHash(t *testing.T) { func TestDB_SelectPayloadHash(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
cnr := cidtest.ID() cnr := cidtest.ID()
@ -393,6 +401,8 @@ func TestDB_SelectPayloadHash(t *testing.T) {
} }
func TestDB_SelectWithSlowFilters(t *testing.T) { func TestDB_SelectWithSlowFilters(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
cnr := cidtest.ID() cnr := cidtest.ID()
@ -498,6 +508,8 @@ func TestDB_SelectWithSlowFilters(t *testing.T) {
} }
func TestDB_SelectObjectID(t *testing.T) { func TestDB_SelectObjectID(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
cnr := cidtest.ID() cnr := cidtest.ID()
@ -611,6 +623,8 @@ func TestDB_SelectObjectID(t *testing.T) {
} }
func TestDB_SelectSplitID(t *testing.T) { func TestDB_SelectSplitID(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
cnr := cidtest.ID() cnr := cidtest.ID()
@ -665,6 +679,8 @@ func TestDB_SelectSplitID(t *testing.T) {
} }
func TestDB_SelectContainerID(t *testing.T) { func TestDB_SelectContainerID(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
cnr := cidtest.ID() cnr := cidtest.ID()
@ -750,6 +766,8 @@ func BenchmarkSelect(b *testing.B) {
} }
func TestExpiredObjects(t *testing.T) { func TestExpiredObjects(t *testing.T) {
t.Parallel()
db := newDB(t, meta.WithEpochState(epochState{currEpoch})) db := newDB(t, meta.WithEpochState(epochState{currEpoch}))
checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) { checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) {

View file

@ -12,6 +12,8 @@ import (
) )
func TestDB_StorageID(t *testing.T) { func TestDB_StorageID(t *testing.T) {
t.Parallel()
db := newDB(t) db := newDB(t)
raw1 := testutil.GenerateObject() raw1 := testutil.GenerateObject()