Mmuzaf commented on code in PR #3002:
URL: https://github.com/apache/cassandra/pull/3002#discussion_r1467817704
##########
test/unit/org/apache/cassandra/auth/AuthCacheTest.java:
##########
@@ -322,6 +322,41 @@ public void
testCacheLoaderIsNotCalledOnGetAllWhenCacheIsNotEmpty()
assertEquals(1, loadCounter);
}
+ @Test
+ public void testMetricsOnCacheEnabled()
+ {
+ TestCache authCache = new TestCache(this::countingLoader,
this::emptyBulkLoader, this::setValidity, () -> validity, () -> isCacheEnabled);
+ authCache.get("10");
+ authCache.get("11");
+
+ assertThat(authCache.getMetrics().requests.getCount()).isEqualTo(2L);
+ assertThat(authCache.getMetrics().hits.getCount()).isEqualTo(0L);
+ assertThat(authCache.getMetrics().misses.getCount()).isEqualTo(2L);
+ assertEquals(2, loadCounter);
+
+ authCache.get("10");
+ authCache.get("11");
+
+ assertThat(authCache.getMetrics().requests.getCount()).isEqualTo(4L);
+ assertThat(authCache.getMetrics().hits.getCount()).isEqualTo(2L);
+ assertThat(authCache.getMetrics().misses.getCount()).isEqualTo(2L);
+ assertEquals(2, loadCounter);
+ }
+
+ @Test
+ public void testMetricsOnCacheDisabled()
Review Comment:
Should we add a test to check that new metrics are available via the JMX
API? I haven't found a good candidate for a test class, but I think it's still
worth checking that `getMaxEntries` and `setMaxEntries` match, and the
`entries` match the number entries we set to the cache.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]