[Zope-Checkins] CVS: ZODB3/ZODB/tests - testFileStorage.py:1.19.28.3

Jeremy Hylton jeremy@zope.com
Fri, 15 Nov 2002 11:45:35 -0500


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv30527

Modified Files:
      Tag: ZODB3-restore-debug-branch
	testFileStorage.py 
Log Message:
Improve checkRecoverUndoInVersion().

After verifying that new transactions work after the copy, make a new
copy and verify that all the new transactions get copied correctly.


=== ZODB3/ZODB/tests/testFileStorage.py 1.19.28.2 => 1.19.28.3 ===
--- ZODB3/ZODB/tests/testFileStorage.py:1.19.28.2	Fri Nov 15 10:57:34 2002
+++ ZODB3/ZODB/tests/testFileStorage.py	Fri Nov 15 11:45:35 2002
@@ -119,13 +119,9 @@
         revid = self._dostore(oid, data=21, version="one")
         revid = self._dostore(oid, revid=revid, data=23, version='one')
         revid = self._dostore(oid, revid=revid, data=34, version='one')
-        # Now abort the version and the creation
-        t = Transaction()
-        self._storage.tpc_begin(t)
-        oids = self._storage.abortVersion('one', t)
-        self._storage.tpc_vote(t)
-        self._storage.tpc_finish(t)
+        oids = self._abortVersion("one")
         self.assertEqual(oids, [oid])
+        print self._dump(self._storage.__name__)
         self._dst.copyTransactionsFrom(self._storage)
         self.compare(self._storage, self._dst)
         # Also make sure the the last transaction has a data record
@@ -155,7 +151,12 @@
         # now copy the records to a new storage
         self._dst.copyTransactionsFrom(self._storage)
         self.compare(self._storage, self._dst)
-        
+
+        # The last two transactions were applied directly rather than
+        # copied.  So we can't use compare() to verify that they new
+        # transactions are applied correctly.  (The new transactions
+        # will have different timestamps for each storage.)
+
         self._abortVersion(version)
         self.assert_(self._storage.versionEmpty(version))
         self._undo(self._storage.undoInfo()[0]['id'], oid)
@@ -183,7 +184,15 @@
 
         # swap them back
         self._storage = tmp
+
+        # Now remove _dst and copy all the transactions a second time.
+        # This time we will be able to confirm via compare().
+        self._dst.close()
+        StorageTestBase.removefs("Dest.fs")
+        self._dst = ZODB.FileStorage.FileStorage('Dest.fs')
+        self._dst.copyTransactionsFrom(self._storage)
         self.compare(self._storage, self._dst)
+        
 
 def test_suite():
     suite = unittest.makeSuite(FileStorageTests, 'check')