[#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) {
t.Parallel()
db := newDB(t)
const N = 10
@ -90,6 +92,8 @@ func TestDB_Containers(t *testing.T) {
}
func TestDB_ContainersCount(t *testing.T) {
t.Parallel()
db := newDB(t)
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) {
t.Parallel()
db := newDB(t)
const (

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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