Commit bb52c1f9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1df073df
......@@ -224,9 +224,8 @@ func XGetKV(db *zodb.DB, at zodb.Tid, kvOid map[Key]Value) map[Key]string {
//
// it is known that @at1 and @at2 the tree has kv1 and kv2 values correspondingly.
// it is known that for at1->at2 ZODB-level change is δZ.
func xverifyΔBTail(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.Tid, kv1, kv2 map[Key]string, δZ *zodb.EventCommit) {
func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.Tid, kv1, kv2 map[Key]string, δZ *zodb.EventCommit) {
d12 := kvdiff(kv1, kv2)
fmt.Println("d12:", d12)
// verify transition at1->at2 for all initial states of tracked {keys} from kv1 + ∞
keyv1 := []Key{10000} // inf, simulating ZBigFile.Size() query
......@@ -242,16 +241,21 @@ func xverifyΔBTail(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.
keys.Add(keyv1[idx])
}
xverifyΔBTail1(t, db, treeRoot, at1,at2, kv1,kv2, d12, δZ, keys)
xverifyΔBTail1(t, subj, db, treeRoot, at1,at2, kv1,kv2, d12, δZ, keys)
}
}
// xverifyΔBTail1 verifies how ΔBTail handles ZODB update at1->at2 from initial
// tracked state defined by initialTrackedKeys.
func xverifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.Tid, kv1,kv2, d12 map[Key]string, δZ *zodb.EventCommit, initialTrackedKeys SetKey) {
func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.Tid, kv1,kv2, d12 map[Key]string, δZ *zodb.EventCommit, initialTrackedKeys SetKey) {
X := exc.Raiseif
assert := require.New(t)
fmt.Println("verify1", initialTrackedKeys)
tracked := initialTrackedKeys.Elements()
sort.Slice(tracked, func(i,j int) bool {
return tracked[i] < tracked[j]
})
//fmt.Println("verify1", tracked)
txn, ctx := transaction.New(context.Background())
defer txn.Abort()
......@@ -292,8 +296,8 @@ func xverifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.
δToid := δB.ByRoot[treeRoot] // {} k -> oid
δT := XGetKV(db, at2, δToid) // {} k -> ZBlk(oid).data
fmt.Println("d12:", d12)
fmt.Println("δT: ", δT)
//fmt.Println("d12:", d12)
//fmt.Println("δT: ", δT)
var badv []string
badf := func(format string, argv ...interface{}) {
......@@ -330,14 +334,11 @@ func xverifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.
}
if badv != nil {
emsg := "δT is wrong:\n\n"
tracked := initialTrackedKeys.Elements()
sort.Slice(tracked, func(i,j int) bool {
return tracked[i] < tracked[j]
})
emsg += fmt.Sprintf("d12: %v\nδT: %v\ntracked: %v\n\n", d12, δT, tracked)
emsg := fmt.Sprintf("%s ; tracked=%v : δT is wrong:\n\n", subj, tracked)
emsg += fmt.Sprintf("d12: %v\nδT: %v\n\n", d12, δT)
emsg += strings.Join(badv, "\n")
t.Fatal(emsg)
emsg += "\n"
t.Error(emsg)
}
}
......@@ -437,8 +438,8 @@ func TestΔBTail(t *testing.T) {
at2 := δZ.Tid
kv2 := XGetTree(db, at2, tg.treeRoot)
fmt.Printf("\n%s -> %s\n", tree1, tree2) // XXX -> subtest? excctx?
xverifyΔBTail(t, db, tg.treeRoot, at1,at2, kv1,kv2, δZ)
subj := fmt.Sprintf("%s -> %s", tree1, tree2)
xverifyΔBTail(t, subj, db, tg.treeRoot, at1,at2, kv1,kv2, δZ)
at1 = at2
kv1 = kv2
......
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