2021-09-13 13:38:58 +00:00
|
|
|
package shard
|
|
|
|
|
|
|
|
import (
|
2023-03-23 14:59:14 +00:00
|
|
|
"context"
|
2024-02-08 08:57:23 +00:00
|
|
|
"fmt"
|
2023-03-21 10:38:44 +00:00
|
|
|
"io/fs"
|
|
|
|
"math"
|
2021-09-13 13:38:58 +00:00
|
|
|
"os"
|
2022-02-02 13:28:08 +00:00
|
|
|
"path/filepath"
|
2023-05-19 15:06:20 +00:00
|
|
|
"sync/atomic"
|
2021-09-13 13:38:58 +00:00
|
|
|
"testing"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/fstree"
|
2023-03-21 10:38:44 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/teststore"
|
2023-03-07 13:38:26 +00:00
|
|
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
2023-12-22 09:58:20 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
2023-08-23 07:53:42 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger/test"
|
2023-08-04 11:14:07 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
2023-03-07 13:38:26 +00:00
|
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
|
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
|
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
|
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
|
|
|
objecttest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/test"
|
2021-09-13 13:38:58 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2023-03-21 10:38:44 +00:00
|
|
|
"go.etcd.io/bbolt"
|
2021-09-13 13:38:58 +00:00
|
|
|
)
|
|
|
|
|
2022-10-16 11:39:47 +00:00
|
|
|
type objAddr struct {
|
|
|
|
obj *objectSDK.Object
|
|
|
|
addr oid.Address
|
|
|
|
}
|
|
|
|
|
2022-06-27 08:06:01 +00:00
|
|
|
func TestShardOpen(t *testing.T) {
|
2023-05-05 11:08:10 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
2022-06-27 08:06:01 +00:00
|
|
|
dir := t.TempDir()
|
|
|
|
metaPath := filepath.Join(dir, "meta")
|
|
|
|
|
2023-03-21 10:38:44 +00:00
|
|
|
st := teststore.New(teststore.WithSubstorage(fstree.New(
|
|
|
|
fstree.WithDirNameLen(2),
|
|
|
|
fstree.WithPath(filepath.Join(dir, "blob")),
|
|
|
|
fstree.WithDepth(1)),
|
|
|
|
))
|
|
|
|
|
|
|
|
var allowedMode atomic.Int64
|
|
|
|
openFileMetabase := func(p string, f int, perm fs.FileMode) (*os.File, error) {
|
|
|
|
const modeMask = os.O_RDONLY | os.O_RDWR | os.O_WRONLY
|
|
|
|
if int64(f&modeMask) == allowedMode.Load() {
|
|
|
|
return os.OpenFile(p, f, perm)
|
|
|
|
}
|
|
|
|
return nil, fs.ErrPermission
|
|
|
|
}
|
|
|
|
|
2023-12-22 09:58:20 +00:00
|
|
|
wcOpts := []writecache.Option{
|
|
|
|
writecache.WithPath(filepath.Join(dir, "wc")),
|
2023-06-22 11:55:30 +00:00
|
|
|
}
|
|
|
|
|
2022-06-27 08:06:01 +00:00
|
|
|
newShard := func() *Shard {
|
|
|
|
return New(
|
2023-03-13 11:37:35 +00:00
|
|
|
WithID(NewIDFromBytes([]byte{})),
|
2024-01-09 08:37:41 +00:00
|
|
|
WithLogger(test.NewLogger(t)),
|
2022-06-27 08:06:01 +00:00
|
|
|
WithBlobStorOptions(
|
2022-07-11 12:34:17 +00:00
|
|
|
blobstor.WithStorages([]blobstor.SubStorage{
|
2023-03-21 10:38:44 +00:00
|
|
|
{Storage: st},
|
2022-07-11 12:34:17 +00:00
|
|
|
})),
|
2023-03-21 10:38:44 +00:00
|
|
|
WithMetaBaseOptions(
|
|
|
|
meta.WithPath(metaPath),
|
|
|
|
meta.WithEpochState(epochState{}),
|
|
|
|
meta.WithBoltDBOptions(&bbolt.Options{OpenFile: openFileMetabase}),
|
|
|
|
),
|
2022-06-27 08:06:01 +00:00
|
|
|
WithPiloramaOptions(
|
|
|
|
pilorama.WithPath(filepath.Join(dir, "pilorama"))),
|
|
|
|
WithWriteCache(true),
|
2023-06-22 11:55:30 +00:00
|
|
|
WithWriteCacheOptions(wcOpts))
|
2022-06-27 08:06:01 +00:00
|
|
|
}
|
|
|
|
|
2023-03-21 10:38:44 +00:00
|
|
|
allowedMode.Store(int64(os.O_RDWR))
|
|
|
|
|
2022-06-27 08:06:01 +00:00
|
|
|
sh := newShard()
|
2023-08-31 16:26:47 +00:00
|
|
|
require.NoError(t, sh.Open(context.Background()))
|
2023-03-23 14:59:14 +00:00
|
|
|
require.NoError(t, sh.Init(context.Background()))
|
2022-06-27 08:06:01 +00:00
|
|
|
require.Equal(t, mode.ReadWrite, sh.GetMode())
|
|
|
|
require.NoError(t, sh.Close())
|
|
|
|
|
|
|
|
// Metabase can be opened in read-only => start in ReadOnly mode.
|
2023-03-21 10:38:44 +00:00
|
|
|
allowedMode.Store(int64(os.O_RDONLY))
|
|
|
|
|
2022-06-27 08:06:01 +00:00
|
|
|
sh = newShard()
|
2023-08-31 16:26:47 +00:00
|
|
|
require.NoError(t, sh.Open(context.Background()))
|
2023-03-23 14:59:14 +00:00
|
|
|
require.NoError(t, sh.Init(context.Background()))
|
2022-06-27 08:06:01 +00:00
|
|
|
require.Equal(t, mode.ReadOnly, sh.GetMode())
|
|
|
|
require.Error(t, sh.SetMode(mode.ReadWrite))
|
|
|
|
require.Equal(t, mode.ReadOnly, sh.GetMode())
|
|
|
|
require.NoError(t, sh.Close())
|
|
|
|
|
|
|
|
// Metabase is corrupted => start in DegradedReadOnly mode.
|
2023-03-21 10:38:44 +00:00
|
|
|
allowedMode.Store(math.MaxInt64)
|
|
|
|
|
2022-06-27 08:06:01 +00:00
|
|
|
sh = newShard()
|
2023-08-31 16:26:47 +00:00
|
|
|
require.NoError(t, sh.Open(context.Background()))
|
2023-03-23 14:59:14 +00:00
|
|
|
require.NoError(t, sh.Init(context.Background()))
|
2022-06-27 08:06:01 +00:00
|
|
|
require.Equal(t, mode.DegradedReadOnly, sh.GetMode())
|
|
|
|
require.NoError(t, sh.Close())
|
|
|
|
}
|
|
|
|
|
2022-06-21 07:52:03 +00:00
|
|
|
func TestRefillMetabaseCorrupted(t *testing.T) {
|
2023-05-05 11:08:10 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
2022-06-21 07:52:03 +00:00
|
|
|
dir := t.TempDir()
|
|
|
|
|
2022-10-05 12:41:36 +00:00
|
|
|
fsTree := fstree.New(
|
|
|
|
fstree.WithDirNameLen(2),
|
|
|
|
fstree.WithPath(filepath.Join(dir, "blob")),
|
|
|
|
fstree.WithDepth(1))
|
2022-06-21 07:52:03 +00:00
|
|
|
blobOpts := []blobstor.Option{
|
2022-07-11 12:34:17 +00:00
|
|
|
blobstor.WithStorages([]blobstor.SubStorage{
|
|
|
|
{
|
2022-10-05 12:41:36 +00:00
|
|
|
Storage: fsTree,
|
2022-07-11 12:34:17 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
}
|
2022-06-21 07:52:03 +00:00
|
|
|
|
2024-03-12 14:36:26 +00:00
|
|
|
mm := NewMetricStore()
|
|
|
|
|
2022-06-21 07:52:03 +00:00
|
|
|
sh := New(
|
2023-04-12 14:01:29 +00:00
|
|
|
WithID(NewIDFromBytes([]byte{})),
|
2022-06-21 07:52:03 +00:00
|
|
|
WithBlobStorOptions(blobOpts...),
|
2022-06-09 08:09:18 +00:00
|
|
|
WithPiloramaOptions(pilorama.WithPath(filepath.Join(dir, "pilorama"))),
|
2024-03-12 14:36:26 +00:00
|
|
|
WithMetaBaseOptions(meta.WithPath(filepath.Join(dir, "meta")), meta.WithEpochState(epochState{})),
|
|
|
|
WithMetricsWriter(mm),
|
|
|
|
)
|
2023-08-31 16:26:47 +00:00
|
|
|
require.NoError(t, sh.Open(context.Background()))
|
2023-03-23 14:59:14 +00:00
|
|
|
require.NoError(t, sh.Init(context.Background()))
|
2022-06-21 07:52:03 +00:00
|
|
|
|
|
|
|
obj := objecttest.Object()
|
|
|
|
obj.SetType(objectSDK.TypeRegular)
|
|
|
|
obj.SetPayload([]byte{0, 1, 2, 3, 4, 5})
|
|
|
|
|
|
|
|
var putPrm PutPrm
|
2022-07-13 12:43:04 +00:00
|
|
|
putPrm.SetObject(obj)
|
2023-04-12 14:01:29 +00:00
|
|
|
_, err := sh.Put(context.Background(), putPrm)
|
2022-06-21 07:52:03 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, sh.Close())
|
|
|
|
|
|
|
|
addr := object.AddressOf(obj)
|
2024-02-08 08:57:23 +00:00
|
|
|
// This is copied from `fstree.treePath()` to avoid exporting function just for tests.
|
|
|
|
{
|
|
|
|
saddr := addr.Object().EncodeToString() + "." + addr.Container().EncodeToString()
|
|
|
|
p := fmt.Sprintf("%s/%s/%s", fsTree.RootPath, saddr[:2], saddr[2:])
|
|
|
|
require.NoError(t, os.WriteFile(p, []byte("not an object"), fsTree.Permissions))
|
|
|
|
}
|
2022-06-21 07:52:03 +00:00
|
|
|
|
|
|
|
sh = New(
|
2023-03-13 11:37:35 +00:00
|
|
|
WithID(NewIDFromBytes([]byte{})),
|
2022-06-21 07:52:03 +00:00
|
|
|
WithBlobStorOptions(blobOpts...),
|
2022-06-09 08:09:18 +00:00
|
|
|
WithPiloramaOptions(pilorama.WithPath(filepath.Join(dir, "pilorama"))),
|
2022-07-27 18:34:25 +00:00
|
|
|
WithMetaBaseOptions(meta.WithPath(filepath.Join(dir, "meta_new")), meta.WithEpochState(epochState{})),
|
2024-03-12 14:36:26 +00:00
|
|
|
WithRefillMetabase(true),
|
|
|
|
WithMetricsWriter(mm))
|
2023-08-31 16:26:47 +00:00
|
|
|
require.NoError(t, sh.Open(context.Background()))
|
2023-03-23 14:59:14 +00:00
|
|
|
require.NoError(t, sh.Init(context.Background()))
|
2022-06-21 07:52:03 +00:00
|
|
|
|
|
|
|
var getPrm GetPrm
|
2022-07-13 12:43:04 +00:00
|
|
|
getPrm.SetAddress(addr)
|
2023-03-13 11:37:35 +00:00
|
|
|
_, err = sh.Get(context.Background(), getPrm)
|
2023-08-04 11:14:07 +00:00
|
|
|
require.True(t, client.IsErrObjectNotFound(err))
|
2022-06-21 07:52:03 +00:00
|
|
|
require.NoError(t, sh.Close())
|
|
|
|
}
|
|
|
|
|
2021-09-13 13:38:58 +00:00
|
|
|
func TestRefillMetabase(t *testing.T) {
|
2023-05-05 11:08:10 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
2021-09-13 13:38:58 +00:00
|
|
|
p := t.Name()
|
|
|
|
|
|
|
|
defer os.RemoveAll(p)
|
|
|
|
|
|
|
|
blobOpts := []blobstor.Option{
|
2022-07-11 12:34:17 +00:00
|
|
|
blobstor.WithStorages([]blobstor.SubStorage{
|
|
|
|
{
|
|
|
|
Storage: fstree.New(
|
|
|
|
fstree.WithPath(filepath.Join(p, "blob")),
|
|
|
|
fstree.WithDepth(1)),
|
|
|
|
},
|
|
|
|
}),
|
2021-09-13 13:38:58 +00:00
|
|
|
}
|
|
|
|
|
2024-03-12 14:36:26 +00:00
|
|
|
mm := NewMetricStore()
|
|
|
|
|
2021-09-13 13:38:58 +00:00
|
|
|
sh := New(
|
2023-03-13 11:37:35 +00:00
|
|
|
WithID(NewIDFromBytes([]byte{})),
|
2021-09-13 13:38:58 +00:00
|
|
|
WithBlobStorOptions(blobOpts...),
|
|
|
|
WithMetaBaseOptions(
|
2022-02-02 13:28:08 +00:00
|
|
|
meta.WithPath(filepath.Join(p, "meta")),
|
2022-07-27 18:34:25 +00:00
|
|
|
meta.WithEpochState(epochState{}),
|
2021-09-13 13:38:58 +00:00
|
|
|
),
|
2022-06-09 08:09:18 +00:00
|
|
|
WithPiloramaOptions(
|
|
|
|
pilorama.WithPath(filepath.Join(p, "pilorama"))),
|
2024-03-12 14:36:26 +00:00
|
|
|
WithMetricsWriter(mm),
|
2021-09-13 13:38:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// open Blobstor
|
2023-08-31 16:26:47 +00:00
|
|
|
require.NoError(t, sh.Open(context.Background()))
|
2021-09-13 13:38:58 +00:00
|
|
|
|
|
|
|
// initialize Blobstor
|
2023-03-23 14:59:14 +00:00
|
|
|
require.NoError(t, sh.Init(context.Background()))
|
2021-09-13 13:38:58 +00:00
|
|
|
|
|
|
|
const objNum = 5
|
|
|
|
|
|
|
|
mObjs := make(map[string]objAddr)
|
2022-06-20 12:28:20 +00:00
|
|
|
locked := make([]oid.ID, 1, 2)
|
|
|
|
locked[0] = oidtest.ID()
|
|
|
|
cnrLocked := cidtest.ID()
|
2021-09-13 13:38:58 +00:00
|
|
|
for i := uint64(0); i < objNum; i++ {
|
2022-03-03 14:19:05 +00:00
|
|
|
obj := objecttest.Object()
|
|
|
|
obj.SetType(objectSDK.TypeRegular)
|
2021-09-13 13:38:58 +00:00
|
|
|
|
2022-06-20 12:28:20 +00:00
|
|
|
if len(locked) < 2 {
|
|
|
|
obj.SetContainerID(cnrLocked)
|
|
|
|
id, _ := obj.ID()
|
|
|
|
locked = append(locked, id)
|
|
|
|
}
|
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
addr := object.AddressOf(obj)
|
2021-09-13 13:38:58 +00:00
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
mObjs[addr.EncodeToString()] = objAddr{
|
2021-09-13 13:38:58 +00:00
|
|
|
obj: obj,
|
|
|
|
addr: addr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
tombObj := objecttest.Object()
|
|
|
|
tombObj.SetType(objectSDK.TypeTombstone)
|
2021-09-13 13:38:58 +00:00
|
|
|
|
|
|
|
tombstone := objecttest.Tombstone()
|
|
|
|
|
|
|
|
tombData, err := tombstone.Marshal()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
tombObj.SetPayload(tombData)
|
2021-09-13 13:38:58 +00:00
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
tombMembers := make([]oid.Address, 0, len(tombstone.Members()))
|
2021-09-13 13:38:58 +00:00
|
|
|
|
2022-03-15 12:11:35 +00:00
|
|
|
members := tombstone.Members()
|
|
|
|
for i := range tombstone.Members() {
|
2022-05-31 17:00:41 +00:00
|
|
|
var a oid.Address
|
|
|
|
a.SetObject(members[i])
|
2022-05-12 16:37:46 +00:00
|
|
|
cnr, _ := tombObj.ContainerID()
|
2022-05-31 17:00:41 +00:00
|
|
|
a.SetContainer(cnr)
|
2021-09-13 13:38:58 +00:00
|
|
|
|
|
|
|
tombMembers = append(tombMembers, a)
|
|
|
|
}
|
|
|
|
|
|
|
|
var putPrm PutPrm
|
|
|
|
|
|
|
|
for _, v := range mObjs {
|
2022-07-13 12:43:04 +00:00
|
|
|
putPrm.SetObject(v.obj)
|
2022-05-20 18:08:59 +00:00
|
|
|
|
2023-04-12 14:01:29 +00:00
|
|
|
_, err := sh.Put(context.Background(), putPrm)
|
2021-09-13 13:38:58 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
2022-07-13 12:43:04 +00:00
|
|
|
putPrm.SetObject(tombObj)
|
2022-05-20 18:08:59 +00:00
|
|
|
|
2023-04-12 14:01:29 +00:00
|
|
|
_, err = sh.Put(context.Background(), putPrm)
|
2021-09-13 13:38:58 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-06-20 12:28:20 +00:00
|
|
|
// LOCK object handling
|
|
|
|
var lock objectSDK.Lock
|
|
|
|
lock.WriteMembers(locked)
|
|
|
|
|
|
|
|
lockObj := objecttest.Object()
|
|
|
|
lockObj.SetContainerID(cnrLocked)
|
|
|
|
objectSDK.WriteLock(lockObj, lock)
|
|
|
|
|
2022-07-13 12:43:04 +00:00
|
|
|
putPrm.SetObject(lockObj)
|
2023-04-12 14:01:29 +00:00
|
|
|
_, err = sh.Put(context.Background(), putPrm)
|
2022-06-20 12:28:20 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
lockID, _ := lockObj.ID()
|
2023-04-12 14:01:29 +00:00
|
|
|
require.NoError(t, sh.Lock(context.Background(), cnrLocked, lockID, locked))
|
2022-06-20 12:28:20 +00:00
|
|
|
|
2022-05-20 18:08:59 +00:00
|
|
|
var inhumePrm InhumePrm
|
2022-07-13 12:43:04 +00:00
|
|
|
inhumePrm.SetTarget(object.AddressOf(tombObj), tombMembers...)
|
2022-05-20 18:08:59 +00:00
|
|
|
|
2023-04-04 11:40:01 +00:00
|
|
|
_, err = sh.Inhume(context.Background(), inhumePrm)
|
2021-09-13 13:38:58 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
var headPrm HeadPrm
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
checkObj := func(addr oid.Address, expObj *objectSDK.Object) {
|
2022-07-13 12:43:04 +00:00
|
|
|
headPrm.SetAddress(addr)
|
2022-05-20 18:08:59 +00:00
|
|
|
|
2023-03-13 11:37:35 +00:00
|
|
|
res, err := sh.Head(context.Background(), headPrm)
|
2021-09-13 13:38:58 +00:00
|
|
|
|
|
|
|
if expObj == nil {
|
2023-08-04 11:14:07 +00:00
|
|
|
require.True(t, client.IsErrObjectNotFound(err))
|
2021-09-13 13:38:58 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
2022-03-03 14:19:05 +00:00
|
|
|
require.Equal(t, expObj.CutPayload(), res.Object())
|
2021-09-13 13:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
checkAllObjs := func(exists bool) {
|
|
|
|
for _, v := range mObjs {
|
|
|
|
if exists {
|
|
|
|
checkObj(v.addr, v.obj)
|
|
|
|
} else {
|
|
|
|
checkObj(v.addr, nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
checkTombMembers := func(exists bool) {
|
|
|
|
for _, member := range tombMembers {
|
2022-07-13 12:43:04 +00:00
|
|
|
headPrm.SetAddress(member)
|
2022-05-20 18:08:59 +00:00
|
|
|
|
2023-03-13 11:37:35 +00:00
|
|
|
_, err := sh.Head(context.Background(), headPrm)
|
2021-09-13 13:38:58 +00:00
|
|
|
|
|
|
|
if exists {
|
2023-08-04 11:14:07 +00:00
|
|
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
2021-09-13 13:38:58 +00:00
|
|
|
} else {
|
2023-08-04 11:14:07 +00:00
|
|
|
require.True(t, client.IsErrObjectNotFound(err))
|
2021-09-13 13:38:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-20 12:28:20 +00:00
|
|
|
checkLocked := func(t *testing.T, cnr cid.ID, locked []oid.ID) {
|
|
|
|
var addr oid.Address
|
|
|
|
addr.SetContainer(cnr)
|
|
|
|
|
|
|
|
for i := range locked {
|
|
|
|
addr.SetObject(locked[i])
|
|
|
|
|
|
|
|
var prm InhumePrm
|
|
|
|
prm.MarkAsGarbage(addr)
|
|
|
|
|
2023-08-04 11:14:07 +00:00
|
|
|
var target *apistatus.ObjectLocked
|
2023-04-04 11:40:01 +00:00
|
|
|
_, err := sh.Inhume(context.Background(), prm)
|
2023-08-04 11:14:07 +00:00
|
|
|
require.ErrorAs(t, err, &target, "object %s should be locked", locked[i])
|
2022-06-20 12:28:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-13 13:38:58 +00:00
|
|
|
checkAllObjs(true)
|
2022-03-03 14:19:05 +00:00
|
|
|
checkObj(object.AddressOf(tombObj), tombObj)
|
2021-09-13 13:38:58 +00:00
|
|
|
checkTombMembers(true)
|
2022-06-20 12:28:20 +00:00
|
|
|
checkLocked(t, cnrLocked, locked)
|
2021-09-13 13:38:58 +00:00
|
|
|
|
2022-09-09 11:36:34 +00:00
|
|
|
c, err := sh.metaBase.ObjectCounters()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2023-12-04 14:35:11 +00:00
|
|
|
phyBefore := c.Phy
|
|
|
|
logicalBefore := c.Logic
|
2022-09-09 11:36:34 +00:00
|
|
|
|
2021-09-13 13:38:58 +00:00
|
|
|
err = sh.Close()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
sh = New(
|
2023-03-13 11:37:35 +00:00
|
|
|
WithID(NewIDFromBytes([]byte{})),
|
2021-09-13 13:38:58 +00:00
|
|
|
WithBlobStorOptions(blobOpts...),
|
|
|
|
WithMetaBaseOptions(
|
2022-02-02 13:28:08 +00:00
|
|
|
meta.WithPath(filepath.Join(p, "meta_restored")),
|
2022-07-27 18:34:25 +00:00
|
|
|
meta.WithEpochState(epochState{}),
|
2021-09-13 13:38:58 +00:00
|
|
|
),
|
2022-06-09 08:09:18 +00:00
|
|
|
WithPiloramaOptions(
|
|
|
|
pilorama.WithPath(filepath.Join(p, "pilorama_another"))),
|
2024-03-12 14:36:26 +00:00
|
|
|
WithMetricsWriter(mm),
|
2021-09-13 13:38:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// open Blobstor
|
2023-08-31 16:26:47 +00:00
|
|
|
require.NoError(t, sh.Open(context.Background()))
|
2021-09-13 13:38:58 +00:00
|
|
|
|
|
|
|
// initialize Blobstor
|
2023-03-23 14:59:14 +00:00
|
|
|
require.NoError(t, sh.Init(context.Background()))
|
2021-09-13 13:38:58 +00:00
|
|
|
|
|
|
|
defer sh.Close()
|
|
|
|
|
|
|
|
checkAllObjs(false)
|
2022-03-03 14:19:05 +00:00
|
|
|
checkObj(object.AddressOf(tombObj), nil)
|
2021-09-13 13:38:58 +00:00
|
|
|
checkTombMembers(false)
|
|
|
|
|
2023-04-12 14:01:29 +00:00
|
|
|
err = sh.refillMetabase(context.Background())
|
2021-09-13 13:38:58 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-09-09 11:36:34 +00:00
|
|
|
c, err = sh.metaBase.ObjectCounters()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2023-12-04 14:35:11 +00:00
|
|
|
require.Equal(t, phyBefore, c.Phy)
|
|
|
|
require.Equal(t, logicalBefore, c.Logic)
|
2022-09-09 11:36:34 +00:00
|
|
|
|
2021-09-13 13:38:58 +00:00
|
|
|
checkAllObjs(true)
|
2022-03-03 14:19:05 +00:00
|
|
|
checkObj(object.AddressOf(tombObj), tombObj)
|
2021-09-13 13:38:58 +00:00
|
|
|
checkTombMembers(true)
|
2022-06-20 12:28:20 +00:00
|
|
|
checkLocked(t, cnrLocked, locked)
|
2024-03-12 14:36:26 +00:00
|
|
|
require.Equal(t, int64(len(mObjs)+2), mm.refillCount) // 1 lock + 1 tomb
|
|
|
|
require.Equal(t, "completed", mm.refillStatus)
|
|
|
|
require.Equal(t, uint32(100), mm.refillPercent)
|
2021-09-13 13:38:58 +00:00
|
|
|
}
|