Commit b810da3c authored by Jeremy Hylton's avatar Jeremy Hylton

Fix use of RecordIterator() in fsrecover and add trivial test case.

parent 58488067
...@@ -24,7 +24,7 @@ of critical data were lost. ...@@ -24,7 +24,7 @@ of critical data were lost.
Options: Options:
-f -f
Force output to putput file even if it exists Force output to output file even if it exists
-v level -v level
...@@ -50,8 +50,8 @@ Options: ...@@ -50,8 +50,8 @@ Options:
option is used, then t should be 0. option is used, then t should be 0.
Important note: The ZODB package must be imporable. You may need Important note: The ZODB package must be imporatble. You may need
to adjust the Python path accordingly. to adjust PYTHONPATH accordingly.
""" """
...@@ -139,13 +139,8 @@ def read_transaction_header(file, pos, file_size): ...@@ -139,13 +139,8 @@ def read_transaction_header(file, pos, file_size):
except: e={} except: e={}
else: e={} else: e={}
result=RecordIterator( result = RecordIterator(tid, status, user, description, e, pos, tend,
tid, status, user, description, e, file, tpos)
pos, (tend, file, seek, read,
tpos,
)
)
pos=tend pos=tend
# Read the (intentionally redundant) transaction length # Read the (intentionally redundant) transaction length
......
...@@ -16,8 +16,11 @@ from __future__ import nested_scopes ...@@ -16,8 +16,11 @@ from __future__ import nested_scopes
import ZODB.FileStorage import ZODB.FileStorage
import sys, os, unittest import sys, os, unittest
import errno import errno
import filecmp
import StringIO
from ZODB.Transaction import Transaction from ZODB.Transaction import Transaction
from ZODB import POSException from ZODB import POSException
from ZODB.fsrecover import recover
from ZODB.tests import StorageTestBase, BasicStorage, \ from ZODB.tests import StorageTestBase, BasicStorage, \
TransactionalUndoStorage, VersionStorage, \ TransactionalUndoStorage, VersionStorage, \
...@@ -167,6 +170,25 @@ class FileStorageTests( ...@@ -167,6 +170,25 @@ class FileStorageTests(
self.failUnless(self._storage._records_before_save > 20) self.failUnless(self._storage._records_before_save > 20)
def checkfsrecover(self):
# an absolutely minimal test of fsrecover
# Verify that calling recover on a small, correct storage
# produces a duplicate of the original.
for i in range(5):
oid = self._storage.new_oid()
revid = None
for j in range(5):
revid = self._dostore(oid, revid=revid)
temp = sys.stdout
sys.stdout = StringIO.StringIO()
try:
recover(["", "FileStorageTests.fs", "fsrecover.fs"])
finally:
sys.stdout = temp
self.assert_(filecmp.cmp("FileStorageTests.fs", "fsrecover.fs"))
StorageTestBase.removefs("fsrecover.fs")
def checkPackVersionsInPast(self): def checkPackVersionsInPast(self):
# FileStorage can't cope with backpointers to objects # FileStorage can't cope with backpointers to objects
# created in versions. Must fix. # created in versions. Must fix.
......
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