Commit 904a3839 authored by Christian Theune's avatar Christian Theune

Extended output of fstail and provided a simple test. Fixes bug #158992.

parent 1ae0ba36
......@@ -21,6 +21,9 @@ General
- (unreleased, after 3.9.0a1) ZODB installation now requires
setuptools.
- (unreleased, after 3.9.0a1) Added `offset` information to output of `fstail`
script. Added test harness for this script.
ZEO
---
......
......@@ -33,8 +33,8 @@ def main(path, ntxn):
th.read_meta()
print "%s: hash=%s" % (th.get_timestamp(),
binascii.hexlify(hash))
print ("user=%r description=%r length=%d"
% (th.user, th.descr, th.length))
print ("user=%r description=%r length=%d offset=%d"
% (th.user, th.descr, th.length, th.get_data_offset()))
print
th = th.prev_txn()
i -= 1
......
====================
The `fstail` utility
====================
The `fstail` utility shows information for a FileStorage about the last `n`
transactions:
We have to prepare a FileStorage first:
>>> from ZODB.FileStorage import FileStorage
>>> from ZODB.DB import DB
>>> import transaction
>>> from tempfile import mktemp
>>> storagefile = mktemp()
>>> base_storage = FileStorage(storagefile)
>>> database = DB(base_storage)
>>> connection1 = database.open()
>>> root = connection1.root()
>>> root['foo'] = 1
>>> transaction.commit()
Now lets have a look at the last transactions of this FileStorage:
>>> from ZODB.scripts.fstail import main
>>> main(storagefile, 5)
2007-11-10 15:18:48.543001: hash=b16422d09fabdb45d4e4325e4b42d7d6f021d3c3
user='' description='' length=138 offset=191
<BLANKLINE>
2007-11-10 15:18:48.543001: hash=b16422d09fabdb45d4e4325e4b42d7d6f021d3c3
user='' description='initial database creation' length=156 offset=52
<BLANKLINE>
Now clean up the storage again:
>>> import os
>>> base_storage.close()
>>> os.unlink(storagefile)
>>> os.unlink(storagefile+'.index')
>>> os.unlink(storagefile+'.lock')
>>> os.unlink(storagefile+'.tmp')
......@@ -11,15 +11,21 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""XXX short summary goes here.
"""Test harness for scripts.
$Id$
"""
import unittest
from zope.testing import doctest
import re
from zope.testing import doctest, renormalizing
checker = renormalizing.RENormalizing([
(re.compile('[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+'),
'2007-11-10 15:18:48.543001'),
(re.compile('hash=[0-9a-f]{40}'),
'hash=b16422d09fabdb45d4e4325e4b42d7d6f021d3c3')])
def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('referrers.txt'),
doctest.DocFileSuite('referrers.txt', 'fstail.txt', checker=checker),
))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment