From 59e80b2ec92928bf3a7ece9dd9a3d67b78f70486 Mon Sep 17 00:00:00 2001 From: david-sarah Date: Sun, 24 Oct 2010 12:34:09 -0700 Subject: [PATCH] test_mutable.py: add test for ResponseCache memory leak. refs #1045, #1129 --- src/allmydata/test/test_mutable.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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): -- 2.45.2