apoorvmittal10 commented on code in PR #20826:
URL: https://github.com/apache/kafka/pull/20826#discussion_r2491396746
##########
core/src/test/scala/unit/kafka/server/KafkaApisTest.scala:
##########
@@ -6582,6 +6583,136 @@ class KafkaApisTest extends Logging {
assertArrayEquals(expectedAcquiredRecords(10, 19, 1).toArray(),
topicResponse.partitions.get(0).acquiredRecords.toArray())
}
+ @Test
+ def testHandleShareFetchRequestSuccessWithRenewAcknowledgements(): Unit = {
+ val topicName = "foo"
+ val topicId = Uuid.randomUuid()
+ val partitionIndex = 0
+ metadataCache = initializeMetadataCacheWithShareGroupsEnabled()
+ addTopicToMetadataCache(topicName, 1, topicId = topicId)
+ val memberId: Uuid = Uuid.randomUuid()
+
+ val records1 = memoryRecords(10, 0)
+
+ val groupId = "group"
+
+ when(sharePartitionManager.fetchMessages(any(), any(), any(), anyInt(),
anyInt(), anyInt(), any())).thenReturn(
+ CompletableFuture.completedFuture(util.Map.of[TopicIdPartition,
ShareFetchResponseData.PartitionData](
+ new TopicIdPartition(topicId, new TopicPartition(topicName,
partitionIndex)),
+ new ShareFetchResponseData.PartitionData()
+ .setErrorCode(Errors.NONE.code)
+ .setAcknowledgeErrorCode(Errors.NONE.code)
+ .setRecords(records1)
+ .setAcquiredRecords(new util.ArrayList(util.List.of(
+ new ShareFetchResponseData.AcquiredRecords()
+ .setFirstOffset(0)
+ .setLastOffset(9)
+ .setDeliveryCount(1)
+ )))
+ ))
+ ).thenReturn(
Review Comment:
Why do we need any mocks for sharePartitionManager.fetchMessage if we just
want to test that no fetch happens when renew ack is present? We can simply
check the mocked `sharePartitionManager` that no calls should happen for
`fetchMessages`, correct?
##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -3239,13 +3239,11 @@ class KafkaApis(val requestChannel: RequestChannel,
// Handling the Fetch from the ShareFetchRequest.
// Variable to store the topic partition wise result of fetching.
- val fetchResult: CompletableFuture[Map[TopicIdPartition,
ShareFetchResponseData.PartitionData]] = handleFetchFromShareFetchRequest(
- request,
- shareSessionEpoch,
- erroneousAndValidPartitionData,
- sharePartitionManager,
- authorizedTopics
- )
+ val fetchResult: CompletableFuture[Map[TopicIdPartition,
ShareFetchResponseData.PartitionData]] =
+ if (shareFetchRequest.version() >= 2 &&
shareFetchRequest.data.isRenewAck)
+ CompletableFuture.completedFuture(mutable.Map.empty[TopicIdPartition,
ShareFetchResponseData.PartitionData])
+ else
+ handleFetchFromShareFetchRequest(request, shareSessionEpoch,
erroneousAndValidPartitionData, sharePartitionManager, authorizedTopics)
Review Comment:
Can we please write comments for the changes.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]