You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by sa...@apache.org on 2023/02/21 03:14:39 UTC

[kafka] branch trunk updated: [MINOR] assert the cache size for each operation in RemoteIndexCacheTest (#13244)

This is an automated email from the ASF dual-hosted git repository.

satishd pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ba6989a77ec [MINOR] assert the cache size for each operation in RemoteIndexCacheTest (#13244)
ba6989a77ec is described below

commit ba6989a77ec799c0875564207828c09216e36bb2
Author: Luke Chen <sh...@gmail.com>
AuthorDate: Tue Feb 21 11:14:25 2023 +0800

    [MINOR] assert the cache size for each operation in RemoteIndexCacheTest (#13244)
    
    Reviewers: Satish Duggana <sa...@apache.org>
---
 .../test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala    | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala b/core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala
index 89afa848ddd..6e2edcb7584 100644
--- a/core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala
+++ b/core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala
@@ -121,8 +121,10 @@ class RemoteIndexCacheTest {
     val tpId = new TopicIdPartition(Uuid.randomUuid(), new TopicPartition("foo", 0))
     val metadataList = generateRemoteLogSegmentMetadata(size = 3, tpId)
 
+    assertEquals(0, cache.entries.size())
     // getIndex for first time will call rsm#fetchIndex
     cache.getIndexEntry(metadataList.head)
+    assertEquals(1, cache.entries.size())
     // Calling getIndex on the same entry should not call rsm#fetchIndex again, but it should retrieve from cache
     cache.getIndexEntry(metadataList.head)
     assertEquals(1, cache.entries.size())
@@ -157,6 +159,7 @@ class RemoteIndexCacheTest {
     val tpId = new TopicIdPartition(Uuid.randomUuid(), new TopicPartition("foo", 0))
     val metadataList = generateRemoteLogSegmentMetadata(size = 3, tpId)
 
+    assertEquals(0, cache.entries.size())
     cache.getIndexEntry(metadataList.head)
     assertEquals(1, cache.entries.size())
     verifyFetchIndexInvocation(count = 1)
@@ -173,8 +176,10 @@ class RemoteIndexCacheTest {
     val tpId = new TopicIdPartition(Uuid.randomUuid(), new TopicPartition("foo", 0))
     val metadataList = generateRemoteLogSegmentMetadata(size = 3, tpId)
 
+    assertEquals(0, cache.entries.size())
     // getIndex for first time will call rsm#fetchIndex
     cache.getIndexEntry(metadataList.head)
+    assertEquals(1, cache.entries.size())
     // Calling getIndex on the same entry should not call rsm#fetchIndex again, but it should retrieve from cache
     cache.getIndexEntry(metadataList.head)
     assertEquals(1, cache.entries.size())
@@ -182,6 +187,7 @@ class RemoteIndexCacheTest {
 
     // Here a new key metadataList(1) is invoked, that should call rsm#fetchIndex, making the count to 2
     cache.getIndexEntry(metadataList(1))
+    assertEquals(2, cache.entries.size())
     // Calling getIndex on the same entry should not call rsm#fetchIndex again, but it should retrieve from cache
     cache.getIndexEntry(metadataList(1))
     assertEquals(2, cache.entries.size())
@@ -189,6 +195,7 @@ class RemoteIndexCacheTest {
 
     // Here a new key metadataList(2) is invoked, that should call rsm#fetchIndex, making the count to 2
     cache.getIndexEntry(metadataList(2))
+    assertEquals(2, cache.entries.size())
     // Calling getIndex on the same entry should not call rsm#fetchIndex again, but it should retrieve from cache
     cache.getIndexEntry(metadataList(2))
     assertEquals(2, cache.entries.size())