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
db98563c
Commit
db98563c
authored
May 21, 2015
by
Adam Groszer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added test to check tryToResolveConflict log output
parent
bdc633a8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
src/ZODB/tests/testconflictresolution.py
src/ZODB/tests/testconflictresolution.py
+69
-0
No files found.
src/ZODB/tests/testconflictresolution.py
View file @
db98563c
...
@@ -292,6 +292,75 @@ And load the pickle:
...
@@ -292,6 +292,75 @@ And load the pickle:
>>> db2.close()
>>> db2.close()
"""
"""
def
show_tryToResolveConflict_log_output
():
"""
Verify output generated by tryToResolveConflict in the logs
>>> db = ZODB.DB('t.fs') # FileStorage!
>>> storage = db.storage
>>> conn = db.open()
>>> conn.root.x = ResolveableWhenStateDoesNotChange()
>>> conn.root.x.v = 1
>>> transaction.commit()
>>> serial1 = conn.root.x._p_serial
>>> conn.root.x.v = 2
>>> transaction.commit()
>>> serial2 = conn.root.x._p_serial
>>> oid = conn.root.x._p_oid
Install a log handler to be able to show log entries
>>> import logging
>>> from zope.testing.loggingsupport import InstalledHandler
>>> handler = InstalledHandler('ZODB.ConflictResolution',
... level=logging.DEBUG)
We conflict if both the committed and new are different than the original:
>>> p = storage.tryToResolveConflict(
... oid, serial2, serial1, storage.loadSerial(oid, serial2))
... # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ConflictError: database conflict error (oid 0x01, ...
If content doesn't support conflict resolution:
>>> conn.root.y = Unresolvable()
>>> conn.root.y.v = 1
>>> transaction.commit()
>>> oid = conn.root.y._p_oid
>>> serial = conn.root.y._p_serial
>>> p = storage.tryToResolveConflict(
... oid, serial, serial, storage.loadSerial(oid, serial))
... # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ConflictError: database conflict error (oid 0x02, ...
Let's see what went into the log:
>>> len(handler.records)
2
>>> import six
>>> msg = handler.records[0]
>>> six.print_(msg.name, msg.levelname, msg.getMessage())
ZODB.ConflictResolution ERROR Unexpected error
>>> msg = handler.records[1]
>>> six.print_(msg.name, msg.levelname, msg.getMessage())
ZODB.ConflictResolution DEBUG Conflict resolution failed with ConflictError: database conflict error
Cleanup:
>>> handler.uninstall()
>>> db.close()
"""
def
test_suite
():
def
test_suite
():
return
unittest
.
TestSuite
([
return
unittest
.
TestSuite
([
manuel
.
testing
.
TestSuite
(
manuel
.
testing
.
TestSuite
(
...
...
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