echonesis commented on code in PR #11400:
URL: https://github.com/apache/ozone/pull/11400#discussion_r4215675410
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotCache.java:
##########
@@ -170,6 +170,18 @@ public void testGetReleasesReadLockOnLoadFailure() throws
Exception {
verify(lock, times(1)).releaseReadLock(eq(SNAPSHOT_DB_LOCK),
eq(dbKey.toString()));
}
+ @Test
+ @DisplayName("get() of an inactive snapshot does not count towards cache
size")
+ void testGetInactiveSnapshotDoesNotIncrementCacheSize() throws Exception {
+ final UUID dbKey = UUID.randomUUID();
+ when(cacheLoader.load(eq(dbKey)))
+ .thenThrow(new OMException("Snapshot is no longer active",
OMException.ResultCodes.FILE_NOT_FOUND));
+ OMException ex = assertThrows(OMException.class, () ->
snapshotCache.get(dbKey));
+ assertEquals(OMException.ResultCodes.FILE_NOT_FOUND, ex.getResult());
+ assertEquals(0, snapshotCache.size());
+ assertEquals(0, omMetrics.getNumSnapshotCacheSize());
Review Comment:
nit: Could we repeat `get(dbKey)` a few times and assert that both the cache
size and NumSnapshotCacheSize remain zero after each failure? This would
explicitly cover the cumulative metric drift caused by repeated reads of a
purged snapshot.
--
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]