[Zodb-checkins] CVS: ZODB3/ZEO/tests - testClientCache.py:1.6.38.1
Guido van Rossum
guido@python.org
Tue, 17 Dec 2002 15:30:09 -0500
Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv14329/ZEO/tests
Modified Files:
Tag: ZODB3-fast-restart-branch
testClientCache.py
Log Message:
Add a new feature: the cache can store the last transaction id (set by
the client storage). This is to make the validation optimization work
for persistent caches.
=== ZODB3/ZEO/tests/testClientCache.py 1.6 => 1.6.38.1 ===
--- ZODB3/ZEO/tests/testClientCache.py:1.6 Wed Sep 18 17:22:58 2002
+++ ZODB3/ZEO/tests/testClientCache.py Tue Dec 17 15:30:08 2002
@@ -261,6 +261,19 @@
self.assert_(None is not cache._index.get(oid1) < 0)
self.assert_(None is not cache._index.get(oid2) < 0)
+ def testLastTid(self):
+ cache = self.cache
+ self.failUnless(cache.getLastTid() is None)
+ ltid = 'pqrstuvw'
+ cache.setLastTid(ltid)
+ self.assertEqual(cache.getLastTid(), ltid)
+ cache.checkSize(10*self.cachesize) # Force a file flip
+ self.assertEqual(cache.getLastTid(), ltid)
+ cache.setLastTid(None)
+ self.failUnless(cache.getLastTid() is None)
+ cache.checkSize(10*self.cachesize) # Force a file flip
+ self.failUnless(cache.getLastTid() is None)
+
class PersistentClientCacheTests(unittest.TestCase):
def setUp(self):
@@ -347,6 +360,26 @@
if loaded != None:
self.fail("invalidated data resurrected, size %d, was %d" %
(len(loaded[0]), len(data)))
+
+ def testPersistentLastTid(self):
+ cache = self.cache
+ self.failUnless(cache.getLastTid() is None)
+ ltid = 'pqrstuvw'
+ cache.setLastTid(ltid)
+ self.assertEqual(cache.getLastTid(), ltid)
+ oid = 'abcdefgh'
+ data = '1234'
+ serial = 'ABCDEFGH'
+ cache.store(oid, data, serial, '', '', '')
+ self.assertEqual(cache.getLastTid(), ltid)
+ cache.checkSize(10*self.cachesize) # Force a file flip
+ self.assertEqual(cache.getLastTid(), ltid)
+ cache = self.reopenCache()
+ self.assertEqual(cache.getLastTid(), ltid)
+ cache.setLastTid(None)
+ self.failUnless(cache.getLastTid() is None)
+ cache.checkSize(10*self.cachesize) # Force a file flip
+ self.failUnless(cache.getLastTid() is None)
def test_suite():
suite = unittest.TestSuite()