Commit 46624787 authored by Kirill Smelkov's avatar Kirill Smelkov

X ΔFtail: `go test -failfast -short -v -run Random...

X ΔFtail: `go test -failfast -short -v -run Random -randseed=1626793016249041295` discovered problems

=== RUN   TestΔFtailRandom
    δftail_test.go:141: # n=10 seed=1626793016249041295
2021/07/23 12:26:01 zodb: FIXME: open /tmp/TestΔFtailRandom1363232041/001/1.fs: raw cache is not ready for invalidations -> NoCache forced
    δftail_test.go:191: #   @at0 (03e19cb6064c58dd)
    δftail_test.go:203: # → @at1 (03e19cb6064ddd99)  t0:a Da:a,b:b,c:c,d:d,e:e,f:f,g:g,h:h,i:i,j:j      ; not-yet-tracked
    δftail_test.go:375: # → @at2 (03e19cb6064fc922)  δT2:i,3:c,5:d,9:c  δD{a b c d e f g h i}   ; t0:a,2:i,3:c,5:d,9:c Da:a2,b:b2,c:c2,d:d2,e:e2,f:f2,g:g2,h:h2,i:i2,j:j        δ{0 2 3 5 9}
    δftail_test.go:472: δf:
        have: &{03e19cb6064fc922 false {2 3 5 9} true}
        want: &{03e19cb6064fc922 false {0 2 3 5 9} true}
    δftail_test.go:499: .trackSetZBlk:
        ~have: map[c:{3 9} d:{5} i:{2}]
         want: map[a:{0} c:{3 9} d:{5} i:{2}]

    ...
parent 0853cc9f
...@@ -519,7 +519,7 @@ func (δftail *_ΔFileTail) forgetPast(revCut zodb.Tid) { ...@@ -519,7 +519,7 @@ func (δftail *_ΔFileTail) forgetPast(revCut zodb.Tid) {
// //
// Note: contrary to regular go slicing, low is exclusive while high is inclusive. // Note: contrary to regular go slicing, low is exclusive while high is inclusive.
func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*readonly*/[]*ΔFile { func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*readonly*/[]*ΔFile {
//fmt.Printf("\n") fmt.Printf("\nslice f<%s> (@%s,@%s]\n", zfile.POid(), lo, hi)
xtail.AssertSlice(δFtail, lo, hi) xtail.AssertSlice(δFtail, lo, hi)
// XXX locking // XXX locking
...@@ -631,13 +631,13 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado ...@@ -631,13 +631,13 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado
} }
// merge vδZ and vδT of current epoch // merge vδZ and vδT of current epoch
for ((iz >= 0 && vδZ[iz].Rev >= epoch) || it >= 0) { for ((iz >= 0 && vδZ[iz].Rev > epoch) || it >= 0) { // XXX -> `δZ.Rev > epoch`
// δZ that is covered by current Zinblk // δZ that is covered by current Zinblk
// -> update δf // -> update δf
if iz >= 0 { if iz >= 0 && vδZ[iz].Rev > epoch {
δZ := vδZ[iz] δZ := vδZ[iz]
if ZinblkAt <= δZ.Rev { if ZinblkAt <= δZ.Rev {
//fmt.Printf("δZ @%s\n", δZ.Rev) fmt.Printf("δZ @%s\n", δZ.Rev)
for _, oid := range δZ.Changev { for _, oid := range δZ.Changev {
inblk, ok := Zinblk[oid] inblk, ok := Zinblk[oid]
if ok && len(inblk) != 0 { if ok && len(inblk) != 0 {
...@@ -653,7 +653,7 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado ...@@ -653,7 +653,7 @@ func (δFtail *ΔFtail) SliceByFileRev(zfile *ZBigFile, lo, hi zodb.Tid) /*reado
// δT -> adjust Zinblk + update δf // δT -> adjust Zinblk + update δf
if it >= 0 { if it >= 0 {
δT := vδT[it] δT := vδT[it]
//fmt.Printf("δT @%s\n", δT.Rev) fmt.Printf("δT @%s\n", δT.Rev)
for blk, δzblk := range δT.ΔKV { for blk, δzblk := range δT.ΔKV {
// apply in reverse as we go ← // apply in reverse as we go ←
if δzblk.New != xbtree.VDEL { if δzblk.New != xbtree.VDEL {
...@@ -727,7 +727,7 @@ func (δFtail *ΔFtail) BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64, a ...@@ -727,7 +727,7 @@ func (δFtail *ΔFtail) BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64, a
func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64, at zodb.Tid) (_ zodb.Tid, exact bool, err error) { func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64, at zodb.Tid) (_ zodb.Tid, exact bool, err error) {
defer xerr.Contextf(&err, "blkrev f<%s> #%d @%s", zf.POid(), blk, at) defer xerr.Contextf(&err, "blkrev f<%s> #%d @%s", zf.POid(), blk, at)
//fmt.Printf("\nblkrev #%d @%s\n", blk, at) fmt.Printf("\nblkrev #%d @%s\n", blk, at)
// assert at ∈ (tail, head] // assert at ∈ (tail, head]
tail := δFtail.Tail() tail := δFtail.Tail()
...@@ -752,7 +752,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64, ...@@ -752,7 +752,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64,
// find epoch that covers at and associated blktab root/object // find epoch that covers at and associated blktab root/object
vδE := δftail.vδE vδE := δftail.vδE
//fmt.Printf(" vδE: %v\n", vδE) fmt.Printf(" vδE: %v\n", vδE)
l := len(vδE) l := len(vδE)
i := sort.Search(l, func(i int) bool { i := sort.Search(l, func(i int) bool {
return at < vδE[i].Rev return at < vδE[i].Rev
...@@ -778,7 +778,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64, ...@@ -778,7 +778,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64,
epoch = vδE[i].Rev epoch = vδE[i].Rev
} }
//fmt.Printf(" epoch: @%s root: %s\n", epoch, root) fmt.Printf(" epoch: @%s root: %s\n", epoch, root)
if root == xbtree.VDEL { if root == xbtree.VDEL {
return epoch, true, nil return epoch, true, nil
...@@ -786,7 +786,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64, ...@@ -786,7 +786,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64,
zblk, tabRev, zblkExact, tabRevExact, err := δFtail.δBtail.GetAt(root, blk, at) zblk, tabRev, zblkExact, tabRevExact, err := δFtail.δBtail.GetAt(root, blk, at)
//fmt.Printf(" GetAt #%d @%s -> %s(%v), @%s(%v)\n", blk, at, zblk, zblkExact, tabRev, tabRevExact) fmt.Printf(" GetAt #%d @%s -> %s(%v), @%s(%v)\n", blk, at, zblk, zblkExact, tabRev, tabRevExact)
if err != nil { if err != nil {
return zodb.InvalidTid, false, err return zodb.InvalidTid, false, err
} }
...@@ -831,7 +831,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64, ...@@ -831,7 +831,7 @@ func (δFtail *ΔFtail) _BlkRevAt(ctx context.Context, zf *ZBigFile, blk int64,
// blktab[blk] was changed to point to a zblk @tabRev. // blktab[blk] was changed to point to a zblk @tabRev.
// blk revision is max rev and when zblk changed last in (rev, at] range. // blk revision is max rev and when zblk changed last in (rev, at] range.
zblkRev, zblkRevExact := δFtail.δBtail.ΔZtail().LastRevOf(zblk, at) zblkRev, zblkRevExact := δFtail.δBtail.ΔZtail().LastRevOf(zblk, at)
//fmt.Printf(" ZRevOf %s @%s -> @%s, %v\n", zblk, at, zblkRev, zblkRevExact) fmt.Printf(" ZRevOf %s @%s -> @%s, %v\n", zblk, at, zblkRev, zblkRevExact)
if zblkRev > tabRev { if zblkRev > tabRev {
return zblkRev, zblkRevExact, nil return zblkRev, zblkRevExact, nil
} else { } else {
......
...@@ -112,6 +112,12 @@ func TestΔFtail(t *testing.T) { ...@@ -112,6 +112,12 @@ func TestΔFtail(t *testing.T) {
{δT{1:a,3:d,6:j}, δD(b,c,d,f,g,h,i,j)}, {δT{1:a,3:d,6:j}, δD(b,c,d,f,g,h,i,j)},
{δT{0:i,1:f,4:e,5:e,7:d,8:h}, δD(d,j)}, {δT{0:i,1:f,4:e,5:e,7:d,8:h}, δD(d,j)},
{δT{}, δD(a,b,c,e,f,g,h,i,j)}, {δT{}, δD(a,b,c,e,f,g,h,i,j)},
// XXX
{nil, nil},
{δT{0:a}, δD()},
{δT{2:i,3:c,5:d,9:c}, δD(a,b,c,d,e,f,g,h,i)},
{δT{0:j,1:d,2:h,5:g,6:h,7:c,9:h}, δD(d,e,f,h,j)},
} }
testq := make(chan ΔFTestEntry) testq := make(chan ΔFTestEntry)
...@@ -126,7 +132,8 @@ func TestΔFtail(t *testing.T) { ...@@ -126,7 +132,8 @@ func TestΔFtail(t *testing.T) {
// TestΔFtailRandom runs ΔFtail tests on randomly-generated file changes. // TestΔFtailRandom runs ΔFtail tests on randomly-generated file changes.
func TestΔFtailRandom(t *testing.T) { func TestΔFtailRandom(t *testing.T) {
n := xbtreetest.N(1E3, 1E4, 1E5) //n := xbtreetest.N(1E3, 1E4, 1E5)
n := xbtreetest.N(1E1, 1E4, 1E5) // XXX temp
nblk := xbtreetest.N(1E1, 2E1, 1E2) // keeps failures detail small on -short nblk := xbtreetest.N(1E1, 2E1, 1E2) // keeps failures detail small on -short
// random-number generator // random-number generator
...@@ -237,7 +244,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) { ...@@ -237,7 +244,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
oldTrackSetZBlk: nil, oldTrackSetZBlk: nil,
}, },
} }
blkTab := map[int64]string{0:"a"} // #blk -> ZBlk<name> blkTab := map[int64]string{} // #blk -> ZBlk<name>
Zinblk := map[string]setI64{} // ZBlk<name> -> which #blk refer to it Zinblk := map[string]setI64{} // ZBlk<name> -> which #blk refer to it
blkRevAt := map[zodb.Tid]map[int64]zodb.Tid{} // {} at -> {} #blk -> rev blkRevAt := map[zodb.Tid]map[int64]zodb.Tid{} // {} at -> {} #blk -> rev
...@@ -251,6 +258,9 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) { ...@@ -251,6 +258,9 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
epochv := []zodb.Tid{t0.At, t1.At} epochv := []zodb.Tid{t0.At, t1.At}
blkTab[0] = "a" // matches t1
Zinblk["a"] = setI64{} // matches t1
Zinblk["a"].Add(0)
// δfstr/vδfstr converts δf/vδf to string taking xat into account // δfstr/vδfstr converts δf/vδf to string taking xat into account
δfstr := func(δf *ΔFile) string { δfstr := func(δf *ΔFile) string {
...@@ -523,6 +533,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) { ...@@ -523,6 +533,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
} }
/*
// SliceByFileRev // SliceByFileRev
for j := 0; j < len(vδf); j++ { for j := 0; j < len(vδf); j++ {
for k := j; k < len(vδf); k++ { for k := j; k < len(vδf); k++ {
...@@ -541,6 +552,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) { ...@@ -541,6 +552,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
} }
} }
} }
*/
_ = vδfstr
// BlkRevAt // BlkRevAt
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment