Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding MinIO module #7440

Merged
merged 8 commits into from Sep 6, 2023
Merged

Adding MinIO module #7440

merged 8 commits into from Sep 6, 2023

Conversation

frozenwizard
Copy link
Contributor

This adds the MinIO container.

@frozenwizard frozenwizard requested a review from a team as a code owner August 25, 2023 17:18
Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. We will talk about the module tomorrow. I just left some suggestions for general review. No changes should be applied until further notice.

@eddumelendez
Copy link
Member

@frozenwizard Please, proceed making the changes. We discussed this Today and we will be hosting the module. Thanks again!

@eddumelendez eddumelendez added this to the next milestone Aug 31, 2023
@eddumelendez
Copy link
Member

@frozenwizard I forgot to ask but can you some docs, please?

Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add additional test switching another credentials and verify those were set in the container

Comment on lines 20 to 44
MinIOContainer container = new MinIOContainer("minio/minio:latest");
container.start();

MinioClient minioClient = MinioClient
.builder()
.endpoint(container.getS3URL())
.credentials(container.getUserName(), container.getPassword())
.build();

minioClient.makeBucket(MakeBucketArgs.builder().bucket("test-bucket").region("us-west-2").build());

BucketExistsArgs existsArgs = BucketExistsArgs.builder().bucket("test-bucket").build();

assertThat(minioClient.bucketExists(existsArgs)).isTrue();

URL file = this.getClass().getResource("/object_to_upload.txt");
assertThat(file).isNotNull();
ObjectWriteResponse upload = minioClient.uploadObject(
UploadObjectArgs.builder().bucket("test-bucket").object("my-objectname").filename(file.getPath()).build()
);

StatObjectResponse objectStat = minioClient.statObject(
StatObjectArgs.builder().bucket("test-bucket").object("my-objectname").build()
);

assertThat(objectStat.object()).isEqualTo("my-objectname");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace latest with a specific version

Suggested change
MinIOContainer container = new MinIOContainer("minio/minio:latest");
container.start();
MinioClient minioClient = MinioClient
.builder()
.endpoint(container.getS3URL())
.credentials(container.getUserName(), container.getPassword())
.build();
minioClient.makeBucket(MakeBucketArgs.builder().bucket("test-bucket").region("us-west-2").build());
BucketExistsArgs existsArgs = BucketExistsArgs.builder().bucket("test-bucket").build();
assertThat(minioClient.bucketExists(existsArgs)).isTrue();
URL file = this.getClass().getResource("/object_to_upload.txt");
assertThat(file).isNotNull();
ObjectWriteResponse upload = minioClient.uploadObject(
UploadObjectArgs.builder().bucket("test-bucket").object("my-objectname").filename(file.getPath()).build()
);
StatObjectResponse objectStat = minioClient.statObject(
StatObjectArgs.builder().bucket("test-bucket").object("my-objectname").build()
);
assertThat(objectStat.object()).isEqualTo("my-objectname");
try(MinIOContainer container = new MinIOContainer("minio/minio:latest")) {
container.start();
MinioClient minioClient = MinioClient
.builder()
.endpoint(container.getS3URL())
.credentials(container.getUserName(), container.getPassword())
.build();
minioClient.makeBucket(MakeBucketArgs.builder().bucket("test-bucket").region("us-west-2").build());
BucketExistsArgs existsArgs = BucketExistsArgs.builder().bucket("test-bucket").build();
assertThat(minioClient.bucketExists(existsArgs)).isTrue();
URL file = this.getClass().getResource("/object_to_upload.txt");
assertThat(file).isNotNull();
ObjectWriteResponse upload = minioClient.uploadObject(
UploadObjectArgs.builder().bucket("test-bucket").object("my-objectname").filename(file.getPath()).build()
);
StatObjectResponse objectStat = minioClient.statObject(
StatObjectArgs.builder().bucket("test-bucket").object("my-objectname").build()
);
assertThat(objectStat.object()).isEqualTo("my-objectname");
}

* <p>
* Exposed ports: 9000,9001
*/
@Slf4j
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Slf4j

* Constructs a MinIO container from the dockerImageName
* @param dockerImageName the full image name to use
*/
public MinIOContainer(@NonNull final String dockerImageName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public MinIOContainer(@NonNull final String dockerImageName) {
public MinIOContainer(final String dockerImageName) {


URL file = this.getClass().getResource("/object_to_upload.txt");
assertThat(file).isNotNull();
ObjectWriteResponse upload = minioClient.uploadObject(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upload is not being used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general if an upload fails it throws an exception. If we get the upload object back then it was a success. I can make it more clear with a comment or remove the variable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing the variable would be fine

@frozenwizard
Copy link
Contributor Author

@frozenwizard I forgot to ask but can you some docs, please?

Sure where would they go?

@eddumelendez
Copy link
Member

docs can be added here and then update the mkdocs.yml in the root directory

docs/modules/minio.md Outdated Show resolved Hide resolved
docs/modules/minio.md Outdated Show resolved Hide resolved
docs/modules/minio.md Outdated Show resolved Hide resolved
@eddumelendez eddumelendez merged commit ba9e3cc into testcontainers:main Sep 6, 2023
88 checks passed
@eddumelendez
Copy link
Member

Thanks for your contribution, @frozenwizard ! I've made some changes to keep aligned with the image. Module will be release as part of the next release.

@frozenwizard frozenwizard deleted the minio branch September 8, 2023 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants