frostfs-node/pkg/local_object_storage/shard/shutdown_test.go
Evgenii Stratonikov d06425c852 [#1085] shard: allow to ignore errors in Evacuate
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-01-26 15:28:13 +03:00

52 lines
1.2 KiB
Go

package shard_test
import (
"math/rand"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/stretchr/testify/require"
)
func TestWriteCacheObjectLoss(t *testing.T) {
const (
smallSize = 1024
objCount = 100
)
objects := make([]*object.Object, objCount)
for i := range objects {
size := smallSize
//if i%2 == 0 {
size = smallSize / 2
//}
data := make([]byte, size)
rand.Read(data)
objects[i] = generateRawObjectWithPayload(cidtest.ID(), data).Object()
}
dir := t.TempDir()
wcOpts := []writecache.Option{
writecache.WithSmallObjectSize(smallSize),
writecache.WithMaxObjectSize(smallSize * 2)}
sh := newCustomShard(t, dir, true, wcOpts, nil)
for i := range objects {
_, err := sh.Put(new(shard.PutPrm).WithObject(objects[i]))
require.NoError(t, err)
}
require.NoError(t, sh.Close())
sh = newCustomShard(t, dir, true, wcOpts, nil)
defer releaseShard(sh, t)
for i := range objects {
_, err := sh.Get(new(shard.GetPrm).WithAddress(objects[i].Address()))
require.NoError(t, err, i)
}
}