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 9e11e98629cf8a9dfba66476f832d3ec9b0d516c Author: TungTV <[email protected]> AuthorDate: Tue Dec 3 22:05:14 2024 +0700 [FIX] Add tests for GC algorithm with S3 MinIO GenerationAwareBlobId --- server/blob/blob-s3/pom.xml | 11 ++++ .../aws/S3MinioBlobStoreGCAlgorithmTest.java | 68 ++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/server/blob/blob-s3/pom.xml b/server/blob/blob-s3/pom.xml index bd4aad1445..2b80d79dbc 100644 --- a/server/blob/blob-s3/pom.xml +++ b/server/blob/blob-s3/pom.xml @@ -52,6 +52,12 @@ <artifactId>blob-storage-strategy</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>blob-storage-strategy</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> <dependency> <groupId>${james.groupId}</groupId> <artifactId>james-core</artifactId> @@ -117,6 +123,11 @@ <groupId>jakarta.annotation</groupId> <artifactId>jakarta.annotation-api</artifactId> </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> diff --git a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3MinioBlobStoreGCAlgorithmTest.java b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3MinioBlobStoreGCAlgorithmTest.java new file mode 100644 index 0000000000..7110e72857 --- /dev/null +++ b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3MinioBlobStoreGCAlgorithmTest.java @@ -0,0 +1,68 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.blob.objectstorage.aws; + +import static org.apache.james.blob.objectstorage.aws.S3BlobStoreConfiguration.UPLOAD_RETRY_EXCEPTION_PREDICATE; + +import java.util.Optional; + +import org.apache.james.blob.api.BlobId; +import org.apache.james.blob.api.BlobStoreDAO; +import org.apache.james.blob.api.PlainBlobId; +import org.apache.james.metrics.api.NoopGaugeRegistry; +import org.apache.james.metrics.tests.RecordingMetricFactory; +import org.apache.james.server.blob.deduplication.BloomFilterGCAlgorithmContract; +import org.apache.james.server.blob.deduplication.GenerationAwareBlobId; +import org.apache.james.server.blob.deduplication.MinIOGenerationAwareBlobId; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.RegisterExtension; + +import reactor.util.retry.Retry; + +public class S3MinioBlobStoreGCAlgorithmTest implements BloomFilterGCAlgorithmContract { + + private BlobStoreDAO blobStoreDAO; + + @RegisterExtension + static S3MinioExtension minoExtension = new S3MinioExtension(); + + @BeforeEach + void beforeEach() { + AwsS3AuthConfiguration awsS3AuthConfiguration = minoExtension.minioDocker().getAwsS3AuthConfiguration(); + + S3BlobStoreConfiguration s3Configuration = S3BlobStoreConfiguration.builder() + .authConfiguration(awsS3AuthConfiguration) + .region(DockerAwsS3Container.REGION) + .uploadRetrySpec(Optional.of(Retry.backoff(3, java.time.Duration.ofSeconds(1)) + .filter(UPLOAD_RETRY_EXCEPTION_PREDICATE))) + .build(); + + S3ClientFactory s3ClientFactory = new S3ClientFactory(s3Configuration, new RecordingMetricFactory(), new NoopGaugeRegistry()); + + BlobId.Factory plainBlobIdFactory = new PlainBlobId.Factory(); + MinIOGenerationAwareBlobId.Factory minIOGenerationAwareBlobIdFactory = new MinIOGenerationAwareBlobId.Factory(CLOCK, GenerationAwareBlobId.Configuration.DEFAULT, plainBlobIdFactory); + blobStoreDAO = new S3BlobStoreDAO(s3ClientFactory, s3Configuration, minIOGenerationAwareBlobIdFactory, S3RequestOption.DEFAULT); + } + + @Override + public BlobStoreDAO blobStoreDAO() { + return blobStoreDAO; + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
