Samrat002 commented on code in PR #28867:
URL: https://github.com/apache/flink/pull/28867#discussion_r3805788661


##########
flink-filesystems/flink-s3-fs-native/src/test/java/org/apache/flink/fs/s3native/NativeS3FileSystemITCase.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.s3native;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.fs.FSDataInputStream;
+import org.apache.flink.core.fs.FSDataOutputStream;
+import org.apache.flink.core.fs.FileStatus;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.core.fs.RecoverableFsDataOutputStream;
+import org.apache.flink.core.fs.RecoverableWriter;
+import org.apache.flink.core.testutils.AllCallbackWrapper;
+import org.apache.flink.core.testutils.TestContainerExtension;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+/** Exercises native S3 filesystem operations directly. */
+class NativeS3FileSystemITCase {
+
+    @RegisterExtension
+    private static final 
AllCallbackWrapper<TestContainerExtension<SeaweedFsNativeS3TestContainer>>
+            SEAWEEDFS_EXTENSION =
+                    new AllCallbackWrapper<>(
+                            new 
TestContainerExtension<>(SeaweedFsNativeS3TestContainer::new));
+
+    private static FileSystem fs;
+    private static String bucketUri;
+
+    private static SeaweedFsNativeS3TestContainer container() {
+        return SEAWEEDFS_EXTENSION.getCustomExtension().getTestContainer();
+    }
+
+    @BeforeAll
+    static void setUp() throws Exception {
+        final Configuration config = new Configuration();
+        container().setS3ConfigOptions(config);
+
+        final NativeS3FileSystemFactory factory = new 
NativeS3FileSystemFactory();
+        factory.configure(config);
+
+        bucketUri = container().getS3UriForDefaultBucket();
+        fs = factory.create(URI.create(bucketUri + "/"));
+    }
+
+    @Test
+    void testWriteReadAndStat() throws Exception {
+        final Path file = path("dir/" + UUID.randomUUID() + ".txt");
+        final byte[] data = "hello seaweedfs".getBytes(StandardCharsets.UTF_8);
+        write(file, data);
+
+        assertThat(fs.exists(file)).isTrue();
+        assertThat(fs.getFileStatus(file).getLen()).isEqualTo(data.length);
+        assertThat(read(file, data.length)).isEqualTo(data);
+    }
+
+    @Test
+    void testListRenameDelete() throws Exception {
+        final String dir = "listdir-" + UUID.randomUUID();
+        final Path a = path(dir + "/a.txt");
+        final Path b = path(dir + "/b.txt");
+        write(a, "a".getBytes(StandardCharsets.UTF_8));
+        write(b, "b".getBytes(StandardCharsets.UTF_8));
+
+        final FileStatus[] listed = fs.listStatus(path(dir));
+        assertThat(listed)
+                .extracting(status -> status.getPath().getName())
+                .containsExactlyInAnyOrder("a.txt", "b.txt");
+
+        final Path renamed = path(dir + "/c.txt");
+        assertThat(fs.rename(a, renamed)).isTrue();
+        assertThat(fs.exists(a)).isFalse();
+        assertThat(fs.exists(renamed)).isTrue();
+
+        assertThat(fs.delete(path(dir), true)).isTrue();
+        assertThat(fs.exists(renamed)).isFalse();
+    }
+
+    @Test
+    void testMkdirsDoesNotThrow() {

Review Comment:
   addressed to it . PTAL



-- 
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