forked from TrueCloudLab/frostfs-node
Evgenii Stratonikov
bdecfbc1be
Semantic patch (also, duplicate definitions are removed): ``` @@ var e identifier @@ -import "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard" -shard.e +e ``` Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package shard
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestShard_Inhume(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
t.Run("without write cache", func(t *testing.T) {
|
|
t.Parallel()
|
|
testShardInhume(t, false)
|
|
})
|
|
|
|
t.Run("with write cache", func(t *testing.T) {
|
|
t.Parallel()
|
|
testShardInhume(t, true)
|
|
})
|
|
}
|
|
|
|
func testShardInhume(t *testing.T, hasWriteCache bool) {
|
|
sh := newShard(t, hasWriteCache)
|
|
defer releaseShard(sh, t)
|
|
|
|
cnr := cidtest.ID()
|
|
|
|
obj := testutil.GenerateObjectWithCID(cnr)
|
|
testutil.AddAttribute(obj, "foo", "bar")
|
|
|
|
ts := testutil.GenerateObjectWithCID(cnr)
|
|
|
|
var putPrm PutPrm
|
|
putPrm.SetObject(obj)
|
|
|
|
var inhPrm InhumePrm
|
|
inhPrm.SetTarget(object.AddressOf(ts), object.AddressOf(obj))
|
|
|
|
var getPrm GetPrm
|
|
getPrm.SetAddress(object.AddressOf(obj))
|
|
|
|
_, err := sh.Put(context.Background(), putPrm)
|
|
require.NoError(t, err)
|
|
|
|
_, err = testGet(t, sh, getPrm, hasWriteCache)
|
|
require.NoError(t, err)
|
|
|
|
_, err = sh.Inhume(context.Background(), inhPrm)
|
|
require.NoError(t, err)
|
|
|
|
_, err = sh.Get(context.Background(), getPrm)
|
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
|
}
|