From: david-sarah Date: Sun, 24 Oct 2010 19:34:09 +0000 (-0700) Subject: test_mutable.py: add test for ResponseCache memory leak. refs #1045, #1129 X-Git-Tag: trac-4800~38 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/reliability?a=commitdiff_plain;h=59e80b2ec92928bf3a7ece9dd9a3d67b78f70486;p=tahoe-lafs%2Ftahoe-lafs.git test_mutable.py: add test for ResponseCache memory leak. refs #1045, #1129 --- diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 021e1966..375de1ff 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -294,6 +294,24 @@ class Filenode(unittest.TestCase, testutil.ShouldFailMixin): d.addCallback(_created) return d + def test_response_cache_memory_leak(self): + d = self.nodemaker.create_mutable_file("contents") + def _created(n): + d = n.download_best_version() + d.addCallback(lambda res: self.failUnlessEqual(res, "contents")) + d.addCallback(lambda ign: self.failUnless(isinstance(n._cache, ResponseCache))) + + def _check_cache_size(expected): + # The total size of cache entries should not increase on the second download. + d2 = n.download_best_version() + d2.addCallback(lambda ign: self.failUnlessEqual(len(repr(n._cache.cache)), expected)) + return d2 + d.addCallback(lambda ign: _check_cache_size(len(repr(n._cache.cache)))) + return d + d.addCallback(_created) + return d + test_response_cache_memory_leak.todo = "This isn't fixed (see #1045)." + def test_create_with_initial_contents_function(self): data = "initial contents" def _make_contents(n):