This is an automated email from the ASF dual-hosted git repository. rouazana pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 4168bf1389dc6a962ba6110e86023f70fdd17cd3 Author: Rene Cordier <[email protected]> AuthorDate: Mon Jul 15 14:40:16 2019 +0700 JAMES-2829 add delete implementation for MetricableBlobStore and test in its contract --- .../org/apache/james/blob/api/MetricableBlobStore.java | 7 ++++--- .../james/blob/api/MetricableBlobStoreContract.java | 17 ++++++++++++++++- .../james/blob/cassandra/CassandraBlobsDAOTest.java | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java index d673b97..5b82cb4 100644 --- a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java +++ b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/MetricableBlobStore.java @@ -23,7 +23,6 @@ import java.io.InputStream; import javax.inject.Inject; import javax.inject.Named; -import org.apache.commons.lang3.NotImplementedException; import org.apache.james.metrics.api.MetricFactory; import reactor.core.publisher.Mono; @@ -38,6 +37,7 @@ public class MetricableBlobStore implements BlobStore { static final String READ_BYTES_TIMER_NAME = BLOB_STORE_METRIC_PREFIX + "readBytes"; static final String READ_TIMER_NAME = BLOB_STORE_METRIC_PREFIX + "read"; static final String DELETE_TIMER_NAME = BLOB_STORE_METRIC_PREFIX + "delete"; + static final String DELETE_BUCKET_TIMER_NAME = BLOB_STORE_METRIC_PREFIX + "deleteBucket"; private final MetricFactory metricFactory; private final BlobStore blobStoreImpl; @@ -76,7 +76,7 @@ public class MetricableBlobStore implements BlobStore { @Override public Mono<Void> deleteBucket(BucketName bucketName) { return metricFactory - .runPublishingTimerMetric(DELETE_TIMER_NAME, () -> blobStoreImpl.deleteBucket(bucketName)); + .runPublishingTimerMetric(DELETE_BUCKET_TIMER_NAME, () -> blobStoreImpl.deleteBucket(bucketName)); } @Override @@ -86,6 +86,7 @@ public class MetricableBlobStore implements BlobStore { @Override public Mono<Void> delete(BucketName bucketName, BlobId blobId) { - throw new NotImplementedException("not implemented"); + return metricFactory + .runPublishingTimerMetric(DELETE_TIMER_NAME, () -> blobStoreImpl.delete(bucketName, blobId)); } } 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 6373b42..481aa98 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 @@ -19,6 +19,7 @@ package org.apache.james.blob.api; +import static org.apache.james.blob.api.MetricableBlobStore.DELETE_BUCKET_TIMER_NAME; import static org.apache.james.blob.api.MetricableBlobStore.DELETE_TIMER_NAME; import static org.apache.james.blob.api.MetricableBlobStore.READ_BYTES_TIMER_NAME; import static org.apache.james.blob.api.MetricableBlobStore.READ_TIMER_NAME; @@ -30,6 +31,7 @@ import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import org.apache.james.metrics.tests.RecordingMetricFactory; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; @@ -104,7 +106,7 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { } @Test - default void deleteBucketShouldPublishDeleteTimerMetrics() { + default void deleteBucketShouldPublishDeleteBucketTimerMetrics() { BucketName bucketName = BucketName.of("custom"); testee().save(BucketName.DEFAULT, BYTES_CONTENT).block(); testee().save(bucketName, BYTES_CONTENT).block(); @@ -112,6 +114,19 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { testee().deleteBucket(BucketName.DEFAULT).block(); testee().deleteBucket(bucketName).block(); + assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(DELETE_BUCKET_TIMER_NAME)) + .hasSize(2); + } + + @Test + @Disabled("JAMES-2829 Not supported yet") + default void deleteShouldPublishDeleteTimerMetrics() { + BlobId blobId1 = testee().save(testee().getDefaultBucketName(), BYTES_CONTENT).block(); + BlobId blobId2 = testee().save(testee().getDefaultBucketName(), BYTES_CONTENT).block(); + + testee().delete(BucketName.DEFAULT, blobId1).block(); + testee().delete(BucketName.DEFAULT, blobId2).block(); + assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(DELETE_TIMER_NAME)) .hasSize(2); } diff --git a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java index 5bf792f..2ba4ccd 100644 --- a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java +++ b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java @@ -72,7 +72,7 @@ public class CassandraBlobsDAOTest implements MetricableBlobStoreContract { @Override @Disabled("JAMES-2806: delete bucket not implemented yet for Cassandra") - public void deleteBucketShouldPublishDeleteTimerMetrics() { + public void deleteBucketShouldPublishDeleteBucketTimerMetrics() { } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
