forked from TrueCloudLab/frostfs-node
Dmitrii Stepanov
76268e3ea2
Target container ID is taken from tombstone: cmd/frostfs-node/object.go:507 Also object of type `TOMBSTONE` contains objectID, so tombstone and tombstoned object must have the same containerID. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
package meta_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestReset(t *testing.T) {
|
|
db := newDB(t)
|
|
defer func() { require.NoError(t, db.Close()) }()
|
|
|
|
err := db.Reset()
|
|
require.NoError(t, err)
|
|
|
|
obj := testutil.GenerateObject()
|
|
addr := object.AddressOf(obj)
|
|
|
|
addrToInhume := oidtest.Address()
|
|
|
|
assertExists := func(addr oid.Address, expExists bool, assertErr func(error) bool) {
|
|
exists, err := metaExists(db, addr)
|
|
if assertErr != nil {
|
|
require.True(t, assertErr(err))
|
|
} else {
|
|
require.NoError(t, err)
|
|
}
|
|
require.Equal(t, expExists, exists)
|
|
}
|
|
|
|
assertExists(addr, false, nil)
|
|
assertExists(addrToInhume, false, nil)
|
|
|
|
err = putBig(db, obj)
|
|
require.NoError(t, err)
|
|
|
|
err = metaInhume(db, addrToInhume, oidtest.ID())
|
|
require.NoError(t, err)
|
|
|
|
assertExists(addr, true, nil)
|
|
assertExists(addrToInhume, false, client.IsErrObjectAlreadyRemoved)
|
|
|
|
err = db.Reset()
|
|
require.NoError(t, err)
|
|
|
|
assertExists(addr, false, nil)
|
|
assertExists(addr, false, nil)
|
|
}
|
|
|
|
func metaExists(db *meta.DB, addr oid.Address) (bool, error) {
|
|
var existsPrm meta.ExistsPrm
|
|
existsPrm.SetAddress(addr)
|
|
|
|
res, err := db.Exists(context.Background(), existsPrm)
|
|
return res.Exists(), err
|
|
}
|