Commit 613cc3c0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d37761bb
......@@ -37,7 +37,7 @@ import (
// T is tree-based testing environment.
//
// It combines TreeSrv and client side access to ZODB with committed trees.
// It should be created it NewT().
// It should be created via NewT().
type T struct {
*testing.T
......@@ -52,7 +52,7 @@ type T struct {
// Commit represent test commit changing a tree.
type Commit struct {
T *T // created via T.CommitTree
T *T // created via T.Commit
idx int // lives in .T.commitv[idx]
Tree string // the tree in topology-encoding
Prev *Commit // previous commit
......@@ -74,7 +74,7 @@ func NewT(t *testing.T) *T {
X := exc.Raiseif
t.Helper()
tt := &T{T: t, at0idx: 1 /* at₀ starts from first CommitTree */}
tt := &T{T: t, at0idx: 1 /* at₀ starts from first t.Commit */}
var err error
work := t.TempDir()
......@@ -120,7 +120,6 @@ func NewT(t *testing.T) *T {
// tZODBCacheEverything is workaround for ZODB/go not implementing real
// live cache for now: Objects get dropped on PDeactivate if cache
// control does not say we need the object to stay in the cache.
// XXX place
type tZODBCacheEverything struct{}
func (_ *tZODBCacheEverything) PCacheClassify(_ zodb.IPersistent) zodb.PCachePolicy {
return zodb.PCachePinObject | zodb.PCacheKeepState
......@@ -175,10 +174,8 @@ func (t *T) AtSymbReset(c *Commit, i int) {
t.at0idx = c.idx - i
}
// CommitTree calls t.treeSrv.Commit and returns Commit corresponding to committed transaction.
// XXX naming -> Commit ?
func (t *T) CommitTree(tree string) *Commit {
// TODO X = FatalIf
// Commit commits tree via treegen server and returns Commit object corresponding to committed transaction.
func (t *T) Commit(tree string) *Commit {
X := exc.Raiseif
defer exc.Contextf("commit %s", tree)
......
......@@ -558,7 +558,7 @@ func testΔBTail(t_ *testing.T, testq chan ΔBTestEntry) {
var t0 *xbtreetest.Commit
for test := range testq {
t1 := t.Head()
t2 := t.CommitTree(test.tree)
t2 := t.Commit(test.tree)
t.AtSymbReset(t2, 2)
subj := fmt.Sprintf("%s -> %s", t1.Tree, t2.Tree)
......@@ -1071,10 +1071,10 @@ func TestΔBtailForget(t_ *testing.T) {
t := xbtreetest.NewT(t_)
X := exc.Raiseif
t0 := t.CommitTree("T/B:")
t1 := t.CommitTree("T/B1:a")
t2 := t.CommitTree("T2/B1:a-B2:b")
t3 := t.CommitTree("T/B2:b")
t0 := t.Commit("T/B:")
t1 := t.Commit("T/B1:a")
t2 := t.Commit("T2/B1:a-B2:b")
t3 := t.Commit("T/B2:b")
δbtail := NewΔBtail(t0.At, t.DB)
_, err := δbtail.Update(t1.ΔZ); X(err)
......@@ -1123,12 +1123,12 @@ func TestΔBtailGetAt(t_ *testing.T) {
X := exc.Raiseif
const ø = "ø"
t.CommitTree("T/B:")
t1 := t.CommitTree("T/B2:b,3:c") ; at1 := t1.At // 2:b 3:c
t2 := t.CommitTree("T/B2:b,3:c,4:d") ; at2 := t2.At // 4:d
t3 := t.CommitTree("T/B2:b,3:e,4:d") ; at3 := t3.At // 3:e
t4 := t.CommitTree("T/B2:b,3:e,4:f") ; at4 := t4.At // 4:f
t5 := t.CommitTree("T/B2:b,3:g,4:f") ; at5 := t5.At // 3:g
t.Commit("T/B:")
t1 := t.Commit("T/B2:b,3:c") ; at1 := t1.At // 2:b 3:c
t2 := t.Commit("T/B2:b,3:c,4:d") ; at2 := t2.At // 4:d
t3 := t.Commit("T/B2:b,3:e,4:d") ; at3 := t3.At // 3:e
t4 := t.Commit("T/B2:b,3:e,4:f") ; at4 := t4.At // 4:f
t5 := t.Commit("T/B2:b,3:g,4:f") ; at5 := t5.At // 3:g
δBtail := NewΔBtail(t1.At, t.DB)
_, err := δBtail.Update(t2.ΔZ); X(err)
......@@ -1195,9 +1195,9 @@ func TestΔBtailSliceByRootRev(t_ *testing.T) {
// δ is shorthand for ΔT.KV
type δ = map[Key]Δstring
t0 := t.CommitTree("T2/B1:a-B2:f")
t1 := t.CommitTree("T2/B1:b-B2:g")
t2 := t.CommitTree("T2/B1:c-B2:h")
t0 := t.Commit("T2/B1:a-B2:f")
t1 := t.Commit("T2/B1:b-B2:g")
t2 := t.Commit("T2/B1:c-B2:h")
const a, b, c = "a", "b", "c"
const f, g, h = "f", "g", "h"
......@@ -1335,8 +1335,8 @@ func TestΔBtailClone(t_ *testing.T) {
t := xbtreetest.NewT(t_)
X := exc.Raiseif
t0 := t.CommitTree("T2/B1:a-B2:b")
t1 := t.CommitTree("T2/B1:c-B2:d")
t0 := t.Commit("T2/B1:a-B2:b")
t1 := t.Commit("T2/B1:c-B2:d")
δbtail := NewΔBtail(t0.At, t.DB)
_, err := δbtail.Update(t1.ΔZ); X(err)
_2 := setKey{}; _2.Add(2)
......@@ -1348,7 +1348,7 @@ func TestΔBtailClone(t_ *testing.T) {
δbklon := δbtail.Clone()
assertΔTtail(t.T, "klon @at1", δbklon, t1, t.Root(), δkv1_1)
t2 := t.CommitTree("T/B1:b,2:a")
t2 := t.Commit("T/B1:b,2:a")
_, err = δbtail.Update(t2.ΔZ); X(err)
δkv1_2 := map[Key]Δstring{1:{"a","c"}, 2:{"b","d"}}
......
......@@ -211,7 +211,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
// start δFtail when zfile does not yet exists
// this way we'll verify how ΔFtail rebuilds vδE for started-to-be-tracked file
t0 := t.CommitTree("øf")
t0 := t.Commit("øf")
t.Logf("# @%s (%s)", t0.AtSymb(), t0.At)
epochv = append(epochv, t0.At)
δFtail := NewΔFtail(t.Head().At, t.DB)
......@@ -219,7 +219,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
// create zfile, but do not track it yet
// vδf + friends will be updated after "load zfile"
δt1 := map[int64]string{0:"a"}
t1 := t.CommitTree(fmt.Sprintf("t%s D%s", xbtreetest.KVTxt(δt1), dataTabTxt(dataTab)))
t1 := t.Commit(fmt.Sprintf("t%s D%s", xbtreetest.KVTxt(δt1), dataTabTxt(dataTab)))
δblk1 := setI64{}
for blk := range δt1 {
δblk1.Add(blk)
......@@ -352,7 +352,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
} else {
req = fmt.Sprintf("t%s D%s", xbtreetest.KVTxt(blkTab), dataTabTxt(dataTab))
}
commit := t.CommitTree(req)
commit := t.Commit(req)
if newEpoch {
epochv = append(epochv, commit.At)
}
......@@ -589,19 +589,19 @@ func TestΔFtailSliceUntrackedUniform(t_ *testing.T) {
δFtail := NewΔFtail(at0, t.DB)
// commit t1. all 0, 1 and 2 are in the same bucket.
t1 := t.CommitTree("T/B0:a,1:b,2:c")
t1 := t.Commit("T/B0:a,1:b,2:c")
δF, err := δFtail.Update(t1.ΔZ); X(err)
t.assertΔF(δF, t1.At, nil) // δf empty
t2 := t.CommitTree("t0:d,1:e,2:c Da:a,b:b,c:c2,d:d,e:e") // 0:-a+d 1:-b+e δc₂
t2 := t.Commit("t0:d,1:e,2:c Da:a,b:b,c:c2,d:d,e:e") // 0:-a+d 1:-b+e δc₂
δF, err = δFtail.Update(t2.ΔZ); X(err)
t.assertΔF(δF, t2.At, nil)
t3 := t.CommitTree("t0:d,1:e,2:c Da:a,b:b,c:c3,d:d3,e:e3") // δc₃ δd₃ δe₃
t3 := t.Commit("t0:d,1:e,2:c Da:a,b:b,c:c3,d:d3,e:e3") // δc₃ δd₃ δe₃
δF, err = δFtail.Update(t3.ΔZ); X(err)
t.assertΔF(δF, t3.At, nil)
t4 := t.CommitTree("t0:d,1:e,2:c Da:a,b:b,c:c4,d:d3,e:e4") // δc₄ δe₄
t4 := t.Commit("t0:d,1:e,2:c Da:a,b:b,c:c4,d:d3,e:e4") // δc₄ δe₄
δF, err = δFtail.Update(t4.ΔZ); X(err)
t.assertΔF(δF, t4.At, 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