Commit 049cb9a0 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/zeo: Make "no serial on load after object deleted" to be a known bug

This turns zeo tests to pass.
The bug is reported upstream here: https://github.com/zopefoundation/ZODB/issues/318
parent d3bb1868
...@@ -209,17 +209,22 @@ func LoadDBHistory(zurl string) (_ []Txn, err error) { ...@@ -209,17 +209,22 @@ func LoadDBHistory(zurl string) (_ []Txn, err error) {
} }
// checkLoad verifies that zdrv.Load(xid) returns expected result. // checkLoad verifies that zdrv.Load(xid) returns expected result.
func checkLoad(t *testing.T, zdrv zodb.IStorageDriver, xid zodb.Xid, expect objState) { func checkLoad(t *testing.T, zdrv zodb.IStorageDriver, xid zodb.Xid, expect objState, bugs map[string]bool) {
t.Helper() t.Helper()
buf, tid, err := zdrv.Load(context.Background(), xid) buf, tid, err := zdrv.Load(context.Background(), xid)
// deleted obj - it should load with "no data" // deleted obj - it should load with "no data"
if expect.data == nil { if expect.data == nil {
var eNoData error = &zodb.NoDataError{Oid: xid.Oid, DeletedAt: expect.tid}
if bugs["load:noserial-after-deleted"] {
// https://github.com/zopefoundation/ZODB/issues/318
eNoData = &zodb.NoObjectError{Oid: xid.Oid}
}
errOk := &zodb.OpError{ errOk := &zodb.OpError{
URL: zdrv.URL(), URL: zdrv.URL(),
Op: "load", Op: "load",
Args: xid, Args: xid,
Err: &zodb.NoDataError{Oid: xid.Oid, DeletedAt: expect.tid}, Err: eNoData,
} }
if !reflect.DeepEqual(err, errOk) { if !reflect.DeepEqual(err, errOk) {
t.Errorf("load %v: returned err unexpected:\nhave: %v\nwant: %v", xid, err, errOk) t.Errorf("load %v: returned err unexpected:\nhave: %v\nwant: %v", xid, err, errOk)
...@@ -256,7 +261,12 @@ func checkLoad(t *testing.T, zdrv zodb.IStorageDriver, xid zodb.Xid, expect objS ...@@ -256,7 +261,12 @@ func checkLoad(t *testing.T, zdrv zodb.IStorageDriver, xid zodb.Xid, expect objS
// DrvTestLoad verifies that zdrv implements Load correctly. // DrvTestLoad verifies that zdrv implements Load correctly.
// //
// txnvOk is what data to expect to be in the database. // txnvOk is what data to expect to be in the database.
func DrvTestLoad(t *testing.T, zdrv zodb.IStorageDriver, txnvOk []Txn) { func DrvTestLoad(t *testing.T, zdrv zodb.IStorageDriver, txnvOk []Txn, bugv ...string) {
bugs := map[string]bool{}
for _, bug := range bugv {
bugs[bug] = true
}
// current knowledge of what was "before" for an oid as we scan over // current knowledge of what was "before" for an oid as we scan over
// data base entries // data base entries
before := map[zodb.Oid]objState{} before := map[zodb.Oid]objState{}
...@@ -269,13 +279,13 @@ func DrvTestLoad(t *testing.T, zdrv zodb.IStorageDriver, txnvOk []Txn) { ...@@ -269,13 +279,13 @@ func DrvTestLoad(t *testing.T, zdrv zodb.IStorageDriver, txnvOk []Txn) {
// ~ loadSerial // ~ loadSerial
xid := zodb.Xid{txh.Tid, obj.Oid} xid := zodb.Xid{txh.Tid, obj.Oid}
checkLoad(t, zdrv, xid, objState{txh.Tid, obj.Data}) checkLoad(t, zdrv, xid, objState{txh.Tid, obj.Data}, bugs)
// ~ loadBefore // ~ loadBefore
xid = zodb.Xid{txh.Tid - 1, obj.Oid} xid = zodb.Xid{txh.Tid - 1, obj.Oid}
expect, ok := before[obj.Oid] expect, ok := before[obj.Oid]
if ok { if ok {
checkLoad(t, zdrv, xid, expect) checkLoad(t, zdrv, xid, expect, bugs)
} }
before[obj.Oid] = objState{txh.Tid, obj.Data} before[obj.Oid] = objState{txh.Tid, obj.Data}
...@@ -287,7 +297,7 @@ func DrvTestLoad(t *testing.T, zdrv zodb.IStorageDriver, txnvOk []Txn) { ...@@ -287,7 +297,7 @@ func DrvTestLoad(t *testing.T, zdrv zodb.IStorageDriver, txnvOk []Txn) {
// XXX should we get "no such transaction" with at > head? - yes // XXX should we get "no such transaction" with at > head? - yes
for oid, expect := range before { for oid, expect := range before {
xid := zodb.Xid{zodb.TidMax, oid} xid := zodb.Xid{zodb.TidMax, oid}
checkLoad(t, zdrv, xid, expect) checkLoad(t, zdrv, xid, expect, bugs)
} }
} }
......
...@@ -44,6 +44,7 @@ type ZEOSrv interface { ...@@ -44,6 +44,7 @@ type ZEOSrv interface {
Close() error Close() error
Encoding() encoding // encoding used on the wire - 'M' or 'Z' Encoding() encoding // encoding used on the wire - 'M' or 'Z'
Bugs() []string // list of known server bugs
} }
// ZEOPySrv represents running ZEO/py server. // ZEOPySrv represents running ZEO/py server.
...@@ -58,6 +59,14 @@ type ZEOPySrv struct { ...@@ -58,6 +59,14 @@ type ZEOPySrv struct {
errExit error // error from Wait errExit error // error from Wait
} }
func (_ *ZEOPySrv) Bugs() []string {
return []string{
// ZODB/py does not return serial for loadBefore after object was deleted
// https://github.com/zopefoundation/ZODB/issues/318
"load:noserial-after-deleted",
}
}
type ZEOPyOptions struct { type ZEOPyOptions struct {
msgpack bool // whether to advertise msgpack msgpack bool // whether to advertise msgpack
} }
...@@ -200,7 +209,7 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption ...@@ -200,7 +209,7 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption
} }
// withZEO tests f on all kinds of ZEO servers connected to by ZEO client. // withZEO tests f on all kinds of ZEO servers connected to by ZEO client.
func withZEO(t *testing.T, f func(t *testing.T, zdrv *zeo), optv ...tOptions) { func withZEO(t *testing.T, f func(t *testing.T, zsrv ZEOSrv, zdrv *zeo), optv ...tOptions) {
t.Helper() t.Helper()
withZEOSrv(t, func(t *testing.T, zsrv ZEOSrv) { withZEOSrv(t, func(t *testing.T, zsrv ZEOSrv) {
t.Helper() t.Helper()
...@@ -210,7 +219,7 @@ func withZEO(t *testing.T, f func(t *testing.T, zdrv *zeo), optv ...tOptions) { ...@@ -210,7 +219,7 @@ func withZEO(t *testing.T, f func(t *testing.T, zdrv *zeo), optv ...tOptions) {
err := zdrv.Close(); X(err) err := zdrv.Close(); X(err)
}() }()
f(t, zdrv) f(t, zsrv, zdrv)
}, optv...) }, optv...)
} }
...@@ -237,8 +246,8 @@ func TestLoad(t *testing.T) { ...@@ -237,8 +246,8 @@ func TestLoad(t *testing.T) {
data := "../fs1/testdata/1.fs" data := "../fs1/testdata/1.fs"
txnvOk, err := xtesting.LoadDBHistory(data); X(err) txnvOk, err := xtesting.LoadDBHistory(data); X(err)
withZEO(t, func(t *testing.T, z *zeo) { withZEO(t, func(t *testing.T, zsrv ZEOSrv, z *zeo) {
xtesting.DrvTestLoad(t, z, txnvOk) xtesting.DrvTestLoad(t, z, txnvOk, zsrv.Bugs()...)
}, tOptions{ }, tOptions{
Preload: data, Preload: data,
}) })
......
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