This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch blobstore-test-s3 in repository https://gitbox.apache.org/repos/asf/james-project.git
commit e51b64f8226a53fbd68d8a936f81b9bc8ddf2827 Author: Rene Cordier <[email protected]> AuthorDate: Thu Apr 15 11:48:34 2021 +0700 Test branch against S3 --- .../james/blob/api/BlobStoreDAOContract.java | 2 +- .../apache/james/blob/api/BlobStoreDAOFixture.java | 2 +- .../blob/api/ReadSaveBlobStoreDAOContract.java | 37 ++++++++++++++++++++-- .../blob/objectstorage/aws/S3BlobStoreDAOTest.java | 6 ++-- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreDAOContract.java b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreDAOContract.java index 1276f78..f4e5dec 100644 --- a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreDAOContract.java +++ b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreDAOContract.java @@ -18,5 +18,5 @@ ****************************************************************/ package org.apache.james.blob.api; -public interface BlobStoreDAOContract extends ReadSaveBlobStoreDAOContract, DeleteBlobStoreDAOContract, BucketBlobStoreDAOContract { +public interface BlobStoreDAOContract extends ReadSaveBlobStoreDAOContract, DeleteBlobStoreDAOContract { } diff --git a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreDAOFixture.java b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreDAOFixture.java index ca03d46..fa2e1e6 100644 --- a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreDAOFixture.java +++ b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreDAOFixture.java @@ -23,7 +23,7 @@ import java.nio.charset.StandardCharsets; import com.google.common.base.Strings; public interface BlobStoreDAOFixture { - BucketName TEST_BUCKET_NAME = BucketName.of("my-test-bucket"); + BucketName TEST_BUCKET_NAME = BucketName.of("james-upn"); BucketName CUSTOM_BUCKET_NAME = BucketName.of("custom"); BlobId TEST_BLOB_ID = new TestBlobId("test-blob-id"); BlobId OTHER_TEST_BLOB_ID = new TestBlobId("other-test-blob-id"); diff --git a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/ReadSaveBlobStoreDAOContract.java b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/ReadSaveBlobStoreDAOContract.java index 2c6570a..79baaba 100644 --- a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/ReadSaveBlobStoreDAOContract.java +++ b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/ReadSaveBlobStoreDAOContract.java @@ -36,6 +36,7 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Arrays; +import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.stream.Stream; @@ -336,7 +337,7 @@ public interface ReadSaveBlobStoreDAOContract { ) .threadCount(10) .operationCount(20) - .runSuccessfullyWithin(Duration.ofMinutes(2)); + .runSuccessfullyWithin(Duration.ofMinutes(10)); } @ParameterizedTest(name = "[{index}] {0}") @@ -348,11 +349,41 @@ public interface ReadSaveBlobStoreDAOContract { (threadNumber, step) -> testee().save(TEST_BUCKET_NAME, TEST_BLOB_ID, ByteSource.wrap(bytes)), (threadNumber, step) -> checkConcurrentSaveOperation(bytes) ) - .threadCount(10) - .operationCount(20) + .threadCount(2) + .operationCount(2) .runSuccessfullyWithin(Duration.ofMinutes(2)); } + @ParameterizedTest(name = "[{index}] {0}") + @MethodSource("blobs") + default void testIsolation(String description, byte[] bytes) throws ExecutionException, InterruptedException { + Mono.from(testee().save(TEST_BUCKET_NAME, TEST_BLOB_ID, bytes)).block(); + ConcurrentTestRunner.builder() + .operation((threadNumber, step) -> { + if (threadNumber == 1) { + testee().save(TEST_BUCKET_NAME, TEST_BLOB_ID, ByteSource.wrap(bytes)); + } else { + checkConcurrentSaveOperation(bytes); + } + }) + .threadCount(2) + .operationCount(4) + .runSuccessfullyWithin(Duration.ofMinutes(10)); + } + + @ParameterizedTest(name = "[{index}] {0}") + @MethodSource("blobs") + default void parrallel(String description, byte[] bytes) throws ExecutionException, InterruptedException { + Mono.from(testee().save(TEST_BUCKET_NAME, TEST_BLOB_ID, bytes)).block(); + ConcurrentTestRunner.builder() + .operation( + (threadNumber, step) -> testee().save(TEST_BUCKET_NAME, new TestBlobId(UUID.randomUUID().toString()), ByteSource.wrap(bytes)) + ) + .threadCount(10) + .operationCount(2) + .runSuccessfullyWithin(Duration.ofMinutes(10)); + } + default Mono<Void> checkConcurrentSaveOperation(byte[] expected) { return Mono.from(testee().readBytes(TEST_BUCKET_NAME, TEST_BLOB_ID)) //assertj is very cpu-intensive, let's compute the assertion only when arrays are different diff --git a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3BlobStoreDAOTest.java b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3BlobStoreDAOTest.java index e426926..4ad3041 100644 --- a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3BlobStoreDAOTest.java +++ b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3BlobStoreDAOTest.java @@ -18,14 +18,14 @@ ****************************************************************/ package org.apache.james.blob.objectstorage.aws; +import java.net.URI; + import org.apache.james.blob.api.BlobStoreDAO; import org.apache.james.blob.api.BlobStoreDAOContract; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(DockerAwsS3Extension.class) public class S3BlobStoreDAOTest implements BlobStoreDAOContract { private static S3BlobStoreDAO testee; @@ -47,7 +47,7 @@ public class S3BlobStoreDAOTest implements BlobStoreDAOContract { @AfterEach void tearDown() { - testee.deleteAllBuckets().block(); + // testee.deleteAllBuckets().block(); } @AfterAll --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
