forked from TrueCloudLab/frostfs-node
[#1634] node: Do not return expired objects
If an object has not been marked for removal by the GC in the current epoch yet but has already expired, respond with `ErrObjectNotFound` api status. Also, optimize shard iteration: a node must stop any iteration if the object is found but gonna be removed soon. All the checks are performed by the Metabase. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
9aba0ba512
commit
156ba85326
28 changed files with 230 additions and 36 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
|
@ -12,8 +13,10 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const currEpoch = 1000
|
||||
|
||||
func TestDB_Exists(t *testing.T) {
|
||||
db := newDB(t)
|
||||
db := newDB(t, meta.WithEpochState(epochState{currEpoch}))
|
||||
|
||||
t.Run("no object", func(t *testing.T) {
|
||||
nonExist := generateObject(t)
|
||||
|
@ -171,4 +174,15 @@ func TestDB_Exists(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.False(t, exists)
|
||||
})
|
||||
|
||||
t.Run("expired object", func(t *testing.T) {
|
||||
checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) {
|
||||
gotObj, err := metaExists(db, object.AddressOf(exp))
|
||||
require.False(t, gotObj)
|
||||
require.ErrorIs(t, err, object.ErrObjectIsExpired)
|
||||
|
||||
gotObj, err = metaExists(db, object.AddressOf(nonExp))
|
||||
require.True(t, gotObj)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue