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 047b5aefd02 KAFKA-16346 Fix flaky MetricsTest.testMetrics (#15502)
047b5aefd02 is described below

commit 047b5aefd0299811cee364cf55dae8788ede7020
Author: PoAn Yang <[email protected]>
AuthorDate: Wed Jul 31 04:29:04 2024 +0800

    KAFKA-16346 Fix flaky MetricsTest.testMetrics (#15502)
    
    Reviewers: Chia-Ping Tsai <[email protected]>
---
 core/src/test/scala/integration/kafka/api/MetricsTest.scala | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/src/test/scala/integration/kafka/api/MetricsTest.scala 
b/core/src/test/scala/integration/kafka/api/MetricsTest.scala
index 149d3e95663..1b72cb895ed 100644
--- a/core/src/test/scala/integration/kafka/api/MetricsTest.scala
+++ b/core/src/test/scala/integration/kafka/api/MetricsTest.scala
@@ -213,7 +213,8 @@ class MetricsTest extends IntegrationTestHarness with 
SaslSetup {
     assertTrue(tempBytes >= recordSize, s"Unexpected temporary memory size 
requestBytes $requestBytes tempBytes $tempBytes")
 
     
verifyYammerMetricRecorded(s"kafka.server:type=BrokerTopicMetrics,name=ProduceMessageConversionsPerSec")
-    
verifyYammerMetricRecorded(s"$requestMetricsPrefix,name=MessageConversionsTimeMs,request=Produce",
 value => value > 0.0)
+    // if message conversion run too fast, the Math.round(value) may be 0.0, 
so using count to check whether the metric is updated
+    
assertTrue(yammerHistogram(s"$requestMetricsPrefix,name=MessageConversionsTimeMs,request=Produce").count()
 > 0, "MessageConversionsTimeMs count should be > 0")
     
verifyYammerMetricRecorded(s"$requestMetricsPrefix,name=RequestBytes,request=Fetch")
     
verifyYammerMetricRecorded(s"$requestMetricsPrefix,name=TemporaryMemoryBytes,request=Fetch",
 value => value == 0.0)
 

Reply via email to