summary refs log tree commit diff
path: root/tests/config/test_cache.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-05-27 12:04:37 +0100
committerGitHub <noreply@github.com>2020-05-27 12:04:37 +0100
commiteefc6b3a0d08cd2a64be7c78c0a4a651cc965be9 (patch)
treeca91c6cf8a1b5639668f68f639c99a1c1ff32b3b /tests/config/test_cache.py
parentEnsure ReplicationStreamer is always started when replication enabled. (#7579) (diff)
downloadsynapse-eefc6b3a0d08cd2a64be7c78c0a4a651cc965be9.tar.xz
Don't apply cache factor to event cache. (#7578)
This is already correctly done when we instansiate the cache, but wasn't
when it got reloaded (which always happens at least once on startup).
Diffstat (limited to 'tests/config/test_cache.py')
-rw-r--r--tests/config/test_cache.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/config/test_cache.py b/tests/config/test_cache.py
index 2920279125..b45e0cc536 100644
--- a/tests/config/test_cache.py
+++ b/tests/config/test_cache.py
@@ -125,3 +125,19 @@ class CacheConfigTests(TestCase):
         cache = LruCache(100)
         add_resizable_cache("foo", cache_resize_callback=cache.set_cache_factor)
         self.assertEqual(cache.max_size, 150)
+
+    def test_apply_cache_factor_from_config(self):
+        """Caches can disable applying cache factor updates, mainly used by
+        event cache size.
+        """
+
+        config = {"caches": {"event_cache_size": "10k"}}
+        t = TestConfig()
+        t.read_config(config, config_dir_path="", data_dir_path="")
+
+        cache = LruCache(
+            max_size=t.caches.event_cache_size, apply_cache_factor_from_config=False,
+        )
+        add_resizable_cache("event_cache", cache_resize_callback=cache.set_cache_factor)
+
+        self.assertEqual(cache.max_size, 10240)