forked from TrueCloudLab/frostfs-node
[#1732] pilorama: Fix backwards log insertion
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
2ef38cfbc4
commit
134f2ba02e
2 changed files with 43 additions and 0 deletions
|
@ -324,6 +324,12 @@ func (t *boltForest) applyOperation(logBucket, treeBucket *bbolt.Bucket, lm *Log
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if key == nil {
|
||||||
|
// The operation is inserted in the beginning, reposition the cursor.
|
||||||
|
// Otherwise, `Next` call will return currently inserted operation.
|
||||||
|
c.First()
|
||||||
|
}
|
||||||
key, value = c.Next()
|
key, value = c.Next()
|
||||||
|
|
||||||
// 3. Re-apply all other operations.
|
// 3. Re-apply all other operations.
|
||||||
|
|
|
@ -514,6 +514,43 @@ func testForestTreeExists(t *testing.T, constructor func(t testing.TB) Forest) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApplyTricky1(t *testing.T) {
|
||||||
|
ops := []Move{
|
||||||
|
{
|
||||||
|
Parent: 1,
|
||||||
|
Meta: Meta{Time: 100},
|
||||||
|
Child: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Parent: 0,
|
||||||
|
Meta: Meta{Time: 80},
|
||||||
|
Child: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := []struct{ child, parent Node }{
|
||||||
|
{1, 0},
|
||||||
|
{2, 1},
|
||||||
|
}
|
||||||
|
|
||||||
|
treeID := "version"
|
||||||
|
d := CIDDescriptor{CID: cidtest.ID(), Position: 0, Size: 1}
|
||||||
|
for i := range providers {
|
||||||
|
t.Run(providers[i].name, func(t *testing.T) {
|
||||||
|
s := providers[i].construct(t)
|
||||||
|
for i := range ops {
|
||||||
|
require.NoError(t, s.TreeApply(d, treeID, &ops[i]))
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range expected {
|
||||||
|
_, parent, err := s.TreeGetMeta(d.CID, treeID, expected[i].child)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, expected[i].parent, parent)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestForest_ApplyRandom(t *testing.T) {
|
func TestForest_ApplyRandom(t *testing.T) {
|
||||||
for i := range providers {
|
for i := range providers {
|
||||||
t.Run(providers[i].name, func(t *testing.T) {
|
t.Run(providers[i].name, func(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue