[#920] tests: Fix data races
DCO action / DCO (pull_request) Successful in 2m2s Details
Build / Build Components (1.21) (pull_request) Successful in 3m35s Details
Vulncheck / Vulncheck (pull_request) Successful in 3m3s Details
Tests and linters / Staticcheck (pull_request) Successful in 5m23s Details
Tests and linters / Tests (1.20) (pull_request) Successful in 7m33s Details
Tests and linters / Tests (1.21) (pull_request) Successful in 7m41s Details
Tests and linters / Tests with -race (pull_request) Successful in 7m47s Details
Tests and linters / Lint (pull_request) Successful in 8m12s Details
Build / Build Components (1.20) (pull_request) Successful in 1m32s Details

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
pull/920/head
Dmitrii Stepanov 2024-01-18 22:24:34 +03:00
parent e42262a863
commit f5160b27fc
3 changed files with 37 additions and 0 deletions

View File

@ -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))

View File

@ -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 {

View File

@ -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"