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


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

Review Comment:
   Can we use mkMap from Utils?



##########
core/src/test/java/kafka/server/share/DelayedShareFetchTest.java:
##########
@@ -522,6 +532,9 @@ public void testForceCompleteTriggersDelayedActionsQueue() {
 
         doAnswer(invocation -> 
buildLogReadResult(Collections.singleton(tp1))).when(replicaManager).readFromLog(any(),
 any(), any(ReplicaQuota.class), anyBoolean());
 
+        PartitionMaxBytesStrategy partitionMaxBytesStrategy = 
mock(PartitionMaxBytesStrategy.class);
+        mockPartitionMaxBytes(partitionMaxBytesStrategy, 
Collections.singleton(tp1));

Review Comment:
   nit: I think we can do as below: 
   
   ```
   PartitionMaxBytesStrategy partitionMaxBytesStrategy = 
mockPartitionMaxBytes(Collections.singleton(tp1));
   ...
   ...
    private PartitionMaxBytesStrategy 
mockPartitionMaxBytes(Set<TopicIdPartition> partitions) {



##########
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:
   Shouldn't we mock `DelayedShareFetch`?



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

Review Comment:
   Shouldn't we mock `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