Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zodb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joshua
zodb
Commits
870f2d58
Commit
870f2d58
authored
Jul 04, 2016
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test that IMultiCommitStorages are supported
parent
572a9652
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
15 deletions
+41
-15
src/ZODB/DB.py
src/ZODB/DB.py
+7
-2
src/ZODB/tests/TransactionalUndoStorage.py
src/ZODB/tests/TransactionalUndoStorage.py
+6
-1
src/ZODB/tests/blob_transaction.txt
src/ZODB/tests/blob_transaction.txt
+1
-12
src/ZODB/tests/testFileStorage.py
src/ZODB/tests/testFileStorage.py
+27
-0
No files found.
src/ZODB/DB.py
View file @
870f2d58
...
@@ -1010,8 +1010,13 @@ class TransactionalUndo(object):
...
@@ -1010,8 +1010,13 @@ class TransactionalUndo(object):
self
.
_oids
.
update
(
result
[
1
])
self
.
_oids
.
update
(
result
[
1
])
def
tpc_vote
(
self
,
transaction
):
def
tpc_vote
(
self
,
transaction
):
for
oid
,
_
in
self
.
_storage
.
tpc_vote
(
transaction
)
or
():
result
=
self
.
_storage
.
tpc_vote
(
transaction
)
self
.
_oids
.
add
(
oid
)
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
):
def
tpc_finish
(
self
,
transaction
):
self
.
_storage
.
tpc_finish
(
self
.
_storage
.
tpc_finish
(
...
...
src/ZODB/tests/TransactionalUndoStorage.py
View file @
870f2d58
...
@@ -111,7 +111,12 @@ class TransactionalUndoStorage:
...
@@ -111,7 +111,12 @@ class TransactionalUndoStorage:
undo_result
=
self
.
_storage
.
undo
(
tid
,
t
)
undo_result
=
self
.
_storage
.
undo
(
tid
,
t
)
if
undo_result
:
if
undo_result
:
oids
.
extend
(
undo_result
[
1
])
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
return
oids
def
undo
(
self
,
tid
,
note
):
def
undo
(
self
,
tid
,
note
):
...
...
src/ZODB/tests/blob_transaction.txt
View file @
870f2d58
...
@@ -390,10 +390,6 @@ stored are discarded.
...
@@ -390,10 +390,6 @@ stored are discarded.
... '', t)
... '', t)
>>> serials = blob_storage.tpc_vote(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)
>>> blob_storage.tpc_abort(t)
...
@@ -402,14 +398,7 @@ Now, the serial for the existing blob should be the same:
...
@@ -402,14 +398,7 @@ Now, the serial for the existing blob should be the same:
>>> blob_storage.load(blob._p_oid, '') == (olddata, oldserial)
>>> blob_storage.load(blob._p_oid, '') == (olddata, oldserial)
True
True
And we shouldn't be able to read the data that we saved:
The old data should be unaffected:
>>> 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:
>>> with open(blob_storage.loadBlob(blob._p_oid, oldserial)) as fp:
>>> with open(blob_storage.loadBlob(blob._p_oid, oldserial)) as fp:
... fp.read()
... fp.read()
...
...
src/ZODB/tests/testFileStorage.py
View file @
870f2d58
...
@@ -36,6 +36,7 @@ from ZODB.tests import ReadOnlyStorage, RecoveryStorage
...
@@ -36,6 +36,7 @@ from ZODB.tests import ReadOnlyStorage, RecoveryStorage
from
ZODB.tests.StorageTestBase
import
MinPO
,
zodb_pickle
from
ZODB.tests.StorageTestBase
import
MinPO
,
zodb_pickle
from
ZODB._compat
import
dump
,
dumps
,
_protocol
from
ZODB._compat
import
dump
,
dumps
,
_protocol
from
..
import
multicommitadapter
class
FileStorageTests
(
class
FileStorageTests
(
StorageTestBase
.
StorageTestBase
,
StorageTestBase
.
StorageTestBase
,
...
@@ -322,6 +323,12 @@ class FileStorageHexTests(FileStorageTests):
...
@@ -322,6 +323,12 @@ class FileStorageHexTests(FileStorageTests):
self
.
_storage
=
ZODB
.
tests
.
hexstorage
.
HexStorage
(
self
.
_storage
=
ZODB
.
tests
.
hexstorage
.
HexStorage
(
ZODB
.
FileStorage
.
FileStorage
(
'FileStorageTests.fs'
,
**
kwargs
))
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
):
class
FileStorageTestsWithBlobsEnabled
(
FileStorageTests
):
...
@@ -331,6 +338,7 @@ class FileStorageTestsWithBlobsEnabled(FileStorageTests):
...
@@ -331,6 +338,7 @@ class FileStorageTestsWithBlobsEnabled(FileStorageTests):
kwargs
[
'blob_dir'
]
=
'blobs'
kwargs
[
'blob_dir'
]
=
'blobs'
FileStorageTests
.
open
(
self
,
**
kwargs
)
FileStorageTests
.
open
(
self
,
**
kwargs
)
class
FileStorageHexTestsWithBlobsEnabled
(
FileStorageTests
):
class
FileStorageHexTestsWithBlobsEnabled
(
FileStorageTests
):
def
open
(
self
,
**
kwargs
):
def
open
(
self
,
**
kwargs
):
...
@@ -340,6 +348,16 @@ class FileStorageHexTestsWithBlobsEnabled(FileStorageTests):
...
@@ -340,6 +348,16 @@ class FileStorageHexTestsWithBlobsEnabled(FileStorageTests):
FileStorageTests
.
open
(
self
,
**
kwargs
)
FileStorageTests
.
open
(
self
,
**
kwargs
)
self
.
_storage
=
ZODB
.
tests
.
hexstorage
.
HexStorage
(
self
.
_storage
)
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
(
class
FileStorageRecoveryTest
(
StorageTestBase
.
StorageTestBase
,
StorageTestBase
.
StorageTestBase
,
RecoveryStorage
.
RecoveryStorage
,
RecoveryStorage
.
RecoveryStorage
,
...
@@ -702,6 +720,7 @@ def test_suite():
...
@@ -702,6 +720,7 @@ def test_suite():
FileStorageNoRestoreRecoveryTest
,
FileStorageNoRestoreRecoveryTest
,
FileStorageTestsWithBlobsEnabled
,
FileStorageHexTestsWithBlobsEnabled
,
FileStorageTestsWithBlobsEnabled
,
FileStorageHexTestsWithBlobsEnabled
,
AnalyzeDotPyTest
,
AnalyzeDotPyTest
,
MultiFileStorageTests
,
MultiFileStorageTestsWithBlobsEnabled
,
]:
]:
suite
.
addTest
(
unittest
.
makeSuite
(
klass
,
"check"
))
suite
.
addTest
(
unittest
.
makeSuite
(
klass
,
"check"
))
suite
.
addTest
(
doctest
.
DocTestSuite
(
suite
.
addTest
(
doctest
.
DocTestSuite
(
...
@@ -723,6 +742,14 @@ def test_suite():
...
@@ -723,6 +742,14 @@ def test_suite():
test_blob_storage_recovery
=
True
,
test_blob_storage_recovery
=
True
,
test_packing
=
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
(
suite
.
addTest
(
PackableStorage
.
IExternalGC_suite
(
lambda
:
ZODB
.
FileStorage
.
FileStorage
(
lambda
:
ZODB
.
FileStorage
.
FileStorage
(
'data.fs'
,
blob_dir
=
'blobs'
,
pack_gc
=
False
)))
'data.fs'
,
blob_dir
=
'blobs'
,
pack_gc
=
False
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment