Commit 38d545b2 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a7b3a3dc
...@@ -602,8 +602,7 @@ func KAdj(t1, t2 *tTreeCommit) (kadj map[Key]SetKey) { ...@@ -602,8 +602,7 @@ func KAdj(t1, t2 *tTreeCommit) (kadj map[Key]SetKey) {
func xverifyΔBTail_Update(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, t1, t2 *tTreeCommit) { func xverifyΔBTail_Update(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, t1, t2 *tTreeCommit) {
// verify transition at1->at2 for all initial states of tracked {keys} from kv1 + kv2 + ∞ // verify transition at1->at2 for all initial states of tracked {keys} from kv1 + kv2 + ∞
// XXX think again whether running each case in subtest is good or not t.Run(fmt.Sprintf("Update/%s→%s", t1.tree, t2.tree), func(t *testing.T) {
// t.Run(fmt.Sprintf("Update/%s→%s", t1.tree, t2.tree), func(t *testing.T) {
allKeys := allTestKeys(t1, t2) allKeys := allTestKeys(t1, t2)
allKeyv := allKeys.SortedElements() allKeyv := allKeys.SortedElements()
...@@ -616,11 +615,11 @@ func xverifyΔBTail_Update(t *testing.T, subj string, db *zodb.DB, treeRoot zodb ...@@ -616,11 +615,11 @@ func xverifyΔBTail_Update(t *testing.T, subj string, db *zodb.DB, treeRoot zodb
keys.Add(allKeyv[idx]) keys.Add(allKeyv[idx])
} }
// t.Run(fmt.Sprintf(" track=%s", keys), func(t *testing.T) { t.Run(fmt.Sprintf(" track=%s", keys), func(t *testing.T) {
xverifyΔBTail_Update1(t, subj, db, treeRoot, t1.at,t2.at, t1.xkv,t2.xkv, t2.δZ, keys, kadj12) xverifyΔBTail_Update1(t, subj, db, treeRoot, t1.at,t2.at, t1.xkv,t2.xkv, t2.δZ, keys, kadj12)
// }) })
} }
// }) })
} }
// xverifyΔBTail_Update1 verifies how ΔBTail handles ZODB update at1->at2 from initial // xverifyΔBTail_Update1 verifies how ΔBTail handles ZODB update at1->at2 from initial
...@@ -789,11 +788,21 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod ...@@ -789,11 +788,21 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
} }
} }
// assertTrack verifies that trackIdx == trackIdxOK.
// XXX place
func assertTrack(t *testing.T, subj string, trackIdx, trackIdxOK trackIndex) {
if !reflect.DeepEqual(trackIdx, trackIdxOK) {
t.Errorf("%s:\n\thave: %v\n\twant: %v", subj, trackIdx, trackIdxOK)
//t.Fatalf("%s:\n\thave: %v\n\twant: %v", subj, trackIdx, trackIdxOK)
}
}
// xverifyΔBTail_rebuild verifies δBtail.rebuild during t0->t1->t2 transition. // xverifyΔBTail_rebuild verifies δBtail.rebuild during t0->t1->t2 transition.
// //
// t0->t1 exercises from-scratch rebuild, // t0->t1 exercises from-scratch rebuild,
// t1->t2 further exercises incremental rebuild. // t1->t2 further exercises incremental rebuild.
func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1, t2 *tTreeCommit) { func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1, t2 *tTreeCommit) {
t.Run(fmt.Sprintf("rebuild/%s→%s", t0.tree, t1.tree), func(t *testing.T) {
tAllKeys := allTestKeys(t0, t1, t2) tAllKeys := allTestKeys(t0, t1, t2)
tAllKeyv := tAllKeys.SortedElements() tAllKeyv := tAllKeys.SortedElements()
...@@ -804,18 +813,22 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1 ...@@ -804,18 +813,22 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
t2.at: "at2", t2.at: "at2",
} }
// XXX move prints under first t.Run ?
fmt.Printf("@%s: %v\n", xat[t0.at], xkvFlatten(t0.xkv)) fmt.Printf("@%s: %v\n", xat[t0.at], xkvFlatten(t0.xkv))
fmt.Printf("@%s: %v\n", xat[t1.at], xkvFlatten(t1.xkv)) fmt.Printf("@%s: %v\n", xat[t1.at], xkvFlatten(t1.xkv))
fmt.Printf("@%s: %v\n", xat[t2.at], xkvFlatten(t2.xkv)) fmt.Printf("@%s: %v\n", xat[t2.at], xkvFlatten(t2.xkv))
d01 := kvdiff(xkvFlatten(t0.xkv), xkvFlatten(t1.xkv)) d01 := kvdiff(xkvFlatten(t0.xkv), xkvFlatten(t1.xkv))
d12 := kvdiff(xkvFlatten(t1.xkv), xkvFlatten(t2.xkv)) d12 := kvdiff(xkvFlatten(t1.xkv), xkvFlatten(t2.xkv))
_ = d01
_ = d12
kadj01 := KAdj(t0,t1) // FIXME for all keys from t0,t1,t2 kadj01 := KAdj(t0,t1) // FIXME for all keys from t0,t1,t2
kadj12 := KAdj(t1,t2) // FIXME for all keys from t0,t1,t2 kadj12 := KAdj(t1,t2) // FIXME for all keys from t0,t1,t2
_ = kadj01
_ = kadj12
ø := SetKey{} //ø := SetKey{}
ø := trackIndex{}
// verify t0 -> t1 Track(keys1) -> t2 Track(keys2) // verify t0 -> t1 Track(keys1) -> t2 Track(keys2)
// for all combinations of keys1 and keys2 // for all combinations of keys1 and keys2
...@@ -825,13 +838,13 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1 ...@@ -825,13 +838,13 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
keys1.Add(tAllKeyv[idx1]) keys1.Add(tAllKeyv[idx1])
} }
t.Run(fmt.Sprintf("rebuild/%s→%s;track=%s;R", t0.tree, t1.tree, keys1), func(t *testing.T) { t.Run(fmt.Sprintf(" track=%s;R", keys1), func(t *testing.T) {
δbtail := NewΔBtail(t0.at, db) δbtail := NewΔBtail(t0.at, db)
// assert trackIdx=ø, newTrackIdx=ø, vδB=[] // assert trackIdx=ø, newTrackIdx=ø, vδB=[]
assertTrack(t, "@at0", δbtail.trackIdx, ø) // XXX + newTrackIdx, XXX vδB assertTrack(t, "@at0 trackIdx", δbtail.trackIdx, ø) // XXX + newTrackIdx, XXX vδB
assertTrack(t, "@at1", δbtail.trackIdx, xkv1.trackIdx(keys1)) assertTrack(t, "@at1 trackIdx", δbtail.trackIdx, t1.xkv.trackIdx(keys1))
xverifyΔBTail_rebuild1(t, db, δbtail, t0, t1, treeRoot, xverifyΔBTail_rebuild1(t, db, δbtail, t0, t1, treeRoot,
// after Update(t0->t1): // after Update(t0->t1):
...@@ -839,10 +852,10 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1 ...@@ -839,10 +852,10 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
// after Track(keys) // after Track(keys)
keys1, keys1,
/*newTrackIdx=*/ xkv1.trackIdx(keys1), /*newTrackIdx=*/ t1.xkv.trackIdx(keys1),
// after rebuild // after rebuild
/*trackIdx=*/ xkv1.trackIdx(keys1), /*trackIdx=*/ t1.xkv.trackIdx(keys1),
/*vδB=*/ /*XXX temp*/nil /*[δ1/Tadj(keys1)*/) /*vδB=*/ /*XXX temp*/nil /*[δ1/Tadj(keys1)*/)
...@@ -865,6 +878,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1 ...@@ -865,6 +878,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
*/ */
}) })
} }
})
} }
// xverifyΔBTail_rebuild1 verifies ΔBTree state: // xverifyΔBTail_rebuild1 verifies ΔBTree state:
...@@ -904,7 +918,7 @@ func xverifyΔBTail_rebuild1(t *testing.T, db *zodb.DB, δbtail *ΔBtail, ti, tj ...@@ -904,7 +918,7 @@ func xverifyΔBTail_rebuild1(t *testing.T, db *zodb.DB, δbtail *ΔBtail, ti, tj
// xverifyΔBTail_Get verifies δBtail.Get on series of vt ZODB changes. // xverifyΔBTail_Get verifies δBtail.Get on series of vt ZODB changes.
// XXX // XXX
// XXX kill // XXX kill
func xverifyΔBTail_Get(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, vt ...*tTreeCommit) { func ___xverifyΔBTail_Get(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, vt ...*tTreeCommit) {
subj := vt[0].tree subj := vt[0].tree
for _, t := range vt[1:] { for _, t := range vt[1:] {
subj += "→" + t.tree subj += "→" + t.tree
......
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