hudeqi commented on code in PR #14243:
URL: https://github.com/apache/kafka/pull/14243#discussion_r1319841547


##########
core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala:
##########
@@ -594,4 +575,16 @@ class RemoteIndexCacheTest {
       timeIndex.flush()
     }
   }
+
+  private def getEstimateEntryBytesSize(): Long = {
+    val cacheForEstimate = new RemoteIndexCache(2L, rsm, tpDir.toString)
+    val tpIdForEstimate = new TopicIdPartition(Uuid.randomUuid(), new 
TopicPartition("foo", 0))
+    val metadataListForEstimate = generateRemoteLogSegmentMetadata(size = 1, 
tpIdForEstimate)
+    val entryForEstimate = 
cacheForEstimate.getIndexEntry(metadataListForEstimate.head)
+    val estimateEntryBytesSize = entryForEstimate.entrySizeBytes()
+    Utils.closeQuietly(cacheForEstimate, "RemoteIndexCache created for 
estimating entry size")
+    cleanup()
+    setup()

Review Comment:
   > These 2 calls are unnecessary. Why can't we just do `clearInvocations` 
here?
   
   Because I have reused `tpDir` here, if not delete this `tpDir` after 
estimating the entry size (here, for convenience, I directly call `cleanup()` 
and `setup()` to reset), it will result in After the new cache in @Test is 
initialized later, the entry corresponding to `tpDir` is directly loaded, 
causing `assertCacheSize(0)` to fail.
   So I can also remove `cleanup()` and `setup()`, and change it to: use a 
different `tpDir` to execute the estimating logic. @showuon 



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