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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
d4749251
Commit
d4749251
authored
Nov 05, 2002
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkPackUnlinkFromRoot(): Add another test that might illustrate some
interesting root reachability properties.
parent
9e8c76de
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
6 deletions
+57
-6
src/ZODB/tests/PackableStorage.py
src/ZODB/tests/PackableStorage.py
+57
-6
No files found.
src/ZODB/tests/PackableStorage.py
View file @
d4749251
...
@@ -13,6 +13,8 @@ except ImportError:
...
@@ -13,6 +13,8 @@ except ImportError:
from
StringIO
import
StringIO
from
StringIO
import
StringIO
import
time
import
time
from
ZODB
import
DB
from
Persistence
import
Persistent
from
ZODB.referencesf
import
referencesf
from
ZODB.referencesf
import
referencesf
...
@@ -42,6 +44,9 @@ class Object:
...
@@ -42,6 +44,9 @@ class Object:
return
self
.
_oid
return
self
.
_oid
class
C
(
Persistent
):
pass
# Here's where all the magic occurs. Sadly, the pickle module is a bit
# Here's where all the magic occurs. Sadly, the pickle module is a bit
# underdocumented, but here's what happens: by setting the persistent_id
# underdocumented, but here's what happens: by setting the persistent_id
# attribute to getpersid() on the pickler, that function gets called for every
# attribute to getpersid() on the pickler, that function gets called for every
...
@@ -159,8 +164,10 @@ class PackableStorage(PackableStorageBase):
...
@@ -159,8 +164,10 @@ class PackableStorage(PackableStorageBase):
eq
(
pobj
.
value
,
3
)
eq
(
pobj
.
value
,
3
)
# Now pack all transactions; need to sleep a second to make
# Now pack all transactions; need to sleep a second to make
# sure that the pack time is greater than the last commit time.
# sure that the pack time is greater than the last commit time.
time
.
sleep
(
1
)
now
=
packtime
=
time
.
time
()
self
.
_storage
.
pack
(
time
.
time
(),
referencesf
)
while
packtime
<=
now
:
packtime
=
time
.
time
()
self
.
_storage
.
pack
(
packtime
,
referencesf
)
# All revisions of the object should be gone, since there is no
# All revisions of the object should be gone, since there is no
# reference from the root object to this object.
# reference from the root object to this object.
raises
(
KeyError
,
self
.
_storage
.
loadSerial
,
oid
,
revid1
)
raises
(
KeyError
,
self
.
_storage
.
loadSerial
,
oid
,
revid1
)
...
@@ -210,8 +217,10 @@ class PackableStorage(PackableStorageBase):
...
@@ -210,8 +217,10 @@ class PackableStorage(PackableStorageBase):
eq
(
pobj
.
value
,
3
)
eq
(
pobj
.
value
,
3
)
# Now pack just revisions 1 and 2. The object's current revision
# Now pack just revisions 1 and 2. The object's current revision
# should stay alive because it's pointed to by the root.
# should stay alive because it's pointed to by the root.
time
.
sleep
(
1
)
now
=
packtime
=
time
.
time
()
self
.
_storage
.
pack
(
time
.
time
(),
referencesf
)
while
packtime
<=
now
:
packtime
=
time
.
time
()
self
.
_storage
.
pack
(
packtime
,
referencesf
)
# Make sure the revisions are gone, but that object zero and revision
# Make sure the revisions are gone, but that object zero and revision
# 3 are still there and correct
# 3 are still there and correct
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
...
@@ -287,8 +296,10 @@ class PackableStorage(PackableStorageBase):
...
@@ -287,8 +296,10 @@ class PackableStorage(PackableStorageBase):
# Now pack just revisions 1 and 2 of object1. Object1's current
# Now pack just revisions 1 and 2 of object1. Object1's current
# revision should stay alive because it's pointed to by the root, as
# revision should stay alive because it's pointed to by the root, as
# should Object2's current revision.
# should Object2's current revision.
time
.
sleep
(
1
)
now
=
packtime
=
time
.
time
()
self
.
_storage
.
pack
(
time
.
time
(),
referencesf
)
while
packtime
<=
now
:
packtime
=
time
.
time
()
self
.
_storage
.
pack
(
packtime
,
referencesf
)
# Make sure the revisions are gone, but that object zero, object2, and
# Make sure the revisions are gone, but that object zero, object2, and
# revision 3 of object1 are still there and correct.
# revision 3 of object1 are still there and correct.
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
...
@@ -312,3 +323,43 @@ class PackableStorage(PackableStorageBase):
...
@@ -312,3 +323,43 @@ class PackableStorage(PackableStorageBase):
pobj
=
pickle
.
loads
(
data
)
pobj
=
pickle
.
loads
(
data
)
eq
(
pobj
.
getoid
(),
oid2
)
eq
(
pobj
.
getoid
(),
oid2
)
eq
(
pobj
.
value
,
11
)
eq
(
pobj
.
value
,
11
)
def
checkPackUnlinkedFromRoot
(
self
):
eq
=
self
.
assertEqual
db
=
DB
(
self
.
_storage
)
conn
=
db
.
open
()
root
=
conn
.
root
()
txn
=
get_transaction
()
txn
.
note
(
'root'
)
txn
.
commit
()
now
=
packtime
=
time
.
time
()
while
packtime
<=
now
:
packtime
=
time
.
time
()
obj
=
C
()
obj
.
value
=
7
root
[
'obj'
]
=
obj
txn
=
get_transaction
()
txn
.
note
(
'root -> o1'
)
txn
.
commit
()
del
root
[
'obj'
]
txn
=
get_transaction
()
txn
.
note
(
'root -x-> o1'
)
txn
.
commit
()
self
.
_storage
.
pack
(
packtime
,
referencesf
)
log
=
self
.
_storage
.
undoLog
()
tid
=
log
[
0
][
'id'
]
db
.
undo
(
tid
)
txn
=
get_transaction
()
txn
.
note
(
'undo root -x-> o1'
)
txn
.
commit
()
conn
.
sync
()
eq
(
root
[
'obj'
].
value
,
7
)
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