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
nexedi
ZODB
Commits
4495c5a2
Commit
4495c5a2
authored
May 01, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some simple synchronization sanity tests
parent
40f502f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
0 deletions
+122
-0
src/ZODB/tests/Synchronization.py
src/ZODB/tests/Synchronization.py
+122
-0
No files found.
src/ZODB/tests/Synchronization.py
0 → 100644
View file @
4495c5a2
"""Test the storage's implemenetation of the storage synchronization spec.
The Synchronization spec
http://www.zope.org/Documentation/Developer/Models/ZODB/
ZODB_Architecture_Storage_Interface_State_Synchronization_Diag.html
It specifies two states committing and non-committing. A storage
starts in the non-committing state. tpc_begin() transfers to the
committting state; tpc_abort() and tpc_finish() transfer back to
non-committing.
Several other methods are only allowed in one state or another. Many
methods allowed only in the committing state require that they apply
to the currently committing transaction.
The spec is silent on a variety of methods that don't appear to modify
the state, e.g. load(), undoLog(), pack(). It's unclear whether there
is a separate set of synchronization rules that apply to these methods
or if the synchronization is implementation dependent, i.e. only what
is need to guarantee a corrected implementation.
The synchronization spec is also silent on whether there is any
contract implied with the caller. If the storage can assume that a
single client is single-threaded and that it will not call, e.g., store()
until after it calls tpc_begin(), the implementation can be
substantially simplified.
New and/or unspecified methods:
tpc_vote(): handled like tpc_abort
transactionalUndo(): handled like undo() (which is how?)
Methods that have nothing to do with committing/non-committing:
load(), loadSerial(), getName(), getSize(), __len__(), history(),
undoLog(), modifiedInVersion(), versionEmpty(), versions(), pack().
Specific questions:
The spec & docs say that undo() takes three arguments, the second
being a transaction. If the specified arg isn't the current
transaction, the undo() should raise StorageTransactionError. This
isn't implemented anywhere. It looks like undo can be called at
anytime.
FileStorage does not allow undo() during a pack. How should this be
tested? Is it a general restriction?
"""
from
ZODB.Transaction
import
Transaction
from
ZODB.POSException
import
StorageTransactionError
VERSION
=
"testversion"
OID
=
"
\
000
"
*
8
SERIALNO
=
"
\
000
"
*
8
TID
=
"
\
000
"
*
8
class
SynchronizedStorage
:
def
verifyCommitting
(
self
,
callable
,
*
args
):
self
.
assertRaises
(
StorageTransactionError
,
callable
*
args
)
def
verifyNotCommitting
(
self
,
callable
,
*
args
):
self
.
assertRaises
(
StorageTransactionError
,
callable
,
*
args
)
def
verifyWrongTrans
(
self
,
callable
,
*
args
):
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
assertRaises
(
StorageTransactionError
,
callable
,
*
args
)
def
checkAbortVersionNotCommitting
(
self
):
self
.
verifyNotCommitting
(
self
.
_storage
.
abortVersion
,
VERSION
,
self
.
_transaction
)
def
checkAbortVersionWrongTrans
(
self
):
self
.
verifyWrongTrans
(
self
.
_storage
.
abortVersion
,
VERSION
,
Transaction
())
def
checkCommitVersionNotCommitting
(
self
):
self
.
verifyNotCommitting
(
self
.
_storage
.
commitVersion
,
VERSION
,
""
,
self
.
_transaction
)
def
checkCommitVersionWrongTrans
(
self
):
self
.
verifyWrongTrans
(
self
.
_storage
.
commitVersion
,
VERSION
,
""
,
Transaction
())
def
checkStoreNotCommitting
(
self
):
self
.
verifyNotCommitting
(
self
.
_storage
.
store
,
OID
,
SERIALNO
,
""
,
""
,
self
.
_transaction
)
def
checkStoreWrongTrans
(
self
):
self
.
verifyWrongTrans
(
self
.
_storage
.
store
,
OID
,
SERIALNO
,
""
,
""
,
Transaction
())
## def checkNewOidNotCommitting(self):
## self.verifyNotCommitting(self._storage.new_oid)
## def checkNewOidWrongTrans(self):
## self.verifyWrongTrans(self._storage.new_oid)
def
checkAbortNotCommitting
(
self
):
self
.
_storage
.
tpc_abort
(
Transaction
())
def
checkAbortWrongTrans
(
self
):
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
_storage
.
tpc_abort
(
Transaction
())
def
checkFinishNotCommitting
(
self
):
self
.
_storage
.
tpc_finish
(
Transaction
())
def
checkFinishWrongTrans
(
self
):
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
Transaction
())
def
checkBeginCommitting
(
self
):
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
# XXX how to check undo?
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