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
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
Nicolas Wavrant
ZODB
Commits
667a49f8
Commit
667a49f8
authored
Jun 13, 2003
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
An obsolete version of this file got added from the 3.1 branch. Bringing
it up to date.
parent
f19e1783
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
8 deletions
+31
-8
src/ZEO/tests/InvalidationTests.py
src/ZEO/tests/InvalidationTests.py
+31
-8
No files found.
src/ZEO/tests/InvalidationTests.py
View file @
667a49f8
...
...
@@ -27,8 +27,27 @@ from ZODB.POSException \
import
ReadConflictError
,
ConflictError
,
VersionLockError
import
zLOG
# The tests here let several threads have a go at one or more database
# instances simultaneously. Each thread appends a disjoint (from the
# other threads) sequence of increasing integers to an OOBTree, one at
# at time (per thread). This provokes lots of conflicts, and BTrees
# work hard at conflict resolution too. An OOBTree is used because
# that flavor has the smallest maximum bucket size, and so splits buckets
# more often than other BTree flavors.
#
# When these tests were first written, they provoked an amazing number
# of obscure timing-related bugs in cache consistency logic, revealed
# by failure of the BTree to pass internal consistency checks at the end,
# and/or by failure of the BTree to contain all the keys the threads
# thought they added (i.e., the keys for which get_transaction().commit()
# did not raise any exception).
class
StressThread
(
TestThread
):
# Append integers startnum, startnum + step, startnum + 2*step, ...
# to 'tree' until Event stop is set. If sleep is given, sleep
# that long after each append. At the end, instance var .added_keys
# is a list of the ints the thread believes it added successfully.
def
__init__
(
self
,
testcase
,
db
,
stop
,
threadnum
,
startnum
,
step
=
2
,
sleep
=
None
):
TestThread
.
__init__
(
self
,
testcase
)
...
...
@@ -154,10 +173,10 @@ class VersionStressThread(TestThread):
class
InvalidationTests
(
CommonSetupTearDown
):
level
=
2
DELAY
=
15
DELAY
=
15
# number of seconds the main thread lets the workers run
def
_check_tree
(
self
,
cn
,
tree
):
# Make sure the BTree is sane and that all the updates persisted
# Make sure the BTree is sane and that all the updates persisted
.
retries
=
3
while
retries
:
retries
-=
1
...
...
@@ -177,11 +196,15 @@ class InvalidationTests(CommonSetupTearDown):
def
_check_threads
(
self
,
tree
,
*
threads
):
# Make sure the thread's view of the world is consistent with
# the actual database state.
all_keys
=
[]
for
t
in
threads
:
# If the test didn't add any keys, it didn't do what we expected.
self
.
assert_
(
t
.
added_keys
)
for
key
in
t
.
added_keys
:
self
.
assert_
(
tree
.
has_key
(
key
),
key
)
all_keys
.
extend
(
t
.
added_keys
)
all_keys
.
sort
()
self
.
assertEqual
(
all_keys
,
list
(
tree
.
keys
()))
def
go
(
self
,
stop
,
*
threads
):
# Run the threads
...
...
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