[Zodb-checkins] SVN: ZODB/trunk/ Extended output of fstail and provided a simple test. Fixes bug #158992.

Christian Theune ct at gocept.com
Sat Nov 10 11:06:07 EST 2007


Log message for revision 81719:
  Extended output of fstail and provided a simple test. Fixes bug #158992.
  

Changed:
  U   ZODB/trunk/NEWS.txt
  U   ZODB/trunk/src/ZODB/scripts/fstail.py
  A   ZODB/trunk/src/ZODB/scripts/fstail.txt
  U   ZODB/trunk/src/ZODB/scripts/tests.py

-=-
Modified: ZODB/trunk/NEWS.txt
===================================================================
--- ZODB/trunk/NEWS.txt	2007-11-10 16:06:02 UTC (rev 81718)
+++ ZODB/trunk/NEWS.txt	2007-11-10 16:06:06 UTC (rev 81719)
@@ -21,6 +21,9 @@
 - (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
 ---
 

Modified: ZODB/trunk/src/ZODB/scripts/fstail.py
===================================================================
--- ZODB/trunk/src/ZODB/scripts/fstail.py	2007-11-10 16:06:02 UTC (rev 81718)
+++ ZODB/trunk/src/ZODB/scripts/fstail.py	2007-11-10 16:06:06 UTC (rev 81719)
@@ -33,8 +33,8 @@
         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

Added: ZODB/trunk/src/ZODB/scripts/fstail.txt
===================================================================
--- ZODB/trunk/src/ZODB/scripts/fstail.txt	                        (rev 0)
+++ ZODB/trunk/src/ZODB/scripts/fstail.txt	2007-11-10 16:06:06 UTC (rev 81719)
@@ -0,0 +1,40 @@
+====================
+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')


Property changes on: ZODB/trunk/src/ZODB/scripts/fstail.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: ZODB/trunk/src/ZODB/scripts/tests.py
===================================================================
--- ZODB/trunk/src/ZODB/scripts/tests.py	2007-11-10 16:06:02 UTC (rev 81718)
+++ ZODB/trunk/src/ZODB/scripts/tests.py	2007-11-10 16:06:06 UTC (rev 81719)
@@ -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),
         ))
-



More information about the Zodb-checkins mailing list