Commit 70cd471f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f72e9137
......@@ -50,6 +50,7 @@ cdef extern from * nogil:
const bigfile_ops ZBigFile_mmap_ops
import wcfs as pywcfs
from wendelin.lib import zodb as pyzodb
from wcfs.client cimport _wcfs as wcfs
from golang cimport error, nil, pyerror
from cpython cimport PyCapsule_New
......@@ -139,7 +140,7 @@ cdef wcfs.PyConn pywconnOf(zconn):
# zconn is not yet associated with wconn
zstor = zconn.db().storage
zurl = pywcfs.zstor_2zurl(zstor)
zurl = pyzodb.zstor_2zurl(zstor)
wc = pywcfs.join(zurl)
wconn = wc.connect(zconn_at(zconn))
......
......@@ -17,7 +17,7 @@
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
from wendelin.lib.zodb import LivePersistent, deactivate_btree, dbclose, zconn_at
from wendelin.lib.zodb import LivePersistent, deactivate_btree, dbclose, zconn_at, zstor_2zurl
from wendelin.lib.testing import getTestDB
from persistent import Persistent, UPTODATE, GHOST, CHANGED
from ZODB import DB, POSException
......@@ -349,6 +349,19 @@ def test_zodb_onresync():
conn.close()
# test that zurl does not change from one open to another storage open.
def test_zurlstable():
zurl0 = None
for i in range(10):
zstor = testdb.getZODBStorage()
zurl = zstor_2zurl(zstor)
zstor.close()
if i == 0:
zurl0 = zurl
else:
assert zurl == zurl0
# ---- misc ----
# zsync syncs ZODB storage.
......
......@@ -299,3 +299,20 @@ elif zmajor == 4:
# ZODB3: TODO
else:
pass # raises in onResyncCallback
# zstor_2zurl converts a ZODB storage to URL to access it.
def zstor_2zurl(zstor):
# There is, sadly, no unified way to do it, as even if storages are created via
# zodburi, after creation its uri is lost. And storages could be created not
# only through URI but e.g. via ZConfig and manually. We want to support all
# those cases...
#
# For this reason extract URL with important for wcfs use-case parameters in
# ad-hoc way.
if isinstance(zstor, FileStorage):
return "file://%s" % (zstor._file_name,)
# TODO ZEO + NEO support
raise NotImplementedError("don't know how to extract zurl from %r" % zstor)
......@@ -286,23 +286,6 @@ def _mntpt_4zurl(zurl):
return mntpt
# zstor_2zurl converts a ZODB storage to URL to access it.
# XXX -> unexport?
def zstor_2zurl(zstor):
# There is, sadly, no unified way to do it, as even if storages are created via
# zodburi, after creation its uri is lost. And storages could be created not
# only through URI but e.g. via ZConfig and manually. We want to support all
# those cases...
#
# For this reason extract URL with important for wcfs use-case parameters in
# ad-hoc way.
if isinstance(zstor, FileStorage):
return "file://%s" % (zstor._file_name,)
# TODO ZEO + NEO support
raise NotImplementedError("don't know how to extract zurl from %r" % zstor)
# mkdir -p.
def _mkdir_p(path):
try:
......
......@@ -92,7 +92,11 @@ cdef sync.Mutex mustfaultMu # one at a time as sigaction is per-process
cdef sigjmp_buf mustfaultJmp
cdef cbool faultExpected = False
cdef cbool faultedOk = False
cdef unsigned char mustfaultG # global var for compiler not to optimize-out p[0] access
cdef extern from * nogil:
"""
volatile unsigned char mustfaultG; // global var for compiler not to optimize-out p[0] access
"""
unsigned char mustfaultG
cdef void mustfaultSighand(int sig) nogil:
global faultedOk
......@@ -105,7 +109,7 @@ cdef void mustfaultSighand(int sig) nogil:
siglongjmp(mustfaultJmp, 1)
cdef void _read_mustfault(const unsigned char *p) nogil except +topyexc:
global faultExpected, faultedOk
global faultExpected, faultedOk, mustfaultG
cdef sigaction_t act, saveact
act.sa_handler = mustfaultSighand
......
......@@ -29,7 +29,7 @@ wcfs.py/wcfs.go while running tox tests in wcfs mode.
from __future__ import print_function, absolute_import
from wendelin.lib.testing import getTestDB
from wendelin.lib.zodb import dbclose
from wendelin.lib.zodb import dbclose, zstor_2zurl
from wendelin.lib.mem import memcpy
from wendelin.bigfile.file_zodb import ZBigFile
from wendelin.bigfile.tests.test_filezodb import blksize
......@@ -80,7 +80,7 @@ def setup_module():
testdb.setup()
zstor = testdb.getZODBStorage()
testzurl = wcfs.zstor_2zurl(zstor)
testzurl = zstor_2zurl(zstor)
zstor.close()
testmntpt = wcfs._mntpt_4zurl(testzurl)
os.rmdir(testmntpt)
......@@ -104,14 +104,6 @@ def teardown_function(f):
# ---- test join/autostart ----
# test that zurl does not change from one open to another storage open.
def test_zurlstable():
for i in range(10):
zstor = testdb.getZODBStorage()
zurl = wcfs.zstor_2zurl(zstor)
zstor.close()
assert zurl == testzurl
# test that join works.
@func
def test_join():
......
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