chia7712 commented on code in PR #16687:
URL: https://github.com/apache/kafka/pull/16687#discussion_r1703061733


##########
core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala:
##########
@@ -94,6 +95,26 @@ class PlaintextAdminIntegrationTest extends 
BaseAdminIntegrationTest {
     super.tearDown()
   }
 
+  @ParameterizedTest
+  @ValueSource(strings = Array("zk", "kraft"))
+  def testCreatePartitionWithOptionRetryOnQuotaViolation(): Unit = {
+    // Since it's hard to stably reach quota limit in integration test, we 
only verify quota configs are set correctly
+    client = createAdminClient
+    val entity = new ClientQuotaEntity(Map(ClientQuotaEntity.CLIENT_ID -> 
clientId).asJava)
+
+    val configEntries = 
Map(QuotaConfigs.CONTROLLER_MUTATION_RATE_OVERRIDE_CONFIG -> 1.0, 
QuotaConfigs.CONSUMER_BYTE_RATE_OVERRIDE_CONFIG -> 3.0)
+    val quotas = configEntries.map {case (k, v) => new 
ClientQuotaAlteration.Op(k,v)}
+    val alterResult = client.alterClientQuotas(Seq(new 
ClientQuotaAlteration(entity, quotas.asJavaCollection)).asJavaCollection)
+    alterResult.all.get
+
+    val describeResult = client.describeClientQuotas(ClientQuotaFilter.all())
+    val quotaEntries = describeResult.entities().get()
+
+    assertTrue(quotaEntries.size() == 1)

Review Comment:
   `assertEquals(1, quotaEntries.size())`



##########
core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala:
##########
@@ -94,6 +95,26 @@ class PlaintextAdminIntegrationTest extends 
BaseAdminIntegrationTest {
     super.tearDown()
   }
 
+  @ParameterizedTest
+  @ValueSource(strings = Array("zk", "kraft"))
+  def testCreatePartitionWithOptionRetryOnQuotaViolation(): Unit = {
+    // Since it's hard to stably reach quota limit in integration test, we 
only verify quota configs are set correctly
+    client = createAdminClient
+    val entity = new ClientQuotaEntity(Map(ClientQuotaEntity.CLIENT_ID -> 
clientId).asJava)
+
+    val configEntries = 
Map(QuotaConfigs.CONTROLLER_MUTATION_RATE_OVERRIDE_CONFIG -> 1.0, 
QuotaConfigs.CONSUMER_BYTE_RATE_OVERRIDE_CONFIG -> 3.0)
+    val quotas = configEntries.map {case (k, v) => new 
ClientQuotaAlteration.Op(k,v)}
+    val alterResult = client.alterClientQuotas(Seq(new 
ClientQuotaAlteration(entity, quotas.asJavaCollection)).asJavaCollection)
+    alterResult.all.get
+
+    val describeResult = client.describeClientQuotas(ClientQuotaFilter.all())

Review Comment:
   kafka metadata may be not synced so quick, and hence we need to use 
`TestUtils.waitUntilTrue` to loop it to avoid flaky test



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