Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
6e1165a5
Commit
6e1165a5
authored
Sep 09, 2010
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a test bug that caused checkCurrentSerialInTransaction to be
tested incorrectly for ZEO.
parent
db1134a5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
15 deletions
+45
-15
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+24
-0
src/ZODB/tests/BasicStorage.py
src/ZODB/tests/BasicStorage.py
+21
-15
No files found.
src/ZEO/tests/testZEO.py
View file @
6e1165a5
...
@@ -249,6 +249,30 @@ class GenericTests(
...
@@ -249,6 +249,30 @@ class GenericTests(
key
=
'%s:%s'
%
(
self
.
_storage
.
_storage
,
self
.
_storage
.
_server_addr
)
key
=
'%s:%s'
%
(
self
.
_storage
.
_storage
,
self
.
_storage
.
_server_addr
)
self
.
assertEqual
(
self
.
_storage
.
sortKey
(),
key
)
self
.
assertEqual
(
self
.
_storage
.
sortKey
(),
key
)
def
_do_store_in_separate_thread
(
self
,
oid
,
revid
):
def
do_store
():
store
=
ZEO
.
ClientStorage
.
ClientStorage
(
self
.
_storage
.
_addr
)
try
:
t
=
transaction
.
get
()
store
.
tpc_begin
(
t
)
store
.
store
(
oid
,
revid
,
'x'
,
''
,
t
)
store
.
tpc_vote
(
t
)
store
.
tpc_finish
(
t
)
except
Exception
,
v
:
import
traceback
print
'E'
*
70
print
v
traceback
.
print_exception
(
*
sys
.
exc_info
())
finally
:
store
.
close
()
thread
=
threading
.
Thread
(
name
=
'T2'
,
target
=
do_store
)
thread
.
setDaemon
(
True
)
thread
.
start
()
thread
.
join
(.
2
)
return
thread
class
FullGenericTests
(
class
FullGenericTests
(
GenericTests
,
GenericTests
,
Cache
.
TransUndoStorageWithCache
,
Cache
.
TransUndoStorageWithCache
,
...
...
src/ZODB/tests/BasicStorage.py
View file @
6e1165a5
...
@@ -24,6 +24,8 @@ from ZODB.tests.MinPO import MinPO
...
@@ -24,6 +24,8 @@ from ZODB.tests.MinPO import MinPO
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
,
zodb_pickle
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
,
zodb_pickle
from
ZODB.tests.StorageTestBase
import
handle_serials
from
ZODB.tests.StorageTestBase
import
handle_serials
import
threading
import
time
import
transaction
import
transaction
import
zope.interface
import
zope.interface
import
zope.interface.verify
import
zope.interface.verify
...
@@ -200,12 +202,21 @@ class BasicStorage:
...
@@ -200,12 +202,21 @@ class BasicStorage:
self
.
_storage
.
tpc_finish
(
t
)
self
.
_storage
.
tpc_finish
(
t
)
t
.
commit
()
t
.
commit
()
def
_do_store_in_separate_thread
(
self
,
oid
,
revid
):
# We'll run the competing trans in a separate thread:
thread
=
threading
.
Thread
(
name
=
'T2'
,
target
=
self
.
_dostore
,
args
=
(
oid
,),
kwargs
=
dict
(
revid
=
revid
))
thread
.
setDaemon
(
True
)
thread
.
start
()
thread
.
join
(.
2
)
return
thread
def
check_checkCurrentSerialInTransaction
(
self
):
def
check_checkCurrentSerialInTransaction
(
self
):
oid
=
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf0
'
oid
=
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf0
'
tid
=
self
.
_dostore
(
oid
)
tid
=
self
.
_dostore
(
oid
)
tid2
=
self
.
_dostore
(
oid
,
revid
=
tid
)
tid2
=
self
.
_dostore
(
oid
,
revid
=
tid
)
#----------------------------------------------------------------------
# stale read
# stale read
transaction
.
begin
()
transaction
.
begin
()
t
=
transaction
.
get
()
t
=
transaction
.
get
()
...
@@ -219,11 +230,12 @@ class BasicStorage:
...
@@ -219,11 +230,12 @@ class BasicStorage:
self
.
assert_
(
v
.
oid
)
==
oid
self
.
assert_
(
v
.
oid
)
==
oid
self
.
assert_
(
v
.
serials
==
(
tid2
,
tid
))
self
.
assert_
(
v
.
serials
==
(
tid2
,
tid
))
else
:
else
:
self
.
assert_
(
False
,
"No conflict error"
)
if
0
:
self
.
assert_
(
False
,
"No conflict error"
)
self
.
_storage
.
tpc_abort
(
t
)
self
.
_storage
.
tpc_abort
(
t
)
#----------------------------------------------------------------------
# non-stale read, no stress. :)
# non-stale read, no stress. :)
transaction
.
begin
()
transaction
.
begin
()
t
=
transaction
.
get
()
t
=
transaction
.
get
()
...
@@ -234,8 +246,9 @@ class BasicStorage:
...
@@ -234,8 +246,9 @@ class BasicStorage:
self
.
_storage
.
tpc_vote
(
t
)
self
.
_storage
.
tpc_vote
(
t
)
self
.
_storage
.
tpc_finish
(
t
)
self
.
_storage
.
tpc_finish
(
t
)
#----------------------------------------------------------------------
# non-stale read, competition after vote. The competing
# non-stale read, competition after vote. The competing
# transaction m
o
st produce a tid > this transaction's tid
# transaction m
u
st produce a tid > this transaction's tid
transaction
.
begin
()
transaction
.
begin
()
t
=
transaction
.
get
()
t
=
transaction
.
get
()
self
.
_storage
.
tpc_begin
(
t
)
self
.
_storage
.
tpc_begin
(
t
)
...
@@ -245,17 +258,14 @@ class BasicStorage:
...
@@ -245,17 +258,14 @@ class BasicStorage:
self
.
_storage
.
tpc_vote
(
t
)
self
.
_storage
.
tpc_vote
(
t
)
# We'll run the competing trans in a separate thread:
# We'll run the competing trans in a separate thread:
import
threading
,
time
thread
=
self
.
_do_store_in_separate_thread
(
oid
,
tid2
)
thread
=
threading
.
Thread
(
name
=
'T1'
,
target
=
self
.
_dostore
,
args
=
(
oid
,),
kwargs
=
dict
(
revid
=
tid2
))
thread
.
start
()
time
.
sleep
(.
1
)
self
.
_storage
.
tpc_finish
(
t
)
self
.
_storage
.
tpc_finish
(
t
)
thread
.
join
()
thread
.
join
(
1
)
tid3
=
self
.
_storage
.
load
(
oid
)[
1
]
tid3
=
self
.
_storage
.
load
(
oid
)[
1
]
self
.
assert_
(
tid3
>
self
.
_storage
.
load
(
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf3
'
)[
1
])
self
.
assert_
(
tid3
>
self
.
_storage
.
load
(
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf3
'
)[
1
])
#----------------------------------------------------------------------
# non-stale competing trans after checkCurrentSerialInTransaction
# non-stale competing trans after checkCurrentSerialInTransaction
transaction
.
begin
()
transaction
.
begin
()
t
=
transaction
.
get
()
t
=
transaction
.
get
()
...
@@ -264,11 +274,7 @@ class BasicStorage:
...
@@ -264,11 +274,7 @@ class BasicStorage:
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
,
'x'
,
''
,
t
)
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
,
'x'
,
''
,
t
)
self
.
_storage
.
checkCurrentSerialInTransaction
(
oid
,
tid3
,
t
)
self
.
_storage
.
checkCurrentSerialInTransaction
(
oid
,
tid3
,
t
)
# We'll run the competing trans in a separate thread:
thread
=
self
.
_do_store_in_separate_thread
(
oid
,
tid3
)
thread
=
threading
.
Thread
(
name
=
'T2'
,
target
=
self
.
_dostore
,
args
=
(
oid
,),
kwargs
=
dict
(
revid
=
tid3
))
thread
.
start
()
time
.
sleep
(.
1
)
# There are 2 possibilities:
# There are 2 possibilities:
# 1. The store happens before this transaction completes,
# 1. The store happens before this transaction completes,
...
@@ -277,7 +283,7 @@ class BasicStorage:
...
@@ -277,7 +283,7 @@ class BasicStorage:
# tid of the object is greater than this transaction's tid.
# tid of the object is greater than this transaction's tid.
try
:
try
:
self
.
_storage
.
tpc_vote
(
t
)
self
.
_storage
.
tpc_vote
(
t
)
except
ReadConflictError
:
except
POSException
.
ReadConflictError
:
thread
.
join
()
# OK :)
thread
.
join
()
# OK :)
else
:
else
:
self
.
_storage
.
tpc_finish
(
t
)
self
.
_storage
.
tpc_finish
(
t
)
...
...
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