forked from TrueCloudLab/frostfs-node
[#920] tests: Fix data races
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
e42262a863
commit
f5160b27fc
3 changed files with 37 additions and 0 deletions
|
@ -83,6 +83,9 @@ func TestEvacuateShard(t *testing.T) {
|
|||
const objPerShard = 3
|
||||
|
||||
e, ids, objects := newEngineEvacuate(t, 3, objPerShard)
|
||||
defer func() {
|
||||
require.NoError(t, e.Close(context.Background()))
|
||||
}()
|
||||
|
||||
evacuateShardID := ids[2].String()
|
||||
|
||||
|
@ -161,6 +164,10 @@ func TestEvacuateNetwork(t *testing.T) {
|
|||
t.Run("single shard", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
e, ids, objects := newEngineEvacuate(t, 1, 3)
|
||||
defer func() {
|
||||
require.NoError(t, e.Close(context.Background()))
|
||||
}()
|
||||
|
||||
evacuateShardID := ids[0].String()
|
||||
|
||||
require.NoError(t, e.shards[evacuateShardID].SetMode(mode.ReadOnly))
|
||||
|
@ -181,6 +188,9 @@ func TestEvacuateNetwork(t *testing.T) {
|
|||
t.Run("multiple shards, evacuate one", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
e, ids, objects := newEngineEvacuate(t, 2, 3)
|
||||
defer func() {
|
||||
require.NoError(t, e.Close(context.Background()))
|
||||
}()
|
||||
|
||||
require.NoError(t, e.shards[ids[0].String()].SetMode(mode.ReadOnly))
|
||||
require.NoError(t, e.shards[ids[1].String()].SetMode(mode.ReadOnly))
|
||||
|
@ -204,6 +214,10 @@ func TestEvacuateNetwork(t *testing.T) {
|
|||
t.Run("multiple shards, evacuate many", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
e, ids, objects := newEngineEvacuate(t, 4, 5)
|
||||
defer func() {
|
||||
require.NoError(t, e.Close(context.Background()))
|
||||
}()
|
||||
|
||||
evacuateIDs := ids[0:3]
|
||||
|
||||
var totalCount uint64
|
||||
|
@ -239,6 +253,9 @@ func TestEvacuateNetwork(t *testing.T) {
|
|||
func TestEvacuateCancellation(t *testing.T) {
|
||||
t.Parallel()
|
||||
e, ids, _ := newEngineEvacuate(t, 2, 3)
|
||||
defer func() {
|
||||
require.NoError(t, e.Close(context.Background()))
|
||||
}()
|
||||
|
||||
require.NoError(t, e.shards[ids[0].String()].SetMode(mode.ReadOnly))
|
||||
require.NoError(t, e.shards[ids[1].String()].SetMode(mode.ReadOnly))
|
||||
|
@ -264,6 +281,9 @@ func TestEvacuateCancellation(t *testing.T) {
|
|||
|
||||
func TestEvacuateSingleProcess(t *testing.T) {
|
||||
e, ids, _ := newEngineEvacuate(t, 2, 3)
|
||||
defer func() {
|
||||
require.NoError(t, e.Close(context.Background()))
|
||||
}()
|
||||
|
||||
require.NoError(t, e.shards[ids[0].String()].SetMode(mode.ReadOnly))
|
||||
require.NoError(t, e.shards[ids[1].String()].SetMode(mode.ReadOnly))
|
||||
|
@ -303,6 +323,9 @@ func TestEvacuateSingleProcess(t *testing.T) {
|
|||
|
||||
func TestEvacuateAsync(t *testing.T) {
|
||||
e, ids, _ := newEngineEvacuate(t, 2, 3)
|
||||
defer func() {
|
||||
require.NoError(t, e.Close(context.Background()))
|
||||
}()
|
||||
|
||||
require.NoError(t, e.shards[ids[0].String()].SetMode(mode.ReadOnly))
|
||||
require.NoError(t, e.shards[ids[1].String()].SetMode(mode.ReadOnly))
|
||||
|
|
|
@ -20,6 +20,9 @@ func TestRebalance(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
te := newEngineWithErrorThreshold(t, "", 0)
|
||||
defer func() {
|
||||
require.NoError(t, te.ng.Close(context.Background()))
|
||||
}()
|
||||
|
||||
const (
|
||||
objCount = 20
|
||||
|
@ -106,6 +109,9 @@ func TestRebalanceSingleThread(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
te := newEngineWithErrorThreshold(t, "", 0)
|
||||
defer func() {
|
||||
require.NoError(t, te.ng.Close(context.Background()))
|
||||
}()
|
||||
|
||||
obj := testutil.GenerateObjectWithCID(cidtest.ID())
|
||||
obj.SetPayload(make([]byte, errSmallSize))
|
||||
|
@ -153,6 +159,9 @@ type deleteEvent struct {
|
|||
|
||||
func TestRebalanceExitByContext(t *testing.T) {
|
||||
te := newEngineWithErrorThreshold(t, "", 0)
|
||||
defer func() {
|
||||
require.NoError(t, te.ng.Close(context.Background()))
|
||||
}()
|
||||
|
||||
objects := make([]*objectSDK.Object, 4)
|
||||
for i := range objects {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func BenchmarkTreeVsSearch(b *testing.B) {
|
||||
|
@ -25,6 +26,10 @@ func BenchmarkTreeVsSearch(b *testing.B) {
|
|||
|
||||
func benchmarkTreeVsSearch(b *testing.B, objCount int) {
|
||||
te := newEngineWithErrorThreshold(b, "", 0)
|
||||
defer func() {
|
||||
require.NoError(b, te.ng.Close(context.Background()))
|
||||
}()
|
||||
|
||||
cid := cidtest.ID()
|
||||
d := pilorama.CIDDescriptor{CID: cid, Position: 0, Size: 1}
|
||||
treeID := "someTree"
|
||||
|
|
Loading…
Reference in a new issue