Commit dd1073fa authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/zeo: Test it on all py2/py3 ZODB kinds of data we care about and wrt...

go/zodb/zeo: Test it on all py2/py3 ZODB kinds of data we care about and wrt both ZEO/py2 and ZEO/py3

Similarly to FileStorage, fs1tools and other Go packages previously we
were testing ZEO/go client only with old FileStorage testdata generated
by python2 and pickle protocol=2. However even on py2 there are more
pickle protocols that are in use, and also there is python3.

We were also testing our ZEO/go client only wrt ZEO/py2 but there is
also ZEO/py3.

-> Adjust ZEO/go testing to automatically load and test against all ZODB
kinds from recently updated FileStorage testdata and wrt both ZEO/py2
and ZEO/py3.

All py2_pickle1, py2_pickle2, py2_pickle3 and py3_pickle3 are handled well out of the box.
However only ZEO/py2 succeeds: tests wrt ZEO/py3 server currently fail
and so are marked with "xfail".

We will fix tests for ZEO/py3 in the next patch.
parent 735c8f3a
// Copyright (C) 2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Copyright (C) 2020-2024 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
......@@ -26,13 +26,14 @@ import (
"net/url"
"os"
"os/exec"
"strings"
"testing"
"time"
"lab.nexedi.com/kirr/neo/go/internal/xexec"
"lab.nexedi.com/kirr/neo/go/internal/xtesting"
"lab.nexedi.com/kirr/neo/go/zodb"
_ "lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet"
......@@ -187,24 +188,41 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption
}
for _, msgpack := range []bool{false, true} {
// ZEO/py
t.Run(fmt.Sprintf("py/msgpack=%v", msgpack), func(t *testing.T) {
t.Helper()
needpy := []string{"ZEO"}
if msgpack {
needpy = append(needpy, "msgpack")
needpy = append(needpy, "ZEO.asyncio") // FIXME hack to check that ZEO ver >= 5
}
xtesting.NeedPy(t, needpy...)
withFS1(t, func(fs1path string) {
X := xtesting.FatalIf(t)
zpy, err := StartZEOPySrv(fs1path, ZEOPyOptions{msgpack: msgpack}); X(err)
defer func() {
err := zpy.Close(); X(err)
}()
f(t, zpy)
t.Run(fmt.Sprintf("msgpack=%v", msgpack), func(t *testing.T) {
// ZEO/py
xtesting.WithEachPy(t, func(t *testing.T) {
t.Helper()
needpy := []string{"ZEO"}
if msgpack {
needpy = append(needpy, "msgpack")
needpy = append(needpy, "ZEO.asyncio") // FIXME hack to check that ZEO ver >= 5
}
xtesting.NeedPy(t, needpy...)
py2 := strings.HasSuffix(t.Name(), "/py2")
if !msgpack && !py2 {
t.Skip("xfail")
}
withFS1(t, func(fs1path string) {
X := xtesting.FatalIf(t)
// adjust FileStorage magic to match current python because FileStorage/py
// rejects to open data created under different major version of python
if opt.Preload != "" {
magic := fs1.Magic30
if py2 {
magic = fs1.Magic21
}
fs1, err := os.OpenFile(fs1path, os.O_RDWR, 0); X(err)
_, err = fs1.WriteAt([]byte(magic), 0); X(err)
}
zpy, err := StartZEOPySrv(fs1path, ZEOPyOptions{msgpack: msgpack}); X(err)
defer func() {
err := zpy.Close(); X(err)
}()
f(t, zpy)
})
})
})
}
......@@ -252,10 +270,22 @@ func TestEmptyDB(t *testing.T) {
})
}
// ztestdataReg keeps registry of ZODB test data we use in tests with non-empty Preload.
// we take the data from fs1 testdata.
var ztestdataReg = xtesting.ZTestDataRegistry[struct{}]{}
type ZTestData = xtesting.ZTestData[struct{}]
func init() {
ztestdataReg = xtesting.LoadZTestData("../fs1/testdata")
}
func TestLoad(t *testing.T) {
ztestdataReg.RunWithEach(t, _TestLoad)
}
func _TestLoad(t *testing.T, z *ZTestData) {
X := xtesting.FatalIf(t)
data := "../fs1/testdata/1.fs"
data := z.Path("1.fs")
txnvOk, err := xtesting.LoadDBHistory(data); X(err)
withZEO(t, func(t *testing.T, zsrv ZEOSrv, z *zeo) {
......
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