diff options
author | Erik Johnston <erik@matrix.org> | 2020-05-27 13:17:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-27 13:17:01 +0100 |
commit | 4ba55559acf56a041e47ec0d74890d4ad3e0ddb7 (patch) | |
tree | 40c55ade601b4dcf6260bef9f25f6ed2e82e0215 /tests/config/test_cache.py | |
parent | Don't apply cache factor to event cache. (#7578) (diff) | |
download | synapse-4ba55559acf56a041e47ec0d74890d4ad3e0ddb7.tar.xz |
Fix specifying cache factors via env vars with * in name. (#7580)
This mostly applise to `*stateGroupCache*` and co. Broke in #6391.
Diffstat (limited to '')
-rw-r--r-- | tests/config/test_cache.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/config/test_cache.py b/tests/config/test_cache.py index b45e0cc536..d3ec24c975 100644 --- a/tests/config/test_cache.py +++ b/tests/config/test_cache.py @@ -126,6 +126,34 @@ class CacheConfigTests(TestCase): add_resizable_cache("foo", cache_resize_callback=cache.set_cache_factor) self.assertEqual(cache.max_size, 150) + def test_cache_with_asterisk_in_name(self): + """Some caches have asterisks in their name, test that they are set correctly. + """ + + config = { + "caches": { + "per_cache_factors": {"*cache_a*": 5, "cache_b": 6, "cache_c": 2} + } + } + t = TestConfig() + t.caches._environ = { + "SYNAPSE_CACHE_FACTOR_CACHE_A": "2", + "SYNAPSE_CACHE_FACTOR_CACHE_B": 3, + } + t.read_config(config, config_dir_path="", data_dir_path="") + + cache_a = LruCache(100) + add_resizable_cache("*cache_a*", cache_resize_callback=cache_a.set_cache_factor) + self.assertEqual(cache_a.max_size, 200) + + cache_b = LruCache(100) + add_resizable_cache("*Cache_b*", cache_resize_callback=cache_b.set_cache_factor) + self.assertEqual(cache_b.max_size, 300) + + cache_c = LruCache(100) + add_resizable_cache("*cache_c*", cache_resize_callback=cache_c.set_cache_factor) + self.assertEqual(cache_c.max_size, 200) + def test_apply_cache_factor_from_config(self): """Caches can disable applying cache factor updates, mainly used by event cache size. |