Commit f0df1b1e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7df766ea
...@@ -458,7 +458,10 @@ func XGetBucket(db *zodb.DB, at zodb.Tid, root zodb.Oid) ... { ...@@ -458,7 +458,10 @@ func XGetBucket(db *zodb.DB, at zodb.Tid, root zodb.Oid) ... {
// //
// it is known that @at1 and @at2 the tree has xkv1 and xkv2 values correspondingly. // it is known that @at1 and @at2 the tree has xkv1 and xkv2 values correspondingly.
// it is known that for at1->at2 ZODB-level change is δZ. // it is known that for at1->at2 ZODB-level change is δZ.
func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.Tid, xkv1, xkv2 RBucketSet, δZ *zodb.EventCommit) { // XXX +kadjOK //
// kadjOK may be optionally provided. if kadjOK != nil computed adjacency
// matrix is verified against it.
func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.Tid, xkv1, xkv2 RBucketSet, δZ *zodb.EventCommit, kadjOK map[Key]SetKey) {
d12 := kvdiff(xkvFlatten(xkv1), xkvFlatten(xkv2)) d12 := kvdiff(xkvFlatten(xkv1), xkvFlatten(xkv2))
// 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 + ∞
...@@ -515,6 +518,10 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a ...@@ -515,6 +518,10 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a
kadj[k] = ka kadj[k] = ka
} }
if kadjOK != nil && !reflect.DeepEqual(kadj, kadjOK) {
panic(fmt.Sprintf("BUG: computed kadj is wrong:\nkadjOK: %v\nkadj : %v", kadjOK, kadj))
}
for kidx := range IntSets(len(allKeyv)) { for kidx := range IntSets(len(allKeyv)) {
keys := SetKey{} keys := SetKey{}
...@@ -633,8 +640,16 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -633,8 +640,16 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
} }
} }
// ΔBTestEntry represents one entry in ΔBTail tests.
// XXX -> ΔBTestCase?
type ΔBTestEntry struct {
tree string // next tree topology
kadjOK map[Key]SetKey // adjacency matrix against previous case
}
// testΔBTail verifies ΔBTail on sequence of tree topologies coming from testq. // testΔBTail verifies ΔBTail on sequence of tree topologies coming from testq.
func testΔBTail(t *testing.T, testq chan string) { func testΔBTail(t *testing.T, testq chan ΔBTestEntry) {
X := exc.Raiseif X := exc.Raiseif
work, err := ioutil.TempDir("", "δBTail"); X(err) work, err := ioutil.TempDir("", "δBTail"); X(err)
...@@ -683,13 +698,14 @@ func testΔBTail(t *testing.T, testq chan string) { ...@@ -683,13 +698,14 @@ func testΔBTail(t *testing.T, testq chan string) {
at1 := tg.head at1 := tg.head
xkv1 := XGetTree(db, at1, tg.treeRoot) xkv1 := XGetTree(db, at1, tg.treeRoot)
tree1 := "ø" // initial tree1 := "ø" // initial
for tree2 := range testq { for test := range testq {
tree2 := test.tree
δZ := XCommitTree(tree2) δZ := XCommitTree(tree2)
at2 := δZ.Tid at2 := δZ.Tid
xkv2 := XGetTree(db, at2, tg.treeRoot) xkv2 := XGetTree(db, at2, tg.treeRoot)
subj := fmt.Sprintf("%s -> %s", tree1, tree2) subj := fmt.Sprintf("%s -> %s", tree1, tree2)
xverifyΔBTail(t, subj, db, tg.treeRoot, at1,at2, xkv1,xkv2, δZ) xverifyΔBTail(t, subj, db, tg.treeRoot, at1,at2, xkv1,xkv2, δZ, test.kadjOK)
at1 = at2 at1 = at2
xkv1 = xkv2 xkv1 = xkv2
...@@ -752,11 +768,11 @@ func TestΔBTail(t *testing.T) { ...@@ -752,11 +768,11 @@ func TestΔBTail(t *testing.T) {
testv = append(testv, testv[i]) testv = append(testv, testv[i])
} }
testq := make(chan string) testq := make(chan ΔBTestEntry)
go func() { go func() {
defer close(testq) defer close(testq)
for _, tree := range testv { for _, tree := range testv {
testq <- tree testq <- ΔBTestEntry{tree, nil}
} }
}() }()
testΔBTail(t, testq) testΔBTail(t, testq)
...@@ -825,7 +841,7 @@ func TestΔBTreeAllStructs(t *testing.T) { ...@@ -825,7 +841,7 @@ func TestΔBTreeAllStructs(t *testing.T) {
return vv[i:i+1] return vv[i:i+1]
} }
testq := make(chan string) testq := make(chan ΔBTestEntry)
go func() { go func() {
defer close(testq) defer close(testq)
for i := range keysv1 { for i := range keysv1 {
...@@ -845,7 +861,7 @@ func TestΔBTreeAllStructs(t *testing.T) { ...@@ -845,7 +861,7 @@ func TestΔBTreeAllStructs(t *testing.T) {
} }
for _, tree := range treev { for _, tree := range treev {
testq <- tree testq <- ΔBTestEntry{tree, nil}
} }
} }
......
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