adoroszlai commented on code in PR #8401:
URL: https://github.com/apache/ozone/pull/8401#discussion_r2077131267


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTestWithFSO.java:
##########
@@ -226,4 +231,31 @@ void testLeaseRecoverable() throws Exception {
     }
   }
 
+  @Test
+  void testIsFileFalseForDir() throws IOException {
+    Path dirPath = new Path(getBucketPath(), "dir1");
+    Path keyPath = new Path(dirPath, "key1");
+    OFSPath ofsPath = new OFSPath(dirPath, new OzoneConfiguration());
+
+    getFs().mkdirs(dirPath);
+    try (FSDataOutputStream out1 = getFs().create(keyPath)) {
+      out1.write(2);
+    }
+
+    RootedOzoneFileSystem ofs = (RootedOzoneFileSystem) getFs();
+    BasicRootedOzoneClientAdapterImpl adapter = 
(BasicRootedOzoneClientAdapterImpl) ofs.getAdapter();
+    OzoneBucket bucket = adapter.getBucket(ofsPath, false);
+
+    Iterator<? extends OzoneKey> key = bucket.listKeys("");

Review Comment:
   nit: rename to `keyIterator` or similar



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTestWithFSO.java:
##########
@@ -226,4 +231,31 @@ void testLeaseRecoverable() throws Exception {
     }
   }
 
+  @Test
+  void testIsFileFalseForDir() throws IOException {
+    Path dirPath = new Path(getBucketPath(), "dir1");
+    Path keyPath = new Path(dirPath, "key1");
+    OFSPath ofsPath = new OFSPath(dirPath, new OzoneConfiguration());

Review Comment:
   Can use existing `conf` member after moving to parent class.
   
   ```suggestion
       OFSPath ofsPath = new OFSPath(dirPath, conf);
   ```



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTestWithFSO.java:
##########
@@ -226,4 +231,31 @@ void testLeaseRecoverable() throws Exception {
     }
   }
 
+  @Test
+  void testIsFileFalseForDir() throws IOException {
+    Path dirPath = new Path(getBucketPath(), "dir1");
+    Path keyPath = new Path(dirPath, "key1");
+    OFSPath ofsPath = new OFSPath(dirPath, new OzoneConfiguration());
+
+    getFs().mkdirs(dirPath);
+    try (FSDataOutputStream out1 = getFs().create(keyPath)) {
+      out1.write(2);
+    }
+
+    RootedOzoneFileSystem ofs = (RootedOzoneFileSystem) getFs();
+    BasicRootedOzoneClientAdapterImpl adapter = 
(BasicRootedOzoneClientAdapterImpl) ofs.getAdapter();

Review Comment:
   Please move this test case to the parent class 
`AbstractRootedOzoneFileSystemTest`.  Then these local variables `ofs` and 
`adapter` are unnecessary.



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTestWithFSO.java:
##########
@@ -226,4 +231,31 @@ void testLeaseRecoverable() throws Exception {
     }
   }
 
+  @Test
+  void testIsFileFalseForDir() throws IOException {
+    Path dirPath = new Path(getBucketPath(), "dir1");
+    Path keyPath = new Path(dirPath, "key1");
+    OFSPath ofsPath = new OFSPath(dirPath, new OzoneConfiguration());
+
+    getFs().mkdirs(dirPath);
+    try (FSDataOutputStream out1 = getFs().create(keyPath)) {
+      out1.write(2);
+    }
+
+    RootedOzoneFileSystem ofs = (RootedOzoneFileSystem) getFs();
+    BasicRootedOzoneClientAdapterImpl adapter = 
(BasicRootedOzoneClientAdapterImpl) ofs.getAdapter();
+    OzoneBucket bucket = adapter.getBucket(ofsPath, false);
+
+    Iterator<? extends OzoneKey> key = bucket.listKeys("");
+
+    assertTrue(key.hasNext(), "Expected dir1, key1 in the bucket");
+    OzoneKey ozoneKey = key.next();
+    assertEquals("dir1/", ozoneKey.getName());
+    assertFalse(ozoneKey.isFile(), "Expected isFile to be false for directory 
key");
+    ozoneKey = key.next();
+    assertEquals("dir1/key1", ozoneKey.getName());
+    assertTrue(ozoneKey.isFile(), "Expected isFile to be true for key");
+
+    getFs().delete(dirPath, true);

Review Comment:
   Cleanup is done in `@AfterEach`, I don't think it's needed here.



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to