chia7712 commented on PR #15463:
URL: https://github.com/apache/kafka/pull/15463#issuecomment-2028125395

   > For my understanding, Could you please explain how this patch fixed the 
issue? The safeYammerMetricValue was also returning the meter count. Thanks!
   
   @kamalcph the variable of metrics item 
(`kafka.server:type=DelayedRemoteFetchMetrics,name=ExpiresPerSec`) is singleton 
object and it could be removed by other tests which are running in same JVM 
(and it is not recreated). Hence, verifying the metrics value is not stable to 
this test case.
   
   For example, the following test case fails on the last `assert`
   ```scala
       TestUtils.clearYammerMetrics()
       DelayedRemoteFetchMetrics.expiredRequestMeter.mark()
       // pass since the singleton object is created lazily when it is used
       assertEquals(1, 
safeYammerMetricValue("type=DelayedRemoteFetchMetrics,name=ExpiresPerSec").asInstanceOf[Long])
       TestUtils.clearYammerMetrics()
       assertEquals(0, 
safeYammerMetricValue("type=DelayedRemoteFetchMetrics,name=ExpiresPerSec").asInstanceOf[Long])
       DelayedRemoteFetchMetrics.expiredRequestMeter.mark()
       // fails since the object is removed from yammer
       assertEquals(1, 
safeYammerMetricValue("type=DelayedRemoteFetchMetrics,name=ExpiresPerSec").asInstanceOf[Long])
   ````


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