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) {
}
// 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()
buf, tid, err := zdrv.Load(context.Background(), xid)
// deleted obj - it should load with "no data"
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{
URL: zdrv.URL(),
Op: "load",
Args: xid,
Err: &zodb.NoDataError{Oid: xid.Oid, DeletedAt: expect.tid},
Err: eNoData,
}
if !reflect.DeepEqual(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
// DrvTestLoad verifies that zdrv implements Load correctly.
//
// 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
// data base entries
before := map[zodb.Oid]objState{}
......@@ -269,13 +279,13 @@ func DrvTestLoad(t *testing.T, zdrv zodb.IStorageDriver, txnvOk []Txn) {
// ~ loadSerial
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
xid = zodb.Xid{txh.Tid - 1, obj.Oid}
expect, ok := before[obj.Oid]
if ok {
checkLoad(t, zdrv, xid, expect)
checkLoad(t, zdrv, xid, expect, bugs)
}
before[obj.Oid] = objState{txh.Tid, obj.Data}
......@@ -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
for oid, expect := range before {
xid := zodb.Xid{zodb.TidMax, oid}
checkLoad(t, zdrv, xid, expect)
checkLoad(t, zdrv, xid, expect, bugs)
}
}
......
......@@ -44,6 +44,7 @@ type ZEOSrv interface {
Close() error
Encoding() encoding // encoding used on the wire - 'M' or 'Z'
Bugs() []string // list of known server bugs
}
// ZEOPySrv represents running ZEO/py server.
......@@ -58,6 +59,14 @@ type ZEOPySrv struct {
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 {
msgpack bool // whether to advertise msgpack
}
......@@ -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.
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()
withZEOSrv(t, func(t *testing.T, zsrv ZEOSrv) {
t.Helper()
......@@ -210,7 +219,7 @@ func withZEO(t *testing.T, f func(t *testing.T, zdrv *zeo), optv ...tOptions) {
err := zdrv.Close(); X(err)
}()
f(t, zdrv)
f(t, zsrv, zdrv)
}, optv...)
}
......@@ -237,8 +246,8 @@ func TestLoad(t *testing.T) {
data := "../fs1/testdata/1.fs"
txnvOk, err := xtesting.LoadDBHistory(data); X(err)
withZEO(t, func(t *testing.T, z *zeo) {
xtesting.DrvTestLoad(t, z, txnvOk)
withZEO(t, func(t *testing.T, zsrv ZEOSrv, z *zeo) {
xtesting.DrvTestLoad(t, z, txnvOk, zsrv.Bugs()...)
}, tOptions{
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