Adding MinIO module#7440
Conversation
eddumelendez
left a comment
There was a problem hiding this comment.
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.
|
@frozenwizard Please, proceed making the changes. We discussed this Today and we will be hosting the module. Thanks again! |
|
@frozenwizard I forgot to ask but can you some docs, please? |
eddumelendez
left a comment
There was a problem hiding this comment.
Add additional test switching another credentials and verify those were set in the container
| 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"); |
There was a problem hiding this comment.
replace latest with a specific version
| 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 |
| * Constructs a MinIO container from the dockerImageName | ||
| * @param dockerImageName the full image name to use | ||
| */ | ||
| public MinIOContainer(@NonNull final String dockerImageName) { |
There was a problem hiding this comment.
| 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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
removing the variable would be fine
Sure where would they go? |
|
docs can be added here and then update the mkdocs.yml in the root directory |
|
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. |
This adds the MinIO container.