eclipse / microprofile-metrics

microprofile-metrics
Apache License 2.0
100 stars 66 forks source link

Incorrectly computed metricID for constructor in ConcurrentGaugedClassBeanTest causing intermittent failures #537

Closed jmartisk closed 4 years ago

jmartisk commented 4 years ago

This line computes the expected MetricID of a concurrent gauge created for ConcurrentGaugedClassBean's constructor: https://github.com/eclipse/microprofile-metrics/blob/2.3/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/metrics/ConcurrentGaugedClassBeanTest.java#L117

But it is wrong, because the bean overrides the metric name (using @ConcurrentGauge(name = "cGaugedClass")) so the correct MetricID will be org.eclipse.microprofile.metrics.tck.metrics.cGaugedClass.ConcurrentGaugedClassBean, whereas the said line computes org.eclipse.microprofile.metrics.tck.metrics.ConcurrentGaugedClassBean.ConcurrentGaugedClassBean

Therefore the logic to skip asserting its max value (https://github.com/eclipse/microprofile-metrics/blob/2.3/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/metrics/ConcurrentGaugedClassBeanTest.java#L120) will break and it will always be asserted that the max value is 0, even though the comment above it says that the max can sometimes be 1. This means that the test can intermittently fail if a new full minute starts between the ConcurrentGaugedClassBean instantiation and execution of the assertion on line 120, because in that case the max value will be 1.