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:

  nexedi/ZEO@629b0667

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:

  https://github.com/zopefoundation/ZEO/pull/63

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.

[1] https://github.com/zopefoundation/ZEO/blob/423cb8563be3e1ee0bb4297ee980d9b74f09c710/src/ZEO/ClientStorage.py#L225-L226

---

/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':
# https://github.com/zopefoundation/ZEO/blob/423cb8/src/ZEO/ClientStorage.py#L224-L246
# But because our storage is already initiated this doesn't help.
if isinstance(zstor, ZEOStorage):
# ZEO >= 5 specifies ping
# https://github.com/zopefoundation/ZEO/blob/423cb8/src/ZEO/ClientStorage.py#L472-L478
# 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:
sync()
......@@ -394,7 +394,11 @@ setup(
],
extras_require = {
'test': ['pytest', 'scipy'],
'test': [
'pytest',
'scipy',
'ZEO', # lib/tests/test_zodb.py
],
},
cmdclass = {'build_dso': build_dso,
......
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