apoorvmittal10 commented on code in PR #18725: URL: https://github.com/apache/kafka/pull/18725#discussion_r1933620080
########## 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: Hmmm, sure but how do we guarantee that the request was timeout and not copleted in normal flow. By checking `assertFalse(future.isDone)` initially? Or should we also check the method call which should only happen when timeout gets triggered i.e. `forceComplete`? -- 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