Commit c3257579 authored by Kirill Smelkov's avatar Kirill Smelkov

tests: Fix ztestdata-related tests on ZODB4

In bf772ce0 I introduced ztestdata fixture and we added several tests
that use this fixture instead of only zext fixture. But contrary to zext
I missed to corresponding xfail if underlying ZODB is ZODB4 and does not
support access to raw extension bytes. As the result several tests
started to fail with ZODB4, because on such ZODB extension is only
dumped via heuristic and on best-effort basis and that cannot match
original extension data bit to bit exactly:

https://lab.nexedi.com/nexedi/zodbtools/-/blob/36cba871/zodbtools/zodbdump.py#L93-102

One example failure is here:

https://erp5js.nexedi.net/#/test_result_module/20241017-58899E0D/2

-> Fix that by xfailing in both zext and ztestdata fixtures
consistently.
Co-authored-by: Jérome Perrin's avatarJérome Perrin <jerome@nexedi.com>
parent b0fdb5fe
[pytest]
markers =
need_zext_support: mark a test using ztestdata requiring extension_bytes support in ZODB. If ZODB version does not support extension_bytes, the test will be marked xfail
......@@ -50,6 +50,8 @@ def ztestdata(request): # -> ZTestData
_.name = name
_.zext = zext
_.zkind = zkind
if zext and request.node.get_closest_marker("need_zext_support"):
_xfail_if_zext_unsupported(request)
return _
class ZTestData(object):
......@@ -96,11 +98,15 @@ def zext(request):
def _(ext):
return ext
_.disabled = False
if not zext_supported():
request.applymarker(pytest.mark.xfail(reason='ZODB does not have txn.extension_bytes support'))
_xfail_if_zext_unsupported(request)
return _
# _xfail_if_zext_unsupported applies xfail marker to request if zext is not supported by ZODB.
def _xfail_if_zext_unsupported(request):
if not zext_supported():
request.applymarker(pytest.mark.xfail(reason='ZODB does not have txn.extension_bytes support'))
# TestZSrv is base class for all test ZODB storages.
class TestZSrv(object):
......
......@@ -35,6 +35,7 @@ from six import PY3
# verify zodbdump output against golden
@mark.need_zext_support
@mark.parametrize('pretty', ('raw', 'zpickledis'))
def test_zodbdump(tmpdir, ztestdata, pretty):
tfs1 = fs1_testdata_py23(tmpdir, '%s/data.fs' % ztestdata.prefix)
......
......@@ -24,9 +24,11 @@ from zodbtools.zodbrestore import zodbrestore
from zodbtools.util import storageFromURL, readfile
from zodbtools.test.testutil import fs1_testdata_py23
from pytest import mark
from golang import func, defer
# verify zodbrestore.
@mark.need_zext_support
@func
def test_zodbrestore(tmpdir, ztestdata):
# restore from zdump.ok and verify it gives result that is
......
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