Commit 870f2d58 authored by Jim Fulton's avatar Jim Fulton

Test that IMultiCommitStorages are supported

parent 572a9652
......@@ -1010,7 +1010,12 @@ class TransactionalUndo(object):
self._oids.update(result[1])
def tpc_vote(self, transaction):
for oid, _ in self._storage.tpc_vote(transaction) or ():
result = self._storage.tpc_vote(transaction)
if result:
if isinstance(result[0], bytes):
self._oids.update(set(result))
else:
for oid, _ in result:
self._oids.add(oid)
def tpc_finish(self, transaction):
......
......@@ -111,7 +111,12 @@ class TransactionalUndoStorage:
undo_result = self._storage.undo(tid, t)
if undo_result:
oids.extend(undo_result[1])
oids.extend(oid for (oid, _) in self._storage.tpc_vote(t) or ())
v = self._storage.tpc_vote(t)
if v:
if isinstance(v[0], bytes):
oids.extend(v)
else:
oids.extend(oid for (oid, _) in v)
return oids
def undo(self, tid, note):
......
......@@ -390,10 +390,6 @@ stored are discarded.
... '', t)
>>> serials = blob_storage.tpc_vote(t)
>>> if s1 is None:
... s1 = [s for (oid, s) in serials if oid == blob._p_oid][0]
>>> if s2 is None:
... s2 = [s for (oid, s) in serials if oid == new_oid][0]
>>> blob_storage.tpc_abort(t)
......@@ -402,14 +398,7 @@ Now, the serial for the existing blob should be the same:
>>> blob_storage.load(blob._p_oid, '') == (olddata, oldserial)
True
And we shouldn't be able to read the data that we saved:
>>> blob_storage.loadBlob(blob._p_oid, s1)
Traceback (most recent call last):
...
POSKeyError: 'No blob file at <BLOB STORAGE PATH>'
Of course the old data should be unaffected:
The old data should be unaffected:
>>> with open(blob_storage.loadBlob(blob._p_oid, oldserial)) as fp:
... fp.read()
......
......@@ -36,6 +36,7 @@ from ZODB.tests import ReadOnlyStorage, RecoveryStorage
from ZODB.tests.StorageTestBase import MinPO, zodb_pickle
from ZODB._compat import dump, dumps, _protocol
from .. import multicommitadapter
class FileStorageTests(
StorageTestBase.StorageTestBase,
......@@ -322,6 +323,12 @@ class FileStorageHexTests(FileStorageTests):
self._storage = ZODB.tests.hexstorage.HexStorage(
ZODB.FileStorage.FileStorage('FileStorageTests.fs',**kwargs))
class MultiFileStorageTests(FileStorageTests):
def open(self, **kwargs):
self._storage = multicommitadapter.MultiCommitAdapter(
ZODB.FileStorage.FileStorage('FileStorageTests.fs', **kwargs))
class FileStorageTestsWithBlobsEnabled(FileStorageTests):
......@@ -331,6 +338,7 @@ class FileStorageTestsWithBlobsEnabled(FileStorageTests):
kwargs['blob_dir'] = 'blobs'
FileStorageTests.open(self, **kwargs)
class FileStorageHexTestsWithBlobsEnabled(FileStorageTests):
def open(self, **kwargs):
......@@ -340,6 +348,16 @@ class FileStorageHexTestsWithBlobsEnabled(FileStorageTests):
FileStorageTests.open(self, **kwargs)
self._storage = ZODB.tests.hexstorage.HexStorage(self._storage)
class MultiFileStorageTestsWithBlobsEnabled(MultiFileStorageTests):
def open(self, **kwargs):
if 'blob_dir' not in kwargs:
kwargs = kwargs.copy()
kwargs['blob_dir'] = 'blobs'
MultiFileStorageTests.open(self, **kwargs)
class FileStorageRecoveryTest(
StorageTestBase.StorageTestBase,
RecoveryStorage.RecoveryStorage,
......@@ -702,6 +720,7 @@ def test_suite():
FileStorageNoRestoreRecoveryTest,
FileStorageTestsWithBlobsEnabled, FileStorageHexTestsWithBlobsEnabled,
AnalyzeDotPyTest,
MultiFileStorageTests, MultiFileStorageTestsWithBlobsEnabled,
]:
suite.addTest(unittest.makeSuite(klass, "check"))
suite.addTest(doctest.DocTestSuite(
......@@ -723,6 +742,14 @@ def test_suite():
test_blob_storage_recovery=True,
test_packing=True,
))
suite.addTest(ZODB.tests.testblob.storage_reusable_suite(
'BlobMultiFileStorage',
lambda name, blob_dir:
multicommitadapter.MultiCommitAdapter(
ZODB.FileStorage.FileStorage('%s.fs' % name, blob_dir=blob_dir)),
test_blob_storage_recovery=True,
test_packing=True,
))
suite.addTest(PackableStorage.IExternalGC_suite(
lambda : ZODB.FileStorage.FileStorage(
'data.fs', blob_dir='blobs', pack_gc=False)))
......
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