XComp commented on a change in pull request #18692:
URL: https://github.com/apache/flink/pull/18692#discussion_r804175066



##########
File path: 
flink-filesystems/flink-s3-fs-presto/src/test/java/org/apache/flink/fs/s3presto/MinioTestContainerTest.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.flink.fs.s3presto;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.testutils.EachCallbackWrapper;
+import org.apache.flink.core.testutils.TestContainerExtension;
+
+import com.amazonaws.services.s3.AmazonS3;
+import com.amazonaws.services.s3.model.Bucket;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * {@code MinioTestContainerTest} tests some basic functionality provided by 
{@link
+ * MinioTestContainer}.
+ */
+public class MinioTestContainerTest {
+
+    private static final String DEFAULT_BUCKET_NAME = "test-bucket";
+
+    @RegisterExtension
+    private static final 
EachCallbackWrapper<TestContainerExtension<MinioTestContainer>>
+            MINIO_EXTENSION =
+                    new EachCallbackWrapper<>(
+                            new TestContainerExtension<>(
+                                    () -> new 
MinioTestContainer(DEFAULT_BUCKET_NAME)));
+
+    private static MinioTestContainer getTestContainer() {
+        return MINIO_EXTENSION.getCustomExtension().getTestContainer();
+    }
+
+    private static AmazonS3 getClient() {
+        return getTestContainer().getClient();
+    }
+
+    @Test
+    public void testBucketCreation() {
+        final String otherBucketName = "other-bucket";
+        final Bucket otherBucket = getClient().createBucket(otherBucketName);
+
+        assertThat(otherBucket).isNotNull();
+        
assertThat(otherBucket).extracting(Bucket::getName).isEqualTo(otherBucketName);
+
+        assertThat(getClient().listBuckets())
+                .map(Bucket::getName)
+                .containsExactlyInAnyOrder(
+                        getTestContainer().getDefaultBucketName(), 
otherBucketName);
+    }
+
+    @Test
+    public void testPutObject() throws IOException {
+        final String bucketName = "other-bucket";
+
+        getClient().createBucket(bucketName);
+        final String objectId = "test-object";
+        final String content = "test content";
+        getClient().putObject(bucketName, objectId, content);
+
+        final BufferedReader reader =
+                new BufferedReader(
+                        new InputStreamReader(
+                                getClient().getObject(bucketName, 
objectId).getObjectContent()));
+        assertThat(reader.readLine()).isEqualTo(content);
+    }
+
+    @Test
+    public void testFlinkConfigurationInitialization() {
+        final Configuration config = new Configuration();
+        getTestContainer().updateConfigAccordingly(config);
+
+        assertThat(config.containsKey("s3.endpoint")).isTrue();
+        assertThat(config.containsKey("s3.path.style.access")).isTrue();
+        assertThat(config.containsKey("s3.access.key")).isTrue();
+        assertThat(config.containsKey("s3.secret.key")).isTrue();
+    }
+
+    @Test
+    public void testDefaultBucketCreation() {
+        final Configuration config = new Configuration();
+        getTestContainer().updateConfigAccordingly(config);

Review comment:
       not required. correct




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to