Commit bf8f6908 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 f97bd139
// Copyright (C) 2020 Nexedi SA and Contributors. // Copyright (C) 2020-2024 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // 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 // it under the terms of the GNU General Public License version 3, or (at your
...@@ -26,13 +26,14 @@ import ( ...@@ -26,13 +26,14 @@ import (
"net/url" "net/url"
"os" "os"
"os/exec" "os/exec"
"strings"
"testing" "testing"
"time" "time"
"lab.nexedi.com/kirr/neo/go/internal/xexec" "lab.nexedi.com/kirr/neo/go/internal/xexec"
"lab.nexedi.com/kirr/neo/go/internal/xtesting" "lab.nexedi.com/kirr/neo/go/internal/xtesting"
"lab.nexedi.com/kirr/neo/go/zodb" "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/xerr"
"lab.nexedi.com/kirr/go123/xnet" "lab.nexedi.com/kirr/go123/xnet"
...@@ -187,24 +188,41 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption ...@@ -187,24 +188,41 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption
} }
for _, msgpack := range []bool{false, true} { for _, msgpack := range []bool{false, true} {
// ZEO/py t.Run(fmt.Sprintf("msgpack=%v", msgpack), func(t *testing.T) {
t.Run(fmt.Sprintf("py/msgpack=%v", msgpack), func(t *testing.T) { // ZEO/py
t.Helper() xtesting.WithEachPy(t, func(t *testing.T) {
needpy := []string{"ZEO"} t.Helper()
if msgpack { needpy := []string{"ZEO"}
needpy = append(needpy, "msgpack") if msgpack {
needpy = append(needpy, "ZEO.asyncio") // FIXME hack to check that ZEO ver >= 5 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) { xtesting.NeedPy(t, needpy...)
X := xtesting.FatalIf(t) py2 := strings.HasSuffix(t.Name(), "/py2")
if !msgpack && !py2 {
zpy, err := StartZEOPySrv(fs1path, ZEOPyOptions{msgpack: msgpack}); X(err) t.Skip("xfail")
defer func() { }
err := zpy.Close(); X(err) withFS1(t, func(fs1path string) {
}() X := xtesting.FatalIf(t)
f(t, zpy) // 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) { ...@@ -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) { func TestLoad(t *testing.T) {
ztestdataReg.RunWithEach(t, _TestLoad)
}
func _TestLoad(t *testing.T, z *ZTestData) {
X := xtesting.FatalIf(t) X := xtesting.FatalIf(t)
data := "../fs1/testdata/1.fs" data := z.Path("1.fs")
txnvOk, err := xtesting.LoadDBHistory(data); X(err) txnvOk, err := xtesting.LoadDBHistory(data); X(err)
withZEO(t, func(t *testing.T, zsrv ZEOSrv, z *zeo) { 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