This is an automated email from the ASF dual-hosted git repository. aduprat pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6ec43fb87bd37317da03574c3a5939aa50263563 Author: Rene Cordier <rcord...@linagora.com> AuthorDate: Tue Jul 2 10:35:48 2019 +0700 JAMES-2806 add a metric for deleteBucket method and test in its contract --- .../org/apache/james/blob/api/MetricableBlobStore.java | 4 +++- .../apache/james/blob/api/MetricableBlobStoreContract.java | 14 ++++++++++++++ .../apache/james/blob/cassandra/CassandraBlobsDAOTest.java | 7 +++++++ .../blob/objectstorage/ObjectStorageBlobsDAOTest.java | 7 +++++++ 4 files changed, 31 insertions(+), 1 deletion(-) 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 89548d8..11fd997 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 @@ -36,6 +36,7 @@ public class MetricableBlobStore implements BlobStore { static final String SAVE_INPUT_STREAM_TIMER_NAME = BLOB_STORE_METRIC_PREFIX + "saveInputStream"; 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"; private final MetricFactory metricFactory; private final BlobStore blobStoreImpl; @@ -73,6 +74,7 @@ public class MetricableBlobStore implements BlobStore { @Override public Mono<Void> deleteBucket(BucketName bucketName) { - return blobStoreImpl.deleteBucket(bucketName); + return metricFactory + .runPublishingTimerMetric(DELETE_TIMER_NAME, () -> blobStoreImpl.deleteBucket(bucketName)); } } 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 74a30ff..983c516 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_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; import static org.apache.james.blob.api.MetricableBlobStore.SAVE_BYTES_TIMER_NAME; @@ -101,4 +102,17 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(READ_TIMER_NAME)) .hasSize(2); } + + @Test + default void deleteBucketShouldPublishDeleteTimerMetrics() { + BucketName bucketName = BucketName.of("custom"); + testee().save(BucketName.DEFAULT, BYTES_CONTENT).block(); + testee().save(bucketName, BYTES_CONTENT).block(); + + testee().deleteBucket(BucketName.DEFAULT); + testee().deleteBucket(bucketName); + + assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(DELETE_TIMER_NAME)) + .hasSize(2); + } } \ No newline at end of file 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 758ad7e..23e3375 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 @@ -35,6 +35,7 @@ import org.apache.james.blob.api.MetricableBlobStore; import org.apache.james.blob.api.MetricableBlobStoreContract; import org.apache.james.util.ZeroedInputStream; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -70,6 +71,12 @@ public class CassandraBlobsDAOTest implements MetricableBlobStoreContract { return new HashBlobId.Factory(); } + @Override + @Disabled("JAMES-2806: delete bucket not implemented yet for Cassandra") + public void deleteBucketShouldPublishDeleteTimerMetrics() { + + } + @Test void readBytesShouldReturnSplitSavedDataByChunk() { String longString = Strings.repeat("0123456789\n", MULTIPLE_CHUNK_SIZE); diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java index e0214ee..1164af5 100644 --- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java +++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java @@ -45,6 +45,7 @@ import org.apache.james.blob.objectstorage.swift.UserHeaderName; import org.apache.james.blob.objectstorage.swift.UserName; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -110,6 +111,12 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract { return new HashBlobId.Factory(); } + @Override + @Disabled("JAMES-2806: delete bucket not implemented yet for ObjectStorage") + public void deleteBucketShouldPublishDeleteTimerMetrics() { + + } + @Test void createContainerShouldMakeTheContainerToExist() { ContainerName containerName = ContainerName.of(UUID.randomUUID().toString()); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org