adixitconfluent commented on code in PR #18725:
URL: https://github.com/apache/kafka/pull/18725#discussion_r1933573691


##########
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala:
##########
@@ -5977,6 +5980,64 @@ class ReplicaManagerTest {
     )
   }
 
+  @Test
+  def testDelayedShareFetchPurgatoryOperationExpiration(): Unit = {
+    val mockLogMgr = TestUtils.createLogManager(config.logDirs.map(new 
File(_)))
+    val rm = new ReplicaManager(
+      metrics = metrics,
+      config = config,
+      time = time,
+      scheduler = new MockScheduler(time),
+      logManager = mockLogMgr,
+      quotaManagers = quotaManager,
+      metadataCache = MetadataCache.kRaftMetadataCache(config.brokerId, () => 
KRaftVersion.KRAFT_VERSION_0),
+      logDirFailureChannel = new LogDirFailureChannel(config.logDirs.size),
+      alterPartitionManager = alterPartitionManager)
+
+    val groupId = "grp"
+    val tp1 = new TopicIdPartition(Uuid.randomUuid, new TopicPartition("foo1", 
0))
+    val partitionMaxBytes = new util.LinkedHashMap[TopicIdPartition, Integer]
+    partitionMaxBytes.put(tp1, 1000)
+
+    val sp1 = mock(classOf[SharePartition])
+    val sharePartitions = new util.LinkedHashMap[TopicIdPartition, 
SharePartition]
+    sharePartitions.put(tp1, sp1)
+
+    val future = new CompletableFuture[util.Map[TopicIdPartition, 
ShareFetchResponseData.PartitionData]]
+    val shareFetch = new ShareFetch(
+      new FetchParams(ApiKeys.SHARE_FETCH.latestVersion, 
FetchRequest.ORDINARY_CONSUMER_ID, -1, 500, 1, 1024 * 1024, 
FetchIsolation.HIGH_WATERMARK, Optional.empty, true),
+      groupId,
+      Uuid.randomUuid.toString,
+      future,
+      partitionMaxBytes,
+      500,
+      100,
+      brokerTopicStats)
+
+    val delayedShareFetch = new DelayedShareFetch(
+      shareFetch,
+      rm,
+      mock(classOf[BiConsumer[SharePartitionKey, Throwable]]),
+      sharePartitions)

Review Comment:
   I think the relevant attributes of `DelayedShareFetch` have already been 
mocked, for example - exception handler. If we don't do this, we'd have to 
write a bunch of `when` statements for `delayedShareFetch`. Hence, I prefer an 
instance instead of a mock. We are not playing with the behaviour of 
`DelayedShareFetch` and we need `shareFetch`



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