forked from TrueCloudLab/frostfs-node
[#67] node: Accept expired locked objects
Allow replication of any (expired too) locked object. Information about object locking is considered to be presented on the _container nodes_. Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
f006f3b342
commit
64bde68fb9
5 changed files with 75 additions and 3 deletions
|
@ -36,13 +36,26 @@ func (s testNetState) CurrentEpoch() uint64 {
|
|||
return s.epoch
|
||||
}
|
||||
|
||||
type testLockSource struct {
|
||||
m map[oid.Address]bool
|
||||
}
|
||||
|
||||
func (t testLockSource) IsLocked(address oid.Address) (bool, error) {
|
||||
return t.m[address], nil
|
||||
}
|
||||
|
||||
func TestFormatValidator_Validate(t *testing.T) {
|
||||
const curEpoch = 13
|
||||
|
||||
ls := testLockSource{
|
||||
m: make(map[oid.Address]bool),
|
||||
}
|
||||
|
||||
v := NewFormatValidator(
|
||||
WithNetState(testNetState{
|
||||
epoch: curEpoch,
|
||||
}),
|
||||
WithLockSource(ls),
|
||||
)
|
||||
|
||||
ownerKey, err := keys.NewPrivateKey()
|
||||
|
@ -229,8 +242,25 @@ func TestFormatValidator_Validate(t *testing.T) {
|
|||
|
||||
t.Run("expired object", func(t *testing.T) {
|
||||
val := strconv.FormatUint(curEpoch-1, 10)
|
||||
err := v.Validate(fn(val), false)
|
||||
require.ErrorIs(t, err, errExpired)
|
||||
obj := fn(val)
|
||||
|
||||
t.Run("non-locked", func(t *testing.T) {
|
||||
err := v.Validate(obj, false)
|
||||
require.ErrorIs(t, err, errExpired)
|
||||
})
|
||||
|
||||
t.Run("locked", func(t *testing.T) {
|
||||
var addr oid.Address
|
||||
oID, _ := obj.ID()
|
||||
cID, _ := obj.ContainerID()
|
||||
|
||||
addr.SetContainer(cID)
|
||||
addr.SetObject(oID)
|
||||
ls.m[addr] = true
|
||||
|
||||
err := v.Validate(obj, false)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("alive object", func(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue