Commit 2a1df513 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1926b828
...@@ -496,11 +496,26 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -496,11 +496,26 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
X := exc.Raiseif X := exc.Raiseif
assert := require.New(t) assert := require.New(t)
tracked := initialTrackedKeys.Elements() var kadjTracked SetKey = nil
sort.Slice(tracked, func(i,j int) bool { var δT map[Key]string = nil
return tracked[i] < tracked[j]
}) var badv []string
//fmt.Println("verify1", tracked) badf := func(format string, argv ...interface{}) {
badv = append(badv, fmt.Sprintf(format, argv...))
}
defer func() {
if badv != nil {
emsg := fmt.Sprintf("%s ; tracked=%v :\n\n", subj, initialTrackedKeys)
emsg += fmt.Sprintf("d12: %v\nδT: %v\n\n", d12, δT)
emsg += fmt.Sprintf("kadj[Tracked]: %v\nkadj: %v\n\n", kadjTracked, kadj)
emsg += strings.Join(badv, "\n")
emsg += "\n"
t.Error(emsg)
//t.Fatal(emsg)
}
}()
txn, ctx := transaction.New(context.Background()) txn, ctx := transaction.New(context.Background())
defer txn.Abort() defer txn.Abort()
...@@ -512,7 +527,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -512,7 +527,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
xtree, err := zconn.Get(ctx, treeRoot); X(err) xtree, err := zconn.Get(ctx, treeRoot); X(err)
ztree := xtree.(*Tree) ztree := xtree.(*Tree)
kadjTracked := SetKey{} // kadj[Tracked] (all keys adjacent to tracked) kadjTracked = SetKey{} // kadj[Tracked] (all keys adjacent to tracked keys)
for k := range initialTrackedKeys { for k := range initialTrackedKeys {
path := []Node{} path := []Node{}
_, _, err = ztree.VGet(ctx, k, func(node Node) { _, _, err = ztree.VGet(ctx, k, func(node Node) {
...@@ -538,7 +553,8 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -538,7 +553,8 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
} }
trackedNotInKadj.Del(kInf) trackedNotInKadj.Del(kInf)
if len(trackedNotInKadj) > 0 { if len(trackedNotInKadj) > 0 {
panic(fmt.Sprintf("BUG: %s: Tracked ∉ kadj[Tracked]", subj)) // XXX more details? badf("BUG: Tracked ∉ kadj[Tracked] ; extra=%v", trackedNotInKadj)
return
} }
// k ∈ d12 // k ∈ d12
...@@ -558,6 +574,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -558,6 +574,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
//if len(d12) == 0 && len(initialTrackedKeys) == 0 { //if len(d12) == 0 && len(initialTrackedKeys) == 0 {
if len(initialTrackedKeys) == 0 { if len(initialTrackedKeys) == 0 {
//if len(inδTOK) == 0 { XXX <- should be correct
assert.Equal(len(δB.ByRoot), 0) assert.Equal(len(δB.ByRoot), 0)
return return
} }
...@@ -570,16 +587,11 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -570,16 +587,11 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
assert.Equal(roots, []zodb.Oid{treeRoot}) assert.Equal(roots, []zodb.Oid{treeRoot})
δToid := δB.ByRoot[treeRoot] // {} k -> oid δToid := δB.ByRoot[treeRoot] // {} k -> oid
δT := XGetKV(db, at2, δToid) // {} k -> ZBlk(oid).data δT = XGetKV(db, at2, δToid) // {} k -> ZBlk(oid).data
//fmt.Println("d12:", d12) //fmt.Println("d12:", d12)
//fmt.Println("δT: ", δT) //fmt.Println("δT: ", δT)
var badv []string
badf := func(format string, argv ...interface{}) {
badv = append(badv, fmt.Sprintf(format, argv...))
}
// δT must be subset of d12. // δT must be subset of d12.
// changed keys, that are // changed keys, that are
// - in tracked set -> must be present in δT // - in tracked set -> must be present in δT
...@@ -614,15 +626,6 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -614,15 +626,6 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
} }
} }
if badv != nil {
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 += fmt.Sprintf("kadj[Tracked]: %v\nkadj: %v\n\n", kadjTracked, kadj)
emsg += strings.Join(badv, "\n")
emsg += "\n"
t.Error(emsg)
//t.Fatal(emsg)
}
} }
...@@ -1070,7 +1073,7 @@ func xkvFlatten(xkv RBucketSet) map[Key]string { ...@@ -1070,7 +1073,7 @@ func xkvFlatten(xkv RBucketSet) map[Key]string {
} }
// easies debugging // easies debugging.
func (ks SetKey) String() string { func (ks SetKey) String() string {
keyv := ks.Elements() keyv := ks.Elements()
sort.Slice(keyv, func(i, j int) bool { sort.Slice(keyv, func(i, j int) bool {
......
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