forked from TrueCloudLab/frostfs-node
Compare commits
No commits in common. "023b90342cf9448cd9867a28dae04d7e90d4450c" and "5b7e4a51b76313a7502c65f048f4f695788a3039" have entirely different histories.
023b90342c
...
5b7e4a51b7
11 changed files with 28 additions and 36 deletions
|
@ -2,8 +2,8 @@ package blobovnicza
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"math/rand"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
|
@ -54,6 +54,8 @@ func testGet(t *testing.T, blz *Blobovnicza, addr oid.Address, expObj []byte, as
|
|||
}
|
||||
|
||||
func TestBlobovnicza(t *testing.T) {
|
||||
rand.Seed(1024)
|
||||
|
||||
p := "./test_blz"
|
||||
|
||||
sizeLim := uint64(256 * 1 << 10) // 256KB
|
||||
|
|
|
@ -2,8 +2,7 @@ package blobstortest
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
mrand "math/rand"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
objectCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
|
@ -54,9 +53,8 @@ func TestInfo(t *testing.T, cons Constructor, expectedType string, expectedPath
|
|||
func prepare(t *testing.T, count int, s common.Storage, min, max uint64) []objectDesc {
|
||||
objects := make([]objectDesc, count)
|
||||
|
||||
r := mrand.New(mrand.NewSource(0))
|
||||
for i := range objects {
|
||||
objects[i].obj = NewObject(min + uint64(r.Intn(int(max-min+1)))) // not too large
|
||||
objects[i].obj = NewObject(min + uint64(rand.Intn(int(max-min+1)))) // not too large
|
||||
objects[i].addr = objectCore.AddressOf(objects[i].obj)
|
||||
|
||||
raw, err := objects[i].obj.Marshal()
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math"
|
||||
mrand "math/rand"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -41,10 +39,9 @@ func Test_decodeList(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
})
|
||||
t.Run("random", func(t *testing.T) {
|
||||
r := mrand.New(mrand.NewSource(time.Now().Unix()))
|
||||
expected := make([][]byte, 20)
|
||||
for i := range expected {
|
||||
expected[i] = make([]byte, r.Uint32()%10)
|
||||
expected[i] = make([]byte, rand.Uint32()%10)
|
||||
rand.Read(expected[i])
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,12 @@ package pilorama
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
mrand "math/rand"
|
||||
"math/rand"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
cidSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
|
@ -769,10 +767,9 @@ func prepareRandomTree(nodeCount, opCount int) []Move {
|
|||
rand.Read(ops[i].Meta.Items[1].Value)
|
||||
}
|
||||
|
||||
r := mrand.New(mrand.NewSource(time.Now().Unix()))
|
||||
for i := nodeCount; i < len(ops); i++ {
|
||||
ops[i] = Move{
|
||||
Parent: r.Uint64() % uint64(nodeCount+12),
|
||||
Parent: rand.Uint64() % uint64(nodeCount+12),
|
||||
Meta: Meta{
|
||||
Time: Timestamp(i + nodeCount),
|
||||
Items: []KeyValue{
|
||||
|
@ -780,9 +777,9 @@ func prepareRandomTree(nodeCount, opCount int) []Move {
|
|||
{Value: make([]byte, 10)},
|
||||
},
|
||||
},
|
||||
Child: r.Uint64() % uint64(nodeCount+10),
|
||||
Child: rand.Uint64() % uint64(nodeCount+10),
|
||||
}
|
||||
if r.Uint32()%5 == 0 {
|
||||
if rand.Uint32()%5 == 0 {
|
||||
ops[i].Parent = TrashID
|
||||
}
|
||||
rand.Read(ops[i].Meta.Items[1].Value)
|
||||
|
@ -816,7 +813,7 @@ func compareForests(t *testing.T, expected, actual Forest, cid cidSDK.ID, treeID
|
|||
}
|
||||
|
||||
func testForestTreeParallelApply(t *testing.T, constructor func(t testing.TB, _ ...Option) Forest, batchSize, opCount, iterCount int) {
|
||||
r := mrand.New(mrand.NewSource(42))
|
||||
rand.Seed(42)
|
||||
|
||||
const nodeCount = 5
|
||||
|
||||
|
@ -832,7 +829,7 @@ func testForestTreeParallelApply(t *testing.T, constructor func(t testing.TB, _
|
|||
|
||||
for i := 0; i < iterCount; i++ {
|
||||
// Shuffle random operations, leave initialization in place.
|
||||
r.Shuffle(len(ops), func(i, j int) { ops[i], ops[j] = ops[j], ops[i] })
|
||||
rand.Shuffle(len(ops), func(i, j int) { ops[i], ops[j] = ops[j], ops[i] })
|
||||
|
||||
actual := constructor(t, WithMaxBatchSize(batchSize))
|
||||
wg := new(sync.WaitGroup)
|
||||
|
@ -858,7 +855,7 @@ func testForestTreeParallelApply(t *testing.T, constructor func(t testing.TB, _
|
|||
}
|
||||
|
||||
func testForestTreeApplyRandom(t *testing.T, constructor func(t testing.TB, _ ...Option) Forest) {
|
||||
r := mrand.New(mrand.NewSource(42))
|
||||
rand.Seed(42)
|
||||
|
||||
const (
|
||||
nodeCount = 5
|
||||
|
@ -878,7 +875,7 @@ func testForestTreeApplyRandom(t *testing.T, constructor func(t testing.TB, _ ..
|
|||
const iterCount = 200
|
||||
for i := 0; i < iterCount; i++ {
|
||||
// Shuffle random operations, leave initialization in place.
|
||||
r.Shuffle(len(ops), func(i, j int) { ops[i], ops[j] = ops[j], ops[i] })
|
||||
rand.Shuffle(len(ops), func(i, j int) { ops[i], ops[j] = ops[j], ops[i] })
|
||||
|
||||
actual := constructor(t)
|
||||
for i := range ops {
|
||||
|
@ -900,18 +897,17 @@ func BenchmarkApplySequential(b *testing.B) {
|
|||
b.Run(providers[i].name, func(b *testing.B) {
|
||||
for _, bs := range batchSizes {
|
||||
b.Run("batchsize="+strconv.Itoa(bs), func(b *testing.B) {
|
||||
r := mrand.New(mrand.NewSource(time.Now().Unix()))
|
||||
s := providers[i].construct(b, WithMaxBatchSize(bs))
|
||||
benchmarkApply(b, s, func(opCount int) []Move {
|
||||
ops := make([]Move, opCount)
|
||||
for i := range ops {
|
||||
ops[i] = Move{
|
||||
Parent: uint64(r.Intn(benchNodeCount)),
|
||||
Parent: uint64(rand.Intn(benchNodeCount)),
|
||||
Meta: Meta{
|
||||
Time: Timestamp(i),
|
||||
Items: []KeyValue{{Value: []byte{0, 1, 2, 3, 4}}},
|
||||
},
|
||||
Child: uint64(r.Intn(benchNodeCount)),
|
||||
Child: uint64(rand.Intn(benchNodeCount)),
|
||||
}
|
||||
}
|
||||
return ops
|
||||
|
@ -934,18 +930,17 @@ func BenchmarkApplyReorderLast(b *testing.B) {
|
|||
b.Run(providers[i].name, func(b *testing.B) {
|
||||
for _, bs := range batchSizes {
|
||||
b.Run("batchsize="+strconv.Itoa(bs), func(b *testing.B) {
|
||||
r := mrand.New(mrand.NewSource(time.Now().Unix()))
|
||||
s := providers[i].construct(b, WithMaxBatchSize(bs))
|
||||
benchmarkApply(b, s, func(opCount int) []Move {
|
||||
ops := make([]Move, opCount)
|
||||
for i := range ops {
|
||||
ops[i] = Move{
|
||||
Parent: uint64(r.Intn(benchNodeCount)),
|
||||
Parent: uint64(rand.Intn(benchNodeCount)),
|
||||
Meta: Meta{
|
||||
Time: Timestamp(i),
|
||||
Items: []KeyValue{{Value: []byte{0, 1, 2, 3, 4}}},
|
||||
},
|
||||
Child: uint64(r.Intn(benchNodeCount)),
|
||||
Child: uint64(rand.Intn(benchNodeCount)),
|
||||
}
|
||||
if i != 0 && i%blockSize == 0 {
|
||||
for j := 0; j < blockSize/2; j++ {
|
||||
|
@ -962,6 +957,8 @@ func BenchmarkApplyReorderLast(b *testing.B) {
|
|||
}
|
||||
|
||||
func benchmarkApply(b *testing.B, s Forest, genFunc func(int) []Move) {
|
||||
rand.Seed(42)
|
||||
|
||||
ops := genFunc(b.N)
|
||||
cid := cidtest.ID()
|
||||
treeID := "version"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package pilorama
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
|
@ -2,7 +2,7 @@ package shard_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package util_test
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util"
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
badgeroptions "github.com/dgraph-io/badger/v4/options"
|
||||
)
|
||||
|
||||
// OpenDB opens a badger instance for write-cache. Opens in read-only mode if ro is true.
|
||||
|
@ -13,7 +12,6 @@ func OpenDB(p string, ro bool, l *logger.Logger) (*badger.DB, error) {
|
|||
return badger.Open(badger.DefaultOptions(p).
|
||||
WithReadOnly(ro).
|
||||
WithSyncWrites(true).
|
||||
WithCompression(badgeroptions.None).
|
||||
WithLoggingLevel(badger.ERROR).
|
||||
WithLogger(badgerLoggerWrapper{l}))
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@ import (
|
|||
)
|
||||
|
||||
func TestInitEndpoints(t *testing.T) {
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
ee := make([]Endpoint, 100)
|
||||
for i := range ee {
|
||||
ee[i].Priority = r.Int()
|
||||
ee[i].Priority = rand.Int()
|
||||
}
|
||||
|
||||
var eeInternal endpoints
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
|
|
Loading…
Reference in a new issue