Comment 6 for bug 533015

Revision history for this message
Nikolay Kim (fafhrd91) wrote :

this test raises assertion, tested on python2.6 python2.4 32-bin linux
without patch total_estimated_size is set to 0, and cache size is 1 (at this point cache is cleaned up on each collecting garbage)
with patch total_estimated_size is set to 320 and cache size is 2

    def test_cache_garbage_collection_shrinking_object(self):
        db = self.db
        # activate size based cache garbage collection
        db.setCacheSizeBytes(1000)
        obj, conn, cache = self.obj, self.conn, self.conn._cache
        # verify the change worked as expected
        self.assertEqual(cache.cache_size_bytes, 1000)
        # verify our entrance assumption is fullfilled
        self.assert_(cache.total_estimated_size > 1)
        # give the objects some size
        obj.setValueWithSize(500)
        transaction.savepoint()
        self.assert_(cache.total_estimated_size > 500)
        # make the object smaller
        obj.setValueWithSize(100)
        transaction.savepoint()
        # make sure there was no overflow
        self.assert_(cache.total_estimated_size != 0)