showuon commented on code in PR #21089:
URL: https://github.com/apache/kafka/pull/21089#discussion_r2641816522


##########
storage/src/test/java/org/apache/kafka/storage/internals/log/RemoteIndexCacheTest.java:
##########
@@ -1309,4 +1309,103 @@ private Set<Thread> getRunningCleanerThread() {
                 .filter(t -> t.isAlive() && 
t.getName().startsWith(REMOTE_LOG_INDEX_CACHE_CLEANER_THREAD))
                 .collect(Collectors.toSet());
     }
+
+    @Test
+    public void testCacheTtlCanBeDisabled() throws IOException {
+        // Test that TTL can be disabled by setting it to -1
+        long ttlMs = -1L;
+        FakeTicker fakeTicker = new FakeTicker();
+        RemoteIndexCache ttlCache = new RemoteIndexCache(1024 * 1024L, ttlMs, 
rsm, logDir.toString(), fakeTicker);
+        try {
+            RemoteIndexCache.Entry entry = ttlCache.getIndexEntry(rlsMetadata);
+            assertNotNull(entry);
+
+            fakeTicker.advance(TimeUnit.HOURS.toNanos(24));
+            ttlCache.internalCache().cleanUp();
+
+            RemoteIndexCache.Entry cachedEntry = 
ttlCache.internalCache().getIfPresent(rlsMetadata.remoteLogSegmentId().id());
+            assertNotNull(cachedEntry, "Entry should remain cached when TTL 
disabled");
+        } finally {
+            Utils.closeQuietly(ttlCache, "RemoteIndexCache");
+        }
+    }
+
+    @Test
+    public void testCacheTtlEviction() throws IOException {

Review Comment:
   Nice tests! Thanks for adding them! Could we add one more test to verify 
that both size-based and time-based eviction strategy work well? Currently we 
have `testCacheEntryExpiry` for size-based eviction test, and time-based 
eviction tests here. So, maybe mix them together with scenario like:
   1. create a RemoteIndexCache with sizeLimit and ttlMs set.
   2. add entries over sizeLimit, and make sure eviction happened
   3. ticker advanced over ttlMs, and make sure eviction happened
   
   something like that. Thanks.



-- 
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]

Reply via email to