This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ee2673c4848 KAFKA-18810 fix flaky 
ClientIdQuotaTest.testQuotaOverrideDelete (#22329)
ee2673c4848 is described below

commit ee2673c48483846fe228a383091ee61e7f44e501
Author: Murali Basani <[email protected]>
AuthorDate: Thu May 21 03:29:13 2026 +0200

    KAFKA-18810 fix flaky ClientIdQuotaTest.testQuotaOverrideDelete (#22329)
    
    Ref : https://issues.apache.org/jira/browse/KAFKA-18810 Marked the
    producer-throttle assertion as "wait until it's true" instead of
    checking immediately
    
    Reviewers: nileshkumar3 <[email protected]>, Chia-Ping Tsai
     <[email protected]>
---
 core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala 
b/core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala
index 13eb169e045..806f95712a9 100644
--- a/core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala
+++ b/core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala
@@ -142,7 +142,6 @@ abstract class BaseQuotaTest extends IntegrationTestHarness 
{
     quotaTestClients.verifyConsumeThrottle(expectThrottle = true)
   }
 
-  @Flaky("KAFKA-18810")
   @ParameterizedTest(name = 
TestInfoUtils.TestWithParameterizedGroupProtocolNames)
   @MethodSource(Array("getTestGroupProtocolParametersAll"))
   def testQuotaOverrideDelete(groupProtocol: String): Unit = {
@@ -288,10 +287,15 @@ abstract class QuotaTestClients(topic: String,
   }
 
   private def verifyThrottleTimeMetric(quotaType: QuotaType, clientId: String, 
expectThrottle: Boolean): Unit = {
-    val throttleMetricValue = metricValue(throttleMetric(quotaType, clientId))
     if (expectThrottle) {
-      assertTrue(throttleMetricValue > 0, s"Client with id=$clientId should 
have been throttled")
+      // Poll until at least one metric is recorded to give the broker thread 
time to flush the throttled value
+      // after the response is sent
+      TestUtils.waitUntilTrue(() => {
+        val metric = throttleMetric(quotaType, clientId)
+        metric != null && metricValue(metric) > 0
+      }, s"Client with id=$clientId should have been throttled")
     } else {
+      val throttleMetricValue = metricValue(throttleMetric(quotaType, 
clientId))
       assertTrue(throttleMetricValue.isNaN, s"Client with id=$clientId should 
not have been throttled")
     }
   }

Reply via email to