[Zope-Checkins] CVS: ZODB3/ZODB/tests - testCache.py:1.17.8.2
Jim Fulton
jim at zope.com
Mon Jan 26 15:37:13 EST 2004
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv23235/src/ZODB/tests
Modified Files:
Tag: zope3-zodb3-devel-branch
testCache.py
Log Message:
Changed a test to remove a non-sensical assertion.
Added a gc.collect and a loud whine (XXX) to another
test to get it to run.
=== ZODB3/ZODB/tests/testCache.py 1.17.8.1 => 1.17.8.2 ===
--- ZODB3/ZODB/tests/testCache.py:1.17.8.1 Fri Jan 23 15:44:25 2004
+++ ZODB3/ZODB/tests/testCache.py Mon Jan 26 15:37:13 2004
@@ -21,6 +21,7 @@
import time
import types
import unittest
+import gc
import ZODB
import ZODB.MappingStorage
@@ -178,13 +179,19 @@
CONNS = 3
for i in range(CONNS):
self.noodle_new_connection()
-
+
self.assertEquals(self.db.cacheSize(), CACHE_SIZE * CONNS)
details = self.db.cacheDetailSize()
self.assertEquals(len(details), CONNS)
for d in details:
self.assertEquals(d['ngsize'], CACHE_SIZE)
- self.assertEquals(d['size'], CACHE_SIZE)
+
+ # The assertion below is non-sensical
+ # The (poorly named) cache size is a target for non-ghosts.
+ # The cache *usually* contains non-ghosts, so that the
+ # size normally exceeds the target size.
+
+ #self.assertEquals(d['size'], CACHE_SIZE)
def checkDetail(self):
CACHE_SIZE = 10
@@ -193,6 +200,28 @@
CONNS = 3
for i in range(CONNS):
self.noodle_new_connection()
+
+ gc.collect()
+
+ # XXX The above gc.collect call is necessary to make this test
+ # pass.
+ #
+ # This test then only works because the other of computations
+ # and object accesses in the "noodle" calls is such that the
+ # persistent mapping containing the MinPO objects is
+ # deactivated before the MinPO objects.
+ #
+ # - Without the gc call, the cache will contain ghost MinPOs
+ # and the check of the MinPO count below will fail. That's
+ # because the counts returned by cacheDetail include ghosts.
+ #
+ # - If the mapping object containing the MinPOs isn't
+ # deactivated, there will be one fewer non-ghost MinPO and
+ # the test will fail anyway.
+ #
+ # This test really needs to be thought through and documented
+ # better.
+
for klass, count in self.db.cacheDetail():
if klass.endswith('MinPO'):
More information about the Zope-Checkins
mailing list