[#920] tests: Fix data races
All checks were successful
DCO action / DCO (pull_request) Successful in 2m2s
Build / Build Components (1.21) (pull_request) Successful in 3m35s
Vulncheck / Vulncheck (pull_request) Successful in 3m3s
Tests and linters / Staticcheck (pull_request) Successful in 5m23s
Tests and linters / Tests (1.20) (pull_request) Successful in 7m33s
Tests and linters / Tests (1.21) (pull_request) Successful in 7m41s
Tests and linters / Tests with -race (pull_request) Successful in 7m47s
Tests and linters / Lint (pull_request) Successful in 8m12s
Build / Build Components (1.20) (pull_request) Successful in 1m32s
All checks were successful
DCO action / DCO (pull_request) Successful in 2m2s
Build / Build Components (1.21) (pull_request) Successful in 3m35s
Vulncheck / Vulncheck (pull_request) Successful in 3m3s
Tests and linters / Staticcheck (pull_request) Successful in 5m23s
Tests and linters / Tests (1.20) (pull_request) Successful in 7m33s
Tests and linters / Tests (1.21) (pull_request) Successful in 7m41s
Tests and linters / Tests with -race (pull_request) Successful in 7m47s
Tests and linters / Lint (pull_request) Successful in 8m12s
Build / Build Components (1.20) (pull_request) Successful in 1m32s
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
|
const objPerShard = 3
|
||||||
|
|
||||||
e, ids, objects := newEngineEvacuate(t, 3, objPerShard)
|
e, ids, objects := newEngineEvacuate(t, 3, objPerShard)
|
||||||
|
defer func() {
|
||||||
|
require.NoError(t, e.Close(context.Background()))
|
||||||
|
}()
|
||||||
|
|
||||||
evacuateShardID := ids[2].String()
|
evacuateShardID := ids[2].String()
|
||||||
|
|
||||||
|
@ -161,6 +164,10 @@ func TestEvacuateNetwork(t *testing.T) {
|
||||||
t.Run("single shard", func(t *testing.T) {
|
t.Run("single shard", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
e, ids, objects := newEngineEvacuate(t, 1, 3)
|
e, ids, objects := newEngineEvacuate(t, 1, 3)
|
||||||
|
defer func() {
|
||||||
|
require.NoError(t, e.Close(context.Background()))
|
||||||
|
}()
|
||||||
|
|
||||||
evacuateShardID := ids[0].String()
|
evacuateShardID := ids[0].String()
|
||||||
|
|
||||||
require.NoError(t, e.shards[evacuateShardID].SetMode(mode.ReadOnly))
|
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.Run("multiple shards, evacuate one", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
e, ids, objects := newEngineEvacuate(t, 2, 3)
|
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[0].String()].SetMode(mode.ReadOnly))
|
||||||
require.NoError(t, e.shards[ids[1].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.Run("multiple shards, evacuate many", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
e, ids, objects := newEngineEvacuate(t, 4, 5)
|
e, ids, objects := newEngineEvacuate(t, 4, 5)
|
||||||
|
defer func() {
|
||||||
|
require.NoError(t, e.Close(context.Background()))
|
||||||
|
}()
|
||||||
|
|
||||||
evacuateIDs := ids[0:3]
|
evacuateIDs := ids[0:3]
|
||||||
|
|
||||||
var totalCount uint64
|
var totalCount uint64
|
||||||
|
@ -239,6 +253,9 @@ func TestEvacuateNetwork(t *testing.T) {
|
||||||
func TestEvacuateCancellation(t *testing.T) {
|
func TestEvacuateCancellation(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
e, ids, _ := newEngineEvacuate(t, 2, 3)
|
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[0].String()].SetMode(mode.ReadOnly))
|
||||||
require.NoError(t, e.shards[ids[1].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) {
|
func TestEvacuateSingleProcess(t *testing.T) {
|
||||||
e, ids, _ := newEngineEvacuate(t, 2, 3)
|
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[0].String()].SetMode(mode.ReadOnly))
|
||||||
require.NoError(t, e.shards[ids[1].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) {
|
func TestEvacuateAsync(t *testing.T) {
|
||||||
e, ids, _ := newEngineEvacuate(t, 2, 3)
|
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[0].String()].SetMode(mode.ReadOnly))
|
||||||
require.NoError(t, e.shards[ids[1].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()
|
t.Parallel()
|
||||||
|
|
||||||
te := newEngineWithErrorThreshold(t, "", 0)
|
te := newEngineWithErrorThreshold(t, "", 0)
|
||||||
|
defer func() {
|
||||||
|
require.NoError(t, te.ng.Close(context.Background()))
|
||||||
|
}()
|
||||||
|
|
||||||
const (
|
const (
|
||||||
objCount = 20
|
objCount = 20
|
||||||
|
@ -106,6 +109,9 @@ func TestRebalanceSingleThread(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
te := newEngineWithErrorThreshold(t, "", 0)
|
te := newEngineWithErrorThreshold(t, "", 0)
|
||||||
|
defer func() {
|
||||||
|
require.NoError(t, te.ng.Close(context.Background()))
|
||||||
|
}()
|
||||||
|
|
||||||
obj := testutil.GenerateObjectWithCID(cidtest.ID())
|
obj := testutil.GenerateObjectWithCID(cidtest.ID())
|
||||||
obj.SetPayload(make([]byte, errSmallSize))
|
obj.SetPayload(make([]byte, errSmallSize))
|
||||||
|
@ -153,6 +159,9 @@ type deleteEvent struct {
|
||||||
|
|
||||||
func TestRebalanceExitByContext(t *testing.T) {
|
func TestRebalanceExitByContext(t *testing.T) {
|
||||||
te := newEngineWithErrorThreshold(t, "", 0)
|
te := newEngineWithErrorThreshold(t, "", 0)
|
||||||
|
defer func() {
|
||||||
|
require.NoError(t, te.ng.Close(context.Background()))
|
||||||
|
}()
|
||||||
|
|
||||||
objects := make([]*objectSDK.Object, 4)
|
objects := make([]*objectSDK.Object, 4)
|
||||||
for i := range objects {
|
for i := range objects {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkTreeVsSearch(b *testing.B) {
|
func BenchmarkTreeVsSearch(b *testing.B) {
|
||||||
|
@ -25,6 +26,10 @@ func BenchmarkTreeVsSearch(b *testing.B) {
|
||||||
|
|
||||||
func benchmarkTreeVsSearch(b *testing.B, objCount int) {
|
func benchmarkTreeVsSearch(b *testing.B, objCount int) {
|
||||||
te := newEngineWithErrorThreshold(b, "", 0)
|
te := newEngineWithErrorThreshold(b, "", 0)
|
||||||
|
defer func() {
|
||||||
|
require.NoError(b, te.ng.Close(context.Background()))
|
||||||
|
}()
|
||||||
|
|
||||||
cid := cidtest.ID()
|
cid := cidtest.ID()
|
||||||
d := pilorama.CIDDescriptor{CID: cid, Position: 0, Size: 1}
|
d := pilorama.CIDDescriptor{CID: cid, Position: 0, Size: 1}
|
||||||
treeID := "someTree"
|
treeID := "someTree"
|
||||||
|
|
Loading…
Reference in a new issue