Commit d4a523b2 authored by Kirill Smelkov's avatar Kirill Smelkov

X δbtail: tests: Run much faster with live ZODB cache

        $ time go test -failfast -short -run 'ΔBTail/rebuild' >x

before:

        real    0m43,071s
        user    0m57,487s
        sys     0m4,869s

after:

        real    0m17,852s
        user    0m23,068s
        sys     0m1,825s
parent a6300c60
......@@ -10,7 +10,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
lab.nexedi.com/kirr/go123 v0.0.0-20210302025843-863c4602a230
lab.nexedi.com/kirr/neo/go v0.0.0-20210326102715-dc35035cdc18
lab.nexedi.com/kirr/neo/go v0.0.0-20210503113049-7fba56df234c
)
// we use kirr/go-fuse@y/nodefs-cancel
......
......@@ -191,3 +191,5 @@ lab.nexedi.com/kirr/neo/go v0.0.0-20210322184934-2888bbbcbe4b h1:JmC5mk3Mts39k6l
lab.nexedi.com/kirr/neo/go v0.0.0-20210322184934-2888bbbcbe4b/go.mod h1:llI3hcJJMACe+rYuXUfS5dljjwIrlBMfJ1ZeRcey96A=
lab.nexedi.com/kirr/neo/go v0.0.0-20210326102715-dc35035cdc18 h1:ysqIq6WqSMhCPbSRt3RnI1geV+chVkneXV7Wxn9zsEc=
lab.nexedi.com/kirr/neo/go v0.0.0-20210326102715-dc35035cdc18/go.mod h1:llI3hcJJMACe+rYuXUfS5dljjwIrlBMfJ1ZeRcey96A=
lab.nexedi.com/kirr/neo/go v0.0.0-20210503113049-7fba56df234c h1:+M4xtOKZqy7oC6L9CzdXi77PNI9KnohOEnEsHlmAPPE=
lab.nexedi.com/kirr/neo/go v0.0.0-20210503113049-7fba56df234c/go.mod h1:llI3hcJJMACe+rYuXUfS5dljjwIrlBMfJ1ZeRcey96A=
......@@ -2366,7 +2366,10 @@ func _main() (err error) {
at0 := zstor.AddWatch(zwatchq)
defer zstor.DelWatch(zwatchq)
zdb := zodb.NewDB(zstor)
// TODO consider using zodbCacheControl for all connections
// ( in addition to zhead, historic connections - that are used to access @rev -
// also need to traverse BigFile.blktab btree )
zdb := zodb.NewDB(zstor, &zodb.DBOptions{})
defer xclose(zdb)
zhead, err := zopen(ctx, zdb, &zodb.ConnOptions{
At: at0,
......
......@@ -44,7 +44,7 @@ func TestZBlk(t *testing.T) {
assert := require.New(t)
ctx := context.Background()
stor, err := zodb.Open(ctx, "testdata/zblk.fs", &zodb.OpenOptions{ReadOnly: true}); X(err)
db := zodb.NewDB(stor)
db := zodb.NewDB(stor, &zodb.DBOptions{})
defer func() {
err := db.Close(); X(err)
err = stor.Close(); X(err)
......
......@@ -1097,6 +1097,15 @@ type tTreeCommit struct {
// XXX do we also need δkv ?
}
// 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
}
// testΔBTail verifies ΔBTail on sequence of tree topologies coming from testq.
func testΔBTail(t *testing.T, testq chan ΔBTestEntry) {
X := exc.Raiseif
......@@ -1117,7 +1126,12 @@ func testΔBTail(t *testing.T, testq chan ΔBTestEntry) {
err := zstor.Close(); X(err)
}()
db := zodb.NewDB(zstor)
db := zodb.NewDB(zstor, &zodb.DBOptions{
// We need objects to be cached, because otherwise it is too
// slow to run the test for many testcases, especially
// xverifyΔBTail_rebuild.
CacheControl: &tZODBCacheEverything{},
})
defer func() {
err := db.Close(); X(err)
}()
......
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