This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit e84e7a439d19ba82a2d71a43ae2528afd800320e Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Tue Jun 30 13:04:10 2020 +0700 JAMES-3170 Correctly test MetricFactory reactive integration Testing wrapping in a Flux or a Mono. We highlight the fact that wrapping the metric factory with a Mono fails at recording the timings, and record zero instead. --- .../dropwizard/DropWizardMetricFactoryTest.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/metrics/metrics-dropwizard/src/test/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactoryTest.java b/metrics/metrics-dropwizard/src/test/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactoryTest.java index 968095e..87455bf 100644 --- a/metrics/metrics-dropwizard/src/test/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactoryTest.java +++ b/metrics/metrics-dropwizard/src/test/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactoryTest.java @@ -28,6 +28,7 @@ import org.apache.james.metrics.api.MetricFactory; import org.apache.james.metrics.api.MetricFactoryContract; import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import com.codahale.metrics.MetricRegistry; @@ -61,6 +62,37 @@ class DropWizardMetricFactoryTest implements MetricFactoryContract { } @Test + void decoratePublisherWithTimerMetricShouldRecordAtLeastTheMonoDelayWhenWrappedInAFlux() { + Duration duration = Duration.ofMillis(100); + Flux.from(testee.decoratePublisherWithTimerMetric("any", Mono.delay(duration))) + .blockLast(); + + assertThat(testee.timer("any").getTimer().getSnapshot().get99thPercentile()) + .isGreaterThan(duration.get(ChronoUnit.NANOS)); + } + + @Disabled("Recorded timing is 0") + @Test + void decoratePublisherWithTimerMetricShouldRecordAtLeastTheMonoDelayWhenWrappedInAMono() { + Duration duration = Duration.ofMillis(100); + Mono.from(testee.decoratePublisherWithTimerMetric("any", Mono.delay(duration))) + .block(); + + assertThat(testee.timer("any").getTimer().getSnapshot().get99thPercentile()) + .isGreaterThan(duration.get(ChronoUnit.NANOS)); + } + + @Test + void decoratePublisherWithTimerMetricShouldRecordAtLeastTheFluxDelayWhenWrappedInAFlux() { + Duration duration = Duration.ofMillis(100); + Flux.from(testee.decoratePublisherWithTimerMetric("any", Flux.interval(duration).take(1))) + .blockLast(); + + assertThat(testee.timer("any").getTimer().getSnapshot().get99thPercentile()) + .isGreaterThan(duration.get(ChronoUnit.NANOS)); + } + + @Test void decoratePublisherWithTimerMetricLogP99ShouldRecordANewValueForEachRetry() { Duration duration = Duration.ofMillis(100); Mono.from(testee.decoratePublisherWithTimerMetricLogP99("any", Mono.delay(duration))) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org