chirag-wadhwa5 commented on code in PR #19637:
URL: https://github.com/apache/kafka/pull/19637#discussion_r2078441931


##########
core/src/test/scala/unit/kafka/server/KafkaApisTest.scala:
##########
@@ -6380,6 +6380,42 @@ class KafkaApisTest extends Logging {
     assertEquals(0, 
topicResponses.get(0).partitions.get(0).acquiredRecords.toArray().length)
   }
 
+  @Test
+  def handleShareFetchRequestThrottlingWhenSessionCacheIsFull(): Unit = {
+    metadataCache = initializeMetadataCacheWithShareGroupsEnabled()
+
+    val groupId = "group"
+    val memberId: Uuid = Uuid.ZERO_UUID
+    val maxWaitMs: Int = 2000
+
+    doThrow(new ShareSessionLimitReachedException("Share session exceeded"))
+      .when(sharePartitionManager).newContext(any(), any(), any(), any(), 
any(), any());
+
+    val shareFetchRequestData = new ShareFetchRequestData().
+      setGroupId(groupId).
+      setMemberId(memberId.toString).
+      setShareSessionEpoch(ShareRequestMetadata.INITIAL_EPOCH).
+      setTopics(List().asJava).
+      setMaxWaitMs(maxWaitMs)
+
+    val shareFetchRequest = new 
ShareFetchRequest.Builder(shareFetchRequestData).build(ApiKeys.SHARE_FETCH.latestVersion)
+    val request = buildRequest(shareFetchRequest)
+    kafkaApis = createKafkaApis()
+    kafkaApis.handleShareFetchRequest(request)
+    val response = verifyNoThrottling[ShareFetchResponse](request)
+    val responseData = response.data()
+
+    val expectedThrottleTimeMs = maxWaitMs
+
+    verify(clientRequestQuotaManager).throttle(
+      ArgumentMatchers.eq(request),
+      any[ThrottleCallback](),
+      ArgumentMatchers.eq(expectedThrottleTimeMs)
+    )
+
+    assertEquals(expectedThrottleTimeMs, responseData.throttleTimeMs)
+  }

Review Comment:
   I have added a new test in the latest commit.



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