2020-12-01 13:58:34 +00:00
|
|
|
package shard_test
|
|
|
|
|
|
|
|
import (
|
2023-04-04 11:40:01 +00:00
|
|
|
"context"
|
2020-12-01 13:58:34 +00:00
|
|
|
"testing"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
2023-03-20 14:10:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
|
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
|
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-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)
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
cnr := cidtest.ID()
|
2020-12-01 13:58:34 +00:00
|
|
|
|
2023-03-20 14:10:26 +00:00
|
|
|
obj := testutil.GenerateObjectWithCID(cnr)
|
|
|
|
testutil.AddAttribute(obj, "foo", "bar")
|
2020-12-01 13:58:34 +00:00
|
|
|
|
2023-03-20 14:10:26 +00:00
|
|
|
ts := testutil.GenerateObjectWithCID(cnr)
|
2020-12-01 13:58:34 +00:00
|
|
|
|
2022-05-20 18:08:59 +00:00
|
|
|
var putPrm shard.PutPrm
|
2022-07-13 12:43:04 +00:00
|
|
|
putPrm.SetObject(obj)
|
2020-12-01 13:58:34 +00:00
|
|
|
|
2022-05-20 18:08:59 +00:00
|
|
|
var inhPrm shard.InhumePrm
|
2022-07-13 12:43:04 +00:00
|
|
|
inhPrm.SetTarget(object.AddressOf(ts), object.AddressOf(obj))
|
2020-12-01 13:58:34 +00:00
|
|
|
|
2022-05-20 18:08:59 +00:00
|
|
|
var getPrm shard.GetPrm
|
2022-07-13 12:43:04 +00:00
|
|
|
getPrm.SetAddress(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)
|
|
|
|
|
2023-04-04 11:40:01 +00:00
|
|
|
_, err = sh.Inhume(context.Background(), inhPrm)
|
2020-12-01 13:58:34 +00:00
|
|
|
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
|
|
|
}
|