2021-02-16 07:57:43 +00:00
|
|
|
package meta_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
2021-02-16 07:57:43 +00:00
|
|
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
2022-05-31 17:00:41 +00:00
|
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
|
|
|
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
|
2021-02-16 07:57:43 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-04-15 10:58:10 +00:00
|
|
|
func TestDB_IterateDeletedObjects_EmptyDB(t *testing.T) {
|
|
|
|
db := newDB(t)
|
|
|
|
|
|
|
|
var counter int
|
2022-05-20 16:48:14 +00:00
|
|
|
var iterGravePRM meta.GraveyardIterationPrm
|
2021-04-15 10:58:10 +00:00
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
iterGravePRM.SetHandler(func(garbage meta.TombstonedObject) error {
|
2021-04-15 10:58:10 +00:00
|
|
|
counter++
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err := db.IterateOverGraveyard(iterGravePRM)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Zero(t, counter)
|
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var iterGCPRM meta.GarbageIterationPrm
|
|
|
|
iterGCPRM.SetHandler(func(garbage meta.GarbageObject) error {
|
2021-04-15 10:58:10 +00:00
|
|
|
counter++
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGarbage(iterGCPRM)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Zero(t, counter)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDB_Iterate_OffsetNotFound(t *testing.T) {
|
|
|
|
db := newDB(t)
|
|
|
|
|
|
|
|
obj1 := generateObject(t)
|
|
|
|
obj2 := generateObject(t)
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
var addr1 oid.Address
|
|
|
|
err := addr1.DecodeString("AUSF6rhReoAdPVKYUZWW9o2LbtTvekn54B3JXi7pdzmn/2daLhLB7yVXbjBaKkckkuvjX22BxRYuSHy9RPxuH9PZS")
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
var addr2 oid.Address
|
|
|
|
err = addr2.DecodeString("CwYYr6sFLU1zK6DeBTVd8SReADUoxYobUhSrxgXYxCVn/ANYbnJoQqdjmU5Dhk3LkxYj5E9nJHQFf8LjTEcap9TxM")
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
var addr3 oid.Address
|
|
|
|
err = addr3.DecodeString("6ay4GfhR9RgN28d5ufg63toPetkYHGcpcW7G3b7QWSek/ANYbnJoQqdjmU5Dhk3LkxYj5E9nJHQFf8LjTEcap9TxM")
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
obj1.SetContainerID(addr1.Container())
|
|
|
|
obj1.SetID(addr1.Object())
|
2022-05-12 16:37:46 +00:00
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
obj2.SetContainerID(addr2.Container())
|
|
|
|
obj2.SetID(addr2.Object())
|
2021-04-15 10:58:10 +00:00
|
|
|
|
|
|
|
err = putBig(db, obj1)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var inhumePrm meta.InhumePrm
|
2022-07-12 14:59:37 +00:00
|
|
|
inhumePrm.SetAddresses(object.AddressOf(obj1))
|
|
|
|
inhumePrm.SetGCMark()
|
2022-05-20 16:48:14 +00:00
|
|
|
|
|
|
|
_, err = db.Inhume(inhumePrm)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
var counter int
|
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var iterGCPRM meta.GarbageIterationPrm
|
|
|
|
iterGCPRM.SetOffset(object.AddressOf(obj2))
|
|
|
|
iterGCPRM.SetHandler(func(garbage meta.GarbageObject) error {
|
2022-05-31 17:00:41 +00:00
|
|
|
require.Equal(t, garbage.Address(), addr1)
|
2021-04-15 10:58:10 +00:00
|
|
|
counter++
|
|
|
|
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGarbage(iterGCPRM)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// the second object would be put after the
|
|
|
|
// first, so it is expected that iteration
|
|
|
|
// will not receive the first object
|
|
|
|
require.Equal(t, 0, counter)
|
|
|
|
|
|
|
|
iterGCPRM.SetOffset(addr3)
|
2022-05-20 16:48:14 +00:00
|
|
|
iterGCPRM.SetHandler(func(garbage meta.GarbageObject) error {
|
2022-05-31 17:00:41 +00:00
|
|
|
require.Equal(t, garbage.Address(), addr1)
|
2021-04-15 10:58:10 +00:00
|
|
|
counter++
|
|
|
|
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGarbage(iterGCPRM)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// the third object would be put before the
|
|
|
|
// first, so it is expected that iteration
|
|
|
|
// will receive the first object
|
|
|
|
require.Equal(t, 1, counter)
|
|
|
|
}
|
|
|
|
|
2021-04-08 14:19:31 +00:00
|
|
|
func TestDB_IterateDeletedObjects(t *testing.T) {
|
2021-02-16 07:57:43 +00:00
|
|
|
db := newDB(t)
|
|
|
|
|
2021-04-15 10:58:10 +00:00
|
|
|
// generate and put 4 objects
|
2022-03-03 14:19:05 +00:00
|
|
|
obj1 := generateObject(t)
|
|
|
|
obj2 := generateObject(t)
|
2021-04-08 14:19:31 +00:00
|
|
|
obj3 := generateObject(t)
|
|
|
|
obj4 := generateObject(t)
|
2021-02-16 07:57:43 +00:00
|
|
|
|
|
|
|
var err error
|
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
err = putBig(db, obj1)
|
2021-02-16 07:57:43 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
err = putBig(db, obj2)
|
2021-02-16 07:57:43 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-04-08 14:19:31 +00:00
|
|
|
err = putBig(db, obj3)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = putBig(db, obj4)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var inhumePrm meta.InhumePrm
|
2021-02-16 07:57:43 +00:00
|
|
|
|
|
|
|
// inhume with tombstone
|
2022-05-31 17:00:41 +00:00
|
|
|
addrTombstone := oidtest.Address()
|
2021-02-16 07:57:43 +00:00
|
|
|
|
2022-07-12 14:59:37 +00:00
|
|
|
inhumePrm.SetAddresses(object.AddressOf(obj1), object.AddressOf(obj2))
|
|
|
|
inhumePrm.SetTombstoneAddress(addrTombstone)
|
2022-05-20 16:48:14 +00:00
|
|
|
|
|
|
|
_, err = db.Inhume(inhumePrm)
|
2021-02-16 07:57:43 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-07-12 14:59:37 +00:00
|
|
|
inhumePrm.SetAddresses(object.AddressOf(obj3), object.AddressOf(obj4))
|
|
|
|
inhumePrm.SetGCMark()
|
2022-05-20 16:48:14 +00:00
|
|
|
|
2021-02-16 07:57:43 +00:00
|
|
|
// inhume with GC mark
|
2022-05-20 16:48:14 +00:00
|
|
|
_, err = db.Inhume(inhumePrm)
|
2022-04-26 15:23:24 +00:00
|
|
|
require.NoError(t, err)
|
2021-02-16 07:57:43 +00:00
|
|
|
|
|
|
|
var (
|
|
|
|
counterAll int
|
2022-05-31 17:00:41 +00:00
|
|
|
buriedTS, buriedGC []oid.Address
|
2021-02-16 07:57:43 +00:00
|
|
|
)
|
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var iterGravePRM meta.GraveyardIterationPrm
|
|
|
|
iterGravePRM.SetHandler(func(tomstoned meta.TombstonedObject) error {
|
2022-05-31 17:00:41 +00:00
|
|
|
require.Equal(t, addrTombstone, tomstoned.Tombstone())
|
2021-04-15 10:58:10 +00:00
|
|
|
|
|
|
|
buriedTS = append(buriedTS, tomstoned.Address())
|
2021-04-08 14:19:31 +00:00
|
|
|
counterAll++
|
|
|
|
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
2021-04-15 10:58:10 +00:00
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
err = db.IterateOverGraveyard(iterGravePRM)
|
|
|
|
require.NoError(t, err)
|
2021-02-16 07:57:43 +00:00
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var iterGCPRM meta.GarbageIterationPrm
|
|
|
|
iterGCPRM.SetHandler(func(garbage meta.GarbageObject) error {
|
2021-04-15 10:58:10 +00:00
|
|
|
buriedGC = append(buriedGC, garbage.Address())
|
2021-02-16 07:57:43 +00:00
|
|
|
counterAll++
|
|
|
|
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGarbage(iterGCPRM)
|
2021-02-16 07:57:43 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-04-08 17:06:13 +00:00
|
|
|
// objects covered with a tombstone
|
|
|
|
// also receive GS mark
|
2022-05-31 17:00:41 +00:00
|
|
|
garbageExpected := []oid.Address{
|
2021-04-08 17:06:13 +00:00
|
|
|
object.AddressOf(obj1), object.AddressOf(obj2),
|
|
|
|
object.AddressOf(obj3), object.AddressOf(obj4),
|
|
|
|
}
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
graveyardExpected := []oid.Address{
|
2021-04-08 17:06:13 +00:00
|
|
|
object.AddressOf(obj1), object.AddressOf(obj2),
|
|
|
|
}
|
|
|
|
|
|
|
|
require.Equal(t, len(garbageExpected)+len(graveyardExpected), counterAll)
|
2022-04-26 15:27:22 +00:00
|
|
|
require.ElementsMatch(t, graveyardExpected, buriedTS)
|
|
|
|
require.ElementsMatch(t, garbageExpected, buriedGC)
|
2021-04-08 14:19:31 +00:00
|
|
|
}
|
|
|
|
|
2021-04-15 10:58:10 +00:00
|
|
|
func TestDB_IterateOverGraveyard_Offset(t *testing.T) {
|
|
|
|
db := newDB(t)
|
|
|
|
|
|
|
|
// generate and put 4 objects
|
|
|
|
obj1 := generateObject(t)
|
|
|
|
obj2 := generateObject(t)
|
|
|
|
obj3 := generateObject(t)
|
|
|
|
obj4 := generateObject(t)
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
err = putBig(db, obj1)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = putBig(db, obj2)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = putBig(db, obj3)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = putBig(db, obj4)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// inhume with tombstone
|
2022-05-31 17:00:41 +00:00
|
|
|
addrTombstone := oidtest.Address()
|
2021-04-15 10:58:10 +00:00
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var inhumePrm meta.InhumePrm
|
2022-07-12 14:59:37 +00:00
|
|
|
inhumePrm.SetAddresses(
|
2022-05-20 16:48:14 +00:00
|
|
|
object.AddressOf(obj1), object.AddressOf(obj2),
|
|
|
|
object.AddressOf(obj3), object.AddressOf(obj4))
|
2022-07-12 14:59:37 +00:00
|
|
|
inhumePrm.SetTombstoneAddress(addrTombstone)
|
2022-05-20 16:48:14 +00:00
|
|
|
|
|
|
|
_, err = db.Inhume(inhumePrm)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
expectedGraveyard := []oid.Address{
|
2021-04-15 10:58:10 +00:00
|
|
|
object.AddressOf(obj1), object.AddressOf(obj2),
|
|
|
|
object.AddressOf(obj3), object.AddressOf(obj4),
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
counter int
|
|
|
|
firstIterationSize = len(expectedGraveyard) / 2
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
gotGraveyard []oid.Address
|
2021-04-15 10:58:10 +00:00
|
|
|
)
|
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var iterGraveyardPrm meta.GraveyardIterationPrm
|
|
|
|
iterGraveyardPrm.SetHandler(func(tombstoned meta.TombstonedObject) error {
|
2022-05-31 17:00:41 +00:00
|
|
|
require.Equal(t, addrTombstone, tombstoned.Tombstone())
|
2021-04-15 10:58:10 +00:00
|
|
|
|
|
|
|
gotGraveyard = append(gotGraveyard, tombstoned.Address())
|
|
|
|
|
|
|
|
counter++
|
|
|
|
if counter == firstIterationSize {
|
|
|
|
return meta.ErrInterruptIterator
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGraveyard(iterGraveyardPrm)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, firstIterationSize, counter)
|
|
|
|
require.Equal(t, firstIterationSize, len(gotGraveyard))
|
|
|
|
|
|
|
|
// last received address is an offset
|
|
|
|
offset := gotGraveyard[len(gotGraveyard)-1]
|
|
|
|
iterGraveyardPrm.SetOffset(offset)
|
2022-05-20 16:48:14 +00:00
|
|
|
iterGraveyardPrm.SetHandler(func(tombstoned meta.TombstonedObject) error {
|
2022-05-31 17:00:41 +00:00
|
|
|
require.Equal(t, addrTombstone, tombstoned.Tombstone())
|
2021-04-15 10:58:10 +00:00
|
|
|
|
|
|
|
gotGraveyard = append(gotGraveyard, tombstoned.Address())
|
|
|
|
counter++
|
|
|
|
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGraveyard(iterGraveyardPrm)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, len(expectedGraveyard), counter)
|
2022-04-26 15:27:22 +00:00
|
|
|
require.ElementsMatch(t, gotGraveyard, expectedGraveyard)
|
2021-04-15 10:58:10 +00:00
|
|
|
|
|
|
|
// last received object (last in db) as offset
|
|
|
|
// should lead to no iteration at all
|
|
|
|
offset = gotGraveyard[len(gotGraveyard)-1]
|
|
|
|
iterGraveyardPrm.SetOffset(offset)
|
|
|
|
iWasCalled := false
|
2022-05-20 16:48:14 +00:00
|
|
|
iterGraveyardPrm.SetHandler(func(tombstoned meta.TombstonedObject) error {
|
2021-04-15 10:58:10 +00:00
|
|
|
iWasCalled = true
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGraveyard(iterGraveyardPrm)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.False(t, iWasCalled)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDB_IterateOverGarbage_Offset(t *testing.T) {
|
|
|
|
db := newDB(t)
|
|
|
|
|
|
|
|
// generate and put 4 objects
|
|
|
|
obj1 := generateObject(t)
|
|
|
|
obj2 := generateObject(t)
|
|
|
|
obj3 := generateObject(t)
|
|
|
|
obj4 := generateObject(t)
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
err = putBig(db, obj1)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = putBig(db, obj2)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = putBig(db, obj3)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = putBig(db, obj4)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var inhumePrm meta.InhumePrm
|
2022-07-12 14:59:37 +00:00
|
|
|
inhumePrm.SetAddresses(
|
2022-05-20 16:48:14 +00:00
|
|
|
object.AddressOf(obj1), object.AddressOf(obj2),
|
|
|
|
object.AddressOf(obj3), object.AddressOf(obj4))
|
2022-07-12 14:59:37 +00:00
|
|
|
inhumePrm.SetGCMark()
|
2021-04-15 10:58:10 +00:00
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
_, err = db.Inhume(inhumePrm)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
expectedGarbage := []oid.Address{
|
2021-04-15 10:58:10 +00:00
|
|
|
object.AddressOf(obj1), object.AddressOf(obj2),
|
|
|
|
object.AddressOf(obj3), object.AddressOf(obj4),
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
counter int
|
|
|
|
firstIterationSize = len(expectedGarbage) / 2
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
gotGarbage []oid.Address
|
2021-04-15 10:58:10 +00:00
|
|
|
)
|
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var iterGarbagePrm meta.GarbageIterationPrm
|
|
|
|
iterGarbagePrm.SetHandler(func(garbage meta.GarbageObject) error {
|
2021-04-15 10:58:10 +00:00
|
|
|
gotGarbage = append(gotGarbage, garbage.Address())
|
|
|
|
|
|
|
|
counter++
|
|
|
|
if counter == firstIterationSize {
|
|
|
|
return meta.ErrInterruptIterator
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGarbage(iterGarbagePrm)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, firstIterationSize, counter)
|
|
|
|
require.Equal(t, firstIterationSize, len(gotGarbage))
|
|
|
|
|
|
|
|
// last received address is an offset
|
|
|
|
offset := gotGarbage[len(gotGarbage)-1]
|
|
|
|
iterGarbagePrm.SetOffset(offset)
|
2022-05-20 16:48:14 +00:00
|
|
|
iterGarbagePrm.SetHandler(func(garbage meta.GarbageObject) error {
|
2021-04-15 10:58:10 +00:00
|
|
|
gotGarbage = append(gotGarbage, garbage.Address())
|
|
|
|
counter++
|
|
|
|
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGarbage(iterGarbagePrm)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, len(expectedGarbage), counter)
|
2022-04-26 15:27:22 +00:00
|
|
|
require.ElementsMatch(t, gotGarbage, expectedGarbage)
|
2021-04-15 10:58:10 +00:00
|
|
|
|
|
|
|
// last received object (last in db) as offset
|
|
|
|
// should lead to no iteration at all
|
|
|
|
offset = gotGarbage[len(gotGarbage)-1]
|
|
|
|
iterGarbagePrm.SetOffset(offset)
|
|
|
|
iWasCalled := false
|
2022-05-20 16:48:14 +00:00
|
|
|
iterGarbagePrm.SetHandler(func(garbage meta.GarbageObject) error {
|
2021-04-15 10:58:10 +00:00
|
|
|
iWasCalled = true
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGarbage(iterGarbagePrm)
|
2021-04-15 10:58:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.False(t, iWasCalled)
|
|
|
|
}
|
|
|
|
|
2022-04-18 18:13:35 +00:00
|
|
|
func TestDB_DropGraves(t *testing.T) {
|
|
|
|
db := newDB(t)
|
|
|
|
|
|
|
|
// generate and put 2 objects
|
|
|
|
obj1 := generateObject(t)
|
|
|
|
obj2 := generateObject(t)
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
err = putBig(db, obj1)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = putBig(db, obj2)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// inhume with tombstone
|
2022-05-31 17:00:41 +00:00
|
|
|
addrTombstone := oidtest.Address()
|
2022-04-18 18:13:35 +00:00
|
|
|
|
2022-05-20 16:48:14 +00:00
|
|
|
var inhumePrm meta.InhumePrm
|
2022-07-12 14:59:37 +00:00
|
|
|
inhumePrm.SetAddresses(object.AddressOf(obj1), object.AddressOf(obj2))
|
|
|
|
inhumePrm.SetTombstoneAddress(addrTombstone)
|
2022-05-20 16:48:14 +00:00
|
|
|
|
|
|
|
_, err = db.Inhume(inhumePrm)
|
2022-04-18 18:13:35 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
buriedTS := make([]meta.TombstonedObject, 0)
|
2022-05-20 16:48:14 +00:00
|
|
|
var iterGravePRM meta.GraveyardIterationPrm
|
2022-04-18 18:13:35 +00:00
|
|
|
var counter int
|
2022-05-20 16:48:14 +00:00
|
|
|
iterGravePRM.SetHandler(func(tomstoned meta.TombstonedObject) error {
|
2022-04-18 18:13:35 +00:00
|
|
|
buriedTS = append(buriedTS, tomstoned)
|
|
|
|
counter++
|
|
|
|
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGraveyard(iterGravePRM)
|
2022-04-18 18:13:35 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 2, counter)
|
|
|
|
|
|
|
|
err = db.DropGraves(buriedTS)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
counter = 0
|
2022-05-20 16:48:14 +00:00
|
|
|
iterGravePRM.SetHandler(func(_ meta.TombstonedObject) error {
|
2022-04-18 18:13:35 +00:00
|
|
|
counter++
|
|
|
|
return nil
|
2022-05-20 16:48:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
err = db.IterateOverGraveyard(iterGravePRM)
|
2022-04-18 18:13:35 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Zero(t, counter)
|
|
|
|
}
|