Commit 28a7db7f authored by Levin Zimmermann's avatar Levin Zimmermann Committed by Kirill Smelkov

test_zodb/zsync: Fix ZEO storage synchronization

Before this patch 'zsync(storage)' was effectless for ZEO storages, it
didn't synchronize the client with the server. This patch fixes 'zsync',
so that it also performs synchronization of ZEO clients.

Background information:

2006 the sync mode of ZEO has been removed:


and only async mode was supported from then. This means, that the "sync"
method of ZEO.ClientStorage was in fact effectless. In ZEO 5 the
"server-sync" option has been added:

Setting this option to 'True' makes the 'sync' method performing a
"server round trip, thus causing client to wait for outstanding
invalidations" [1]. In this patch we imitate the effect of this flag
for both ZEO 4 and ZEO 5.



/reviewed-by @kirr
/reviewed-on nexedi/wendelin.core!13
parent adffe247
......@@ -30,6 +30,7 @@ from transaction import TransactionManager
from golang import defer, func
from pytest import raises
import pytest; xfail = pytest.mark.xfail
from ZEO.ClientStorage import ClientStorage as ZEOStorage
from wendelin.lib.tests.testprog import zopenrace, zloadrace
......@@ -433,6 +434,16 @@ def test_zodb_zloadrace():
# zsync syncs ZODB storage.
# it is noop, if zstor does not support syncing (i.e. FileStorage has no .sync())
def zsync(zstor):
# ZEOs default sync is effectless. We explicitly need to sync by
# pinging to the server. For ZEO 5 it would actually be sufficient
# to set init parameter 'server_sync' to 'True':
# But because our storage is already initiated this doesn't help.
if isinstance(zstor, ZEOStorage):
# ZEO >= 5 specifies ping
# ZEO < 5: we need to provide a ping method
getattr(zstor, 'ping', lambda: zstor._server.lastTransaction())()
sync = getattr(zstor, 'sync', None)
if sync is not None:
......@@ -394,7 +394,11 @@ setup(
extras_require = {
'test': ['pytest', 'scipy'],
'test': [
'ZEO', # lib/tests/
cmdclass = {'build_dso': build_dso,
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment