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 aa978061feea5c777d96b2293bc2e5b54399ef10 Author: Benoit Tellier <[email protected]> AuthorDate: Sat Mar 7 04:45:15 2020 +0100 JAMES-3104 Eventually publish blob store metrics This enhancement improve build stability --- server/blob/blob-api/pom.xml | 5 +++ .../blob/api/MetricableBlobStoreContract.java | 38 ++++++++++++++-------- server/blob/blob-cassandra/pom.xml | 5 +++ server/blob/blob-memory/pom.xml | 5 +++ server/blob/blob-objectstorage/pom.xml | 5 +++ 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/server/blob/blob-api/pom.xml b/server/blob/blob-api/pom.xml index cbe5c0e..8c9182b 100644 --- a/server/blob/blob-api/pom.xml +++ b/server/blob/blob-api/pom.xml @@ -70,6 +70,11 @@ <artifactId>commons-lang3</artifactId> </dependency> <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> diff --git a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java index c11b117..ca346db 100644 --- a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java +++ b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java @@ -27,11 +27,14 @@ import static org.apache.james.blob.api.MetricableBlobStore.READ_TIMER_NAME; import static org.apache.james.blob.api.MetricableBlobStore.SAVE_BYTES_TIMER_NAME; import static org.apache.james.blob.api.MetricableBlobStore.SAVE_INPUT_STREAM_TIMER_NAME; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import org.apache.james.metrics.tests.RecordingMetricFactory; +import org.awaitility.Duration; +import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; @@ -67,8 +70,9 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { Mono.from(store.save(store.getDefaultBucketName(), BYTES_CONTENT, LOW_COST)).block(); Mono.from(store.save(store.getDefaultBucketName(), BYTES_CONTENT, LOW_COST)).block(); - assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_BYTES_TIMER_NAME)) - .hasSize(2); + await().atMost(Duration.FIVE_SECONDS) + .untilAsserted(() -> assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_BYTES_TIMER_NAME)) + .hasSize(2)); } @Test @@ -78,8 +82,9 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { Mono.from(store.save(store.getDefaultBucketName(), STRING_CONTENT, LOW_COST)).block(); Mono.from(store.save(store.getDefaultBucketName(), STRING_CONTENT, LOW_COST)).block(); - assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_BYTES_TIMER_NAME)) - .hasSize(2); + await().atMost(Duration.FIVE_SECONDS) + .untilAsserted(() -> assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_BYTES_TIMER_NAME)) + .hasSize(2)); } @Test @@ -89,8 +94,9 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { Mono.from(store.save(store.getDefaultBucketName(), new ByteArrayInputStream(BYTES_CONTENT), LOW_COST)).block(); Mono.from(store.save(store.getDefaultBucketName(), new ByteArrayInputStream(BYTES_CONTENT), LOW_COST)).block(); - assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_INPUT_STREAM_TIMER_NAME)) - .hasSize(2); + await().atMost(Duration.FIVE_SECONDS) + .untilAsserted(() -> assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_INPUT_STREAM_TIMER_NAME)) + .hasSize(2)); } @Test @@ -101,8 +107,9 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { Mono.from(store.readBytes(store.getDefaultBucketName(), blobId)).block(); Mono.from(store.readBytes(store.getDefaultBucketName(), blobId)).block(); - assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(READ_BYTES_TIMER_NAME)) - .hasSize(2); + await().atMost(Duration.FIVE_SECONDS) + .untilAsserted(() -> assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(READ_BYTES_TIMER_NAME)) + .hasSize(2)); } @Test @@ -113,8 +120,9 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { store.read(store.getDefaultBucketName(), blobId); store.read(store.getDefaultBucketName(), blobId); - assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(READ_TIMER_NAME)) - .hasSize(2); + await().atMost(Duration.FIVE_SECONDS) + .untilAsserted(() -> assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(READ_TIMER_NAME)) + .hasSize(2)); } @Test @@ -127,8 +135,9 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { Mono.from(store.deleteBucket(bucketName)).block(); - assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(DELETE_BUCKET_TIMER_NAME)) - .hasSize(1); + await().atMost(Duration.FIVE_SECONDS) + .untilAsserted(() -> assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(DELETE_BUCKET_TIMER_NAME)) + .hasSize(1)); } @Test @@ -141,7 +150,8 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { Mono.from(store.delete(BucketName.DEFAULT, blobId1)).block(); Mono.from(store.delete(BucketName.DEFAULT, blobId2)).block(); - assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(DELETE_TIMER_NAME)) - .hasSize(2); + await().atMost(Duration.FIVE_SECONDS) + .untilAsserted(() -> assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(DELETE_TIMER_NAME)) + .hasSize(2)); } } \ No newline at end of file diff --git a/server/blob/blob-cassandra/pom.xml b/server/blob/blob-cassandra/pom.xml index dcaf57c..8894ca6 100644 --- a/server/blob/blob-cassandra/pom.xml +++ b/server/blob/blob-cassandra/pom.xml @@ -72,6 +72,11 @@ <artifactId>guava</artifactId> </dependency> <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers</artifactId> <scope>test</scope> diff --git a/server/blob/blob-memory/pom.xml b/server/blob/blob-memory/pom.xml index 6a6888c..76f67e3 100644 --- a/server/blob/blob-memory/pom.xml +++ b/server/blob/blob-memory/pom.xml @@ -66,6 +66,11 @@ <artifactId>reactor-core</artifactId> </dependency> <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> diff --git a/server/blob/blob-objectstorage/pom.xml b/server/blob/blob-objectstorage/pom.xml index 9f66fae..287b193 100644 --- a/server/blob/blob-objectstorage/pom.xml +++ b/server/blob/blob-objectstorage/pom.xml @@ -112,6 +112,11 @@ <version>${jclouds.version}</version> </dependency> <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers</artifactId> <scope>test</scope> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
