rjgoyln commented on code in PR #11400:
URL: https://github.com/apache/ozone/pull/11400#discussion_r4217835133
##########
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:
Done, the test now reads the purged snapshot three times and checks both
values after each failure. Thanks for the review!
--
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]