2020-12-01 13:58:34 +00:00
|
|
|
package shard_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
2022-03-17 08:03:58 +00:00
|
|
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
2021-11-10 07:08:33 +00:00
|
|
|
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
|
2020-12-01 13:58:34 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestShard_Inhume(t *testing.T) {
|
|
|
|
t.Run("without write cache", func(t *testing.T) {
|
2021-04-06 10:56:06 +00:00
|
|
|
testShardInhume(t, false)
|
2020-12-01 13:58:34 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("with write cache", func(t *testing.T) {
|
2021-04-06 10:56:06 +00:00
|
|
|
testShardInhume(t, true)
|
2020-12-01 13:58:34 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-04-06 10:56:06 +00:00
|
|
|
func testShardInhume(t *testing.T, hasWriteCache bool) {
|
|
|
|
sh := newShard(t, hasWriteCache)
|
|
|
|
defer releaseShard(sh, t)
|
|
|
|
|
2021-12-01 13:56:48 +00:00
|
|
|
cid := cidtest.ID()
|
2020-12-01 13:58:34 +00:00
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
obj := generateObjectWithCID(t, cid)
|
2020-12-01 13:58:34 +00:00
|
|
|
addAttribute(obj, "foo", "bar")
|
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
ts := generateObjectWithCID(t, cid)
|
2020-12-01 13:58:34 +00:00
|
|
|
|
|
|
|
putPrm := new(shard.PutPrm)
|
2022-03-03 14:19:05 +00:00
|
|
|
putPrm.WithObject(obj)
|
2020-12-01 13:58:34 +00:00
|
|
|
|
|
|
|
inhPrm := new(shard.InhumePrm)
|
2022-03-03 14:19:05 +00:00
|
|
|
inhPrm.WithTarget(object.AddressOf(ts), object.AddressOf(obj))
|
2020-12-01 13:58:34 +00:00
|
|
|
|
|
|
|
getPrm := new(shard.GetPrm)
|
2022-03-03 14:19:05 +00:00
|
|
|
getPrm.WithAddress(object.AddressOf(obj))
|
2020-12-01 13:58:34 +00:00
|
|
|
|
|
|
|
_, err := sh.Put(putPrm)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-04-06 10:56:06 +00:00
|
|
|
_, err = testGet(t, sh, getPrm, hasWriteCache)
|
2020-12-01 13:58:34 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = sh.Inhume(inhPrm)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = sh.Get(getPrm)
|
2022-03-17 08:03:58 +00:00
|
|
|
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
2020-12-01 13:58:34 +00:00
|
|
|
}
|