[#1085] shard/test: add object integrity check for Evacuate

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-01-18 17:07:30 +03:00 committed by LeL
parent c0f6c988f0
commit b432ec3a03

View file

@ -4,6 +4,7 @@ import (
"errors" "errors"
"io" "io"
"io/ioutil" "io/ioutil"
"math/rand"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -77,6 +78,7 @@ func testEvacuate(t *testing.T, objCount int, hasWriteCache bool) {
size = bsBigObjectSize - headerSize size = bsBigObjectSize - headerSize
} }
data := make([]byte, size) data := make([]byte, size)
rand.Read(data)
obj := generateRawObjectWithPayload(cid, data) obj := generateRawObjectWithPayload(cid, data)
objects[i] = obj.Object() objects[i] = obj.Object()
@ -212,7 +214,8 @@ func checkRestore(t *testing.T, sh *shard.Shard, prm *shard.RestorePrm, objects
require.Equal(t, len(objects), res.Count()) require.Equal(t, len(objects), res.Count())
for i := range objects { for i := range objects {
_, err := sh.Get(new(shard.GetPrm).WithAddress(objects[i].Address())) res, err := sh.Get(new(shard.GetPrm).WithAddress(objects[i].Address()))
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, objects[i], res.Object())
} }
} }