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) {
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 + ∞
// 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)
allKeyv := allKeys.SortedElements()
......@@ -616,11 +615,11 @@ func xverifyΔBTail_Update(t *testing.T, subj string, db *zodb.DB, treeRoot zodb
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 verifies how ΔBTail handles ZODB update at1->at2 from initial
......@@ -789,82 +788,97 @@ 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.
//
// t0->t1 exercises from-scratch rebuild,
// t1->t2 further exercises incremental rebuild.
func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1, t2 *tTreeCommit) {
tAllKeys := allTestKeys(t0, t1, t2)
tAllKeyv := tAllKeys.SortedElements()
// tid -> "at_i"
xat := map[zodb.Tid]string{
t0.at: "at0",
t1.at: "at1",
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[t1.at], xkvFlatten(t1.xkv))
fmt.Printf("@%s: %v\n", xat[t2.at], xkvFlatten(t2.xkv))
d01 := kvdiff(xkvFlatten(t0.xkv), xkvFlatten(t1.xkv))
d12 := kvdiff(xkvFlatten(t1.xkv), xkvFlatten(t2.xkv))
kadj01 := KAdj(t0,t1) // FIXME for all keys from t0,t1,t2
kadj12 := KAdj(t1,t2) // FIXME for all keys from t0,t1,t2
ø := SetKey{}
t.Run(fmt.Sprintf("rebuild/%s→%s", t0.tree, t1.tree), func(t *testing.T) {
tAllKeys := allTestKeys(t0, t1, t2)
tAllKeyv := tAllKeys.SortedElements()
// verify t0 -> t1 Track(keys1) -> t2 Track(keys2)
// for all combinations of keys1 and keys2
for k1idx := range IntSets(len(tAllKeyv)) {
keys1 := SetKey{}
for _, idx1 := range k1idx {
keys1.Add(tAllKeyv[idx1])
// tid -> "at_i"
xat := map[zodb.Tid]string{
t0.at: "at0",
t1.at: "at1",
t2.at: "at2",
}
t.Run(fmt.Sprintf("rebuild/%s→%s;track=%s;R", t0.tree, t1.tree, keys1), func(t *testing.T) {
δbtail := NewΔBtail(t0.at, db)
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[t2.at], xkvFlatten(t2.xkv))
d01 := kvdiff(xkvFlatten(t0.xkv), xkvFlatten(t1.xkv))
d12 := kvdiff(xkvFlatten(t1.xkv), xkvFlatten(t2.xkv))
_ = d01
_ = d12
kadj01 := KAdj(t0,t1) // FIXME for all keys from t0,t1,t2
kadj12 := KAdj(t1,t2) // FIXME for all keys from t0,t1,t2
_ = kadj01
_ = kadj12
//ø := SetKey{}
ø := trackIndex{}
// verify t0 -> t1 Track(keys1) -> t2 Track(keys2)
// for all combinations of keys1 and keys2
for k1idx := range IntSets(len(tAllKeyv)) {
keys1 := SetKey{}
for _, idx1 := range k1idx {
keys1.Add(tAllKeyv[idx1])
}
t.Run(fmt.Sprintf(" track=%s;R", keys1), func(t *testing.T) {
δbtail := NewΔBtail(t0.at, db)
// assert trackIdx=ø, newTrackIdx=ø, vδB=[]
assertTrack(t, "@at0", δbtail.trackIdx, ø) // XXX + newTrackIdx, XXX vδB
// assert trackIdx=ø, newTrackIdx=ø, 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,
// after Update(t0->t1):
/*trackIdx=*/ ø,
xverifyΔBTail_rebuild1(t, db, δbtail, t0, t1, treeRoot,
// after Update(t0->t1):
/*trackIdx=*/ ø,
// after Track(keys)
keys1,
/*newTrackIdx=*/ xkv1.trackIdx(keys1),
// after Track(keys)
keys1,
/*newTrackIdx=*/ t1.xkv.trackIdx(keys1),
// after rebuild
/*trackIdx=*/ xkv1.trackIdx(keys1),
/*vδB=*/ /*XXX temp*/nil /*[δ1/Tadj(keys1)*/)
// after rebuild
/*trackIdx=*/ t1.xkv.trackIdx(keys1),
/*vδB=*/ /*XXX temp*/nil /*[δ1/Tadj(keys1)*/)
/* TODO reenable
// tRestKeys2 = tAllKeys - keys1
tRestKeys2 := tAllKeys.Difference(keys1)
tRestKeyv2 := tRestKeys2.SortedElements()
for k2idx := range IntSets(len(tRestKeyv2)) {
keys2 := SetKey{}
for _, idx2 := range k2idx {
keys2.Add(tRestKeyv2[idx2])
}
// tRestKeys2 = tAllKeys - keys1
tRestKeys2 := tAllKeys.Difference(keys1)
tRestKeyv2 := tRestKeys2.SortedElements()
for k2idx := range IntSets(len(tRestKeyv2)) {
keys2 := SetKey{}
for _, idx2 := range k2idx {
keys2.Add(tRestKeyv2[idx2])
}
δbtail_ = δbtail.Clone()
// XXX t.Run
xverifyΔBTail_rebuild1(t, δbtail_, t1, t2, keys,
trackIdx==Tadj(t2,Tadj(t1,keys1)) v Tadj(t2,keys2),
vδΒ=[δ1/keys1+keys2, δ2/keys1+keys2])
}
δbtail_ = δbtail.Clone()
// XXX t.Run
xverifyΔBTail_rebuild1(t, δbtail_, t1, t2, keys,
trackIdx==Tadj(t2,Tadj(t1,keys1)) v Tadj(t2,keys2),
vδΒ=[δ1/keys1+keys2, δ2/keys1+keys2])
}
*/
})
}
})
}
})
}
// xverifyΔBTail_rebuild1 verifies ΔBTree state:
......@@ -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.
// XXX
// 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
for _, t := range vt[1:] {
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