diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-04 15:47:23 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-12 16:24:50 +0000 |
commit | ce8b5769f7e08515edf8988281d17df7b0ddfdaa (patch) | |
tree | 0772f24e99301afd8261de20f097ca7f9ad29fee /tests | |
parent | Add vector counters to HTTP clients and servers; count the requests by method... (diff) | |
download | synapse-ce8b5769f7e08515edf8988281d17df7b0ddfdaa.tar.xz |
Create the concept of a cachecounter metric; generating two counters specific to caches
Diffstat (limited to '')
-rw-r--r-- | tests/metrics/test_metric.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/metrics/test_metric.py b/tests/metrics/test_metric.py index a4fd52a9d5..93e8e27e4f 100644 --- a/tests/metrics/test_metric.py +++ b/tests/metrics/test_metric.py @@ -15,7 +15,7 @@ from tests import unittest -from synapse.metrics.metric import CounterMetric +from synapse.metrics.metric import CounterMetric, CacheCounterMetric class CounterMetricTestCase(unittest.TestCase): @@ -59,3 +59,28 @@ class CounterMetricTestCase(unittest.TestCase): "vector{method=GET} 2", "vector{method=PUT} 1", ]) + + +class CacheCounterMetricTestCase(unittest.TestCase): + + def test_cachecounter(self): + counter = CacheCounterMetric("cache") + + self.assertEquals(counter.render(), [ + "cache:hits 0", + "cache:misses 0", + ]) + + counter.inc_misses() + + self.assertEquals(counter.render(), [ + "cache:hits 0", + "cache:misses 1", + ]) + + counter.inc_hits() + + self.assertEquals(counter.render(), [ + "cache:hits 1", + "cache:misses 1", + ]) |