Commit 30e2b1be 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 python 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 agains 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 fails
and so are marked with "xfail".

We will fix tests for ZEO/py3 in the next patch.
parent 1cdbed0c
// 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
...@@ -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,8 +188,9 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption ...@@ -187,8 +188,9 @@ 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} {
t.Run(fmt.Sprintf("msgpack=%v", msgpack), func(t *testing.T) {
// ZEO/py // ZEO/py
t.Run(fmt.Sprintf("py/msgpack=%v", msgpack), func(t *testing.T) { xtesting.WithEachPy(t, func(t *testing.T) {
t.Helper() t.Helper()
needpy := []string{"ZEO"} needpy := []string{"ZEO"}
if msgpack { if msgpack {
...@@ -196,9 +198,24 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption ...@@ -196,9 +198,24 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption
needpy = append(needpy, "ZEO.asyncio") // FIXME hack to check that ZEO ver >= 5 needpy = append(needpy, "ZEO.asyncio") // FIXME hack to check that ZEO ver >= 5
} }
xtesting.NeedPy(t, needpy...) xtesting.NeedPy(t, needpy...)
py2 := strings.HasSuffix(t.Name(), "/py2")
if !msgpack && !py2 {
t.Skip("xfail")
}
withFS1(t, func(fs1path string) { withFS1(t, func(fs1path string) {
X := xtesting.FatalIf(t) 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) zpy, err := StartZEOPySrv(fs1path, ZEOPyOptions{msgpack: msgpack}); X(err)
defer func() { defer func() {
err := zpy.Close(); X(err) err := zpy.Close(); X(err)
...@@ -207,6 +224,7 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption ...@@ -207,6 +224,7 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption
f(t, zpy) 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