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
f4587a70
Commit
f4587a70
authored
Feb 04, 2005
by
Dmitry Vasiliev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for fsdump()
parent
40a7a145
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
11 deletions
+87
-11
src/ZODB/FileStorage/fsdump.py
src/ZODB/FileStorage/fsdump.py
+9
-11
src/ZODB/tests/test_fsdump.py
src/ZODB/tests/test_fsdump.py
+78
-0
No files found.
src/ZODB/FileStorage/fsdump.py
View file @
f4587a70
...
...
@@ -25,12 +25,13 @@ def fsdump(path, file=None, with_offset=1):
for
i
,
trans
in
enumerate
(
iter
):
if
with_offset
:
print
>>
file
,
"Trans #%05d tid=%016x time=%s offset=%d"
%
\
(
i
,
u64
(
trans
.
tid
),
str
(
TimeStamp
(
trans
.
tid
)
),
trans
.
_pos
)
(
i
,
u64
(
trans
.
tid
),
TimeStamp
(
trans
.
tid
),
trans
.
_pos
)
else
:
print
>>
file
,
"Trans #%05d tid=%016x time=%s"
%
\
(
i
,
u64
(
trans
.
tid
),
str
(
TimeStamp
(
trans
.
tid
)))
print
>>
file
,
"
\
t
status=%s user=%s description=%s"
%
\
(
`trans.status`
,
trans
.
user
,
trans
.
description
)
(
i
,
u64
(
trans
.
tid
),
TimeStamp
(
trans
.
tid
))
print
>>
file
,
" status=%r user=%r description=%r"
%
\
(
trans
.
status
,
trans
.
user
,
trans
.
description
)
for
j
,
rec
in
enumerate
(
trans
):
if
rec
.
data
is
None
:
fullclass
=
"undo or abort of object creation"
...
...
@@ -39,24 +40,21 @@ def fsdump(path, file=None, with_offset=1):
modname
,
classname
=
get_pickle_metadata
(
rec
.
data
)
size
=
" size=%d"
%
len
(
rec
.
data
)
fullclass
=
"%s.%s"
%
(
modname
,
classname
)
# FIXME: Is this used?
# special case for testing purposes
if
fullclass
==
"ZODB.tests.MinPO.MinPO"
:
obj
=
zodb_unpickle
(
rec
.
data
)
fullclass
=
"%s %s"
%
(
fullclass
,
obj
.
value
)
if
rec
.
version
:
version
=
" version=%
s
"
%
rec
.
version
version
=
" version=%
r
"
%
rec
.
version
else
:
version
=
""
if
rec
.
data_txn
:
# XXX It would be nice to print the transaction number
# (i) but it would be too expensive to keep track of.
bp
=
" bp=%016x"
%
u64
(
rec
.
data_txn
)
else
:
bp
=
""
print
>>
file
,
" data #%05d oid=%016x%s%s class=%s%s"
%
\
(
j
,
u64
(
rec
.
oid
),
version
,
size
,
fullclass
,
bp
)
print
>>
file
iter
.
close
()
def
fmt
(
p64
):
...
...
src/ZODB/tests/test_fsdump.py
0 → 100644
View file @
f4587a70
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
r"""
fsdump test
===========
Let's get a temp file path to work with first.
>>> import tempfile
>>> path = tempfile.mktemp('.fs', 'Data')
>>> print 'path:', path #doctest: +ELLIPSIS
path: ...Data...fs
More imports.
>>> import ZODB
>>> from ZODB.FileStorage import FileStorage
>>> import transaction as txn
>>> from BTrees.OOBTree import OOBTree
>>> from ZODB.FileStorage.fsdump import fsdump # we're testing this
Create an empty FileStorage.
>>> st = FileStorage(path)
For empty DB fsdump() output definitely empty:
>>> fsdump(path)
Create a root object and try again:
>>> db = ZODB.DB(st) # yes, that creates a root object!
>>> fsdump(path) #doctest: +ELLIPSIS
Trans #00000 tid=... time=... offset=52
status=' ' user='' description='initial database creation'
data #00000 oid=0000000000000000 size=66 class=persistent.mapping.PersistentMapping
Now we see first transaction with root object.
Let's add a BTree:
>>> root = db.open().root()
>>> root['tree'] = OOBTree()
>>> txn.get().note('added an OOBTree')
>>> txn.get().commit()
>>> fsdump(path) #doctest: +ELLIPSIS
Trans #00000 tid=... time=... offset=52
status=' ' user='' description='initial database creation'
data #00000 oid=0000000000000000 size=66 class=persistent.mapping.PersistentMapping
Trans #00001 tid=... time=... offset=207
status=' ' user='' description='added an OOBTree'
data #00000 oid=0000000000000000 size=114 class=persistent.mapping.PersistentMapping
data #00001 oid=0000000000000001 size=30 class=BTrees._OOBTree.OOBTree
Now we see two transactions and two changed objects.
Clean up.
>>> st.close()
>>> st.cleanup() # remove .fs, .index, etc
"""
from
zope.testing
import
doctest
def
test_suite
():
return
doctest
.
DocTestSuite
()
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