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