Commit 9eef8bdd authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6b2c1d79
......@@ -177,7 +177,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
t := xbtreetest.NewT(t_)
X := exc.Raiseif
δftail := NewΔFtail(t.Head().At, t.DB)
δFtail := NewΔFtail(t.Head().At, t.DB)
// load zfile via root['treegen/file']
txn, ctx := transaction.New(context.Background())
......@@ -198,7 +198,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
// track zfile[-∞,∞) from the beginning
// this should make ΔFtail to see all zfile changes
size, path, err := zfile.Size(ctx); X(err)
δftail.Track(zfile, /*blk*/-1, path, /*zblk*/nil)
δFtail.Track(zfile, /*blk*/-1, path, /*zblk*/nil)
if size != 0 {
t.Fatalf("BUG: zfile is not initially empty: size=%d", size)
}
......@@ -216,8 +216,18 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
xat := map[zodb.Tid]string{} // tid > "at<i>"
xat[δftail.Head()] = "at0"
t.Logf("# @at0 (%s)", δftail.Head())
xat[δFtail.Head()] = "at0"
t.Logf("# @at0 (%s)", δFtail.Head())
// vector of epochs and func to create a new one
epochv := []zodb.Tid{0}
onNewEpoch := func(epoch zodb.Tid) {
epochv = append(epochv, epoch)
for blk := range blkTab {
_, path, zblk, _, err := zfile.LoadBlk(ctx, blk); X(err)
δFtail.Track(zfile, blk, path, zblk)
}
}
// δfstr/vδfstr converts δf/vδf to string taking xat into account
δfstr := func(δf *ΔFile) string {
......@@ -241,7 +251,6 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
i := 0
delfilePrev := false
epochv := []zodb.Tid{0}
for test := range testq {
i++
δblk := setI64{}
......@@ -316,14 +325,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
req = tTxt + " " + dTxt
}
commit := t.CommitTree(req)
if newEpoch {
epochv = append(epochv, commit.At)
}
// update blkRevAt
var blkRevPrev map[int64]zodb.Tid
if i != 0 {
blkRevPrev = blkRevAt[δftail.Head()]
blkRevPrev = blkRevAt[δFtail.Head()]
}
blkRev := map[int64]zodb.Tid{}
for blk, rev := range blkRevPrev {
......@@ -361,8 +367,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
//fmt.Printf("Zinblk: %v\n", Zinblk)
// update δftail
δF, err := δftail.Update(commit.ΔZ); X(err)
// update δFtail
δF, err := δFtail.Update(commit.ΔZ); X(err)
if newEpoch {
onNewEpoch(commit.At)
}
// assert δF points to the file if δfok != ø
if δF.Rev != commit.At {
......@@ -387,9 +396,9 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
t.Errorf("δf:\nhave: %v\nwant: %v", δf, δfok)
}
// verify δftail.trackSetZBlk
// verify δFtail.trackSetZBlk
trackZinblk := map[string]setI64{}
for oid, zt := range δftail.trackSetZBlk {
for oid, zt := range δFtail.trackSetZBlk {
zblki := commit.ZBlkTab[oid]
for root, blocks := range zt.inroot {
if root != blktabOid {
......@@ -414,10 +423,10 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
if len(vδf) >= ncut {
revcut := vδf[0].Rev
t.Logf("# forget ≤ @%s", xat[revcut])
δftail.ForgetPast(revcut)
δFtail.ForgetPast(revcut)
vδf = vδf[1:]
//t.Logf("# vδf: %s", vδfstr(vδf))
//t.Logf("# vδt: %s", vδfstr(δftail.SliceByFileRev(zfile, δftail.Tail(), δftail.Head())))
//t.Logf("# vδt: %s", vδfstr(δFtail.SliceByFileRev(zfile, δFtail.Tail(), δFtail.Head())))
}
// SliceByFileRev
......@@ -432,7 +441,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
hi := vδf[k].Rev
vδf_ok := vδf[j:k+1] // [j,k]
vδf_ := δftail.SliceByFileRev(zfile, lo, hi)
vδf_ := δFtail.SliceByFileRev(zfile, lo, hi)
if !reflect.DeepEqual(vδf_, vδf_ok) {
t.Errorf("slice (@%s,@%s]:\nhave: %v\nwant: %v", xat[lo], xat[hi], vδfstr(vδf_), vδfstr(vδf_ok))
}
......@@ -457,7 +466,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
at := vδf[j].Rev
blkRev := blkRevAt[at]
for _, blk := range blkv {
rev, exact := δftail.LastBlkRev(ctx, zfile, blk, at)
rev, exact := δFtail.LastBlkRev(ctx, zfile, blk, at)
revOK, ok := blkRev[blk]
if !ok {
k := len(epochv) - 1
......@@ -469,8 +478,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
revOK = epochv[k]
}
exactOK := true
if revOK <= δftail.Tail() {
revOK, exactOK = δftail.Tail(), false
if revOK <= δFtail.Tail() {
revOK, exactOK = δFtail.Tail(), false
}
if !(rev == revOK && exact == exactOK) {
t.Errorf("blkrev #%d @%s:\nhave: @%s, %v\nwant: @%s, %v", blk, xat[at], xat[rev], exact, xat[revOK], exactOK)
......
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