chirag-wadhwa5 commented on code in PR #19500:
URL: https://github.com/apache/kafka/pull/19500#discussion_r2049324837


##########
server/src/test/java/org/apache/kafka/server/share/session/ShareSessionCacheTest.java:
##########
@@ -44,75 +43,45 @@ public void setUp() {
 
     @Test
     public void testShareSessionCache() throws InterruptedException {
-        ShareSessionCache cache = new ShareSessionCache(3, 100);
+        ShareSessionCache cache = new ShareSessionCache(3);
         assertEquals(0, cache.size());
-        ShareSessionKey key1 = cache.maybeCreateSession("grp", 
Uuid.randomUuid(), 0, mockedSharePartitionMap(10));
-        ShareSessionKey key2 = cache.maybeCreateSession("grp", 
Uuid.randomUuid(), 10, mockedSharePartitionMap(20));
-        ShareSessionKey key3 = cache.maybeCreateSession("grp", 
Uuid.randomUuid(), 20, mockedSharePartitionMap(30));
-        assertNull(cache.maybeCreateSession("grp", Uuid.randomUuid(), 30, 
mockedSharePartitionMap(40)));
-        assertNull(cache.maybeCreateSession("grp", Uuid.randomUuid(), 40, 
mockedSharePartitionMap(5)));
+        ShareSessionKey key1 = cache.maybeCreateSession("grp", 
Uuid.randomUuid(), mockedSharePartitionMap(10));
+        ShareSessionKey key2 = cache.maybeCreateSession("grp", 
Uuid.randomUuid(), mockedSharePartitionMap(20));
+        ShareSessionKey key3 = cache.maybeCreateSession("grp", 
Uuid.randomUuid(), mockedSharePartitionMap(30));
+        assertNull(cache.maybeCreateSession("grp", Uuid.randomUuid(), 
mockedSharePartitionMap(40)));
+        assertNull(cache.maybeCreateSession("grp", Uuid.randomUuid(), 
mockedSharePartitionMap(5)));
         assertShareCacheContains(cache, List.of(key1, key2, key3));
 
-        TestUtils.waitForCondition(() -> 
yammerMetricValue(ShareSessionCache.SHARE_SESSIONS_COUNT).intValue() == 3,
-            "Share session count should be 3.");
-        TestUtils.waitForCondition(() -> 
yammerMetricValue(ShareSessionCache.SHARE_PARTITIONS_COUNT).intValue() == 60,
-            "Share partition count should be 60.");
-        assertEquals(0, cache.evictionsMeter().count());
-
-        // Touch the sessions to update the last used time, so that the key-2 
can be evicted.
-        cache.touch(cache.get(key1), 200);

Review Comment:
   Thanks for the review. This test actually touched the cache so that inactive 
sessions could be evicted and new ones could be added to the cache. But the 
eviction logic is removed now so replacing touch with updateNumPartitions 
wouldn't pass the test. Also since the resizing of cache session is being 
tested in the next test in this file, I removed the other logic to let this one 
only test the addition of sessions 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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to