[Zope-Checkins] CVS: ZODB3/ZODB/tests - testFileStorage.py:1.19.8.3
Jeremy Hylton
jeremy@zope.com
Wed, 18 Dec 2002 16:20:28 -0500
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv7847/ZODB/tests
Modified Files:
Tag: ZODB3-3_1-branch
testFileStorage.py
Log Message:
Merge improvement from ZODB3-fast-restart-branch
Partial merge of "Several startup performance improvements" checkin.
Exclude changes that enable fsBTree-based index.
=== ZODB3/ZODB/tests/testFileStorage.py 1.19.8.2 => 1.19.8.3 ===
--- ZODB3/ZODB/tests/testFileStorage.py:1.19.8.2 Fri Dec 6 17:59:30 2002
+++ ZODB3/ZODB/tests/testFileStorage.py Wed Dec 18 16:20:27 2002
@@ -67,6 +67,37 @@
else:
self.fail("expect long user field to raise error")
+ # XXX We could really use some tests for sanity checking
+ def check_save_after_load_with_no_index(self):
+ for i in range(10):
+ self._dostore()
+ self._storage.close()
+ os.remove('FileStorageTests.fs.index')
+ self.open()
+ self.assertEqual(self._storage._saved, 1)
+
+
+ # This would make the unit tests too slow
+ # check_save_after_load_that_worked_hard(self)
+
+ def check_periodic_save_index(self):
+
+ # Check the basic algorithm
+ oldsaved = self._storage._saved
+ self._storage._records_before_save = 10
+ for i in range(4):
+ self._dostore()
+ self.assertEqual(self._storage._saved, oldsaved)
+ self._dostore()
+ self.assertEqual(self._storage._saved, oldsaved+1)
+
+ # Now make sure the parameter changes as we get bigger
+ for i in range(20):
+ self._dostore()
+
+ self.failUnless(self._storage._records_before_save > 20)
+
+
class FileStorageRecoveryTest(
StorageTestBase.StorageTestBase,
IteratorStorage.IteratorDeepCompare,
@@ -120,6 +151,7 @@
pass # iterate until we get the last one
data = trans[0]
self.assertRaises(IndexError, lambda i:trans[i], 1)
+ iter.close()
self.assertEqual(data.oid, oid)
self.assertEqual(data.data, None)
@@ -196,14 +228,16 @@
# copy the final transaction manually. even though there
# was a pack, the restore() ought to succeed.
- final = list(self._storage.iterator())[-1]
+ siter = self._storage.iterator()
+ final = list(siter)[-1]
self._dst.tpc_begin(final, final.tid, final.status)
for r in final:
self._dst.restore(r.oid, r.serial, r.data, r.version, r.data_txn,
final)
+ siter.close()
self._dst.tpc_vote(final)
self._dst.tpc_finish(final)
-
+
def test_suite():
suite = unittest.makeSuite(FileStorageTests, 'check')