navinko commented on code in PR #3711:
URL: https://github.com/apache/ozone/pull/3711#discussion_r965077845


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java:
##########
@@ -387,6 +388,184 @@ public void testListStatus() throws Exception {
     fs.delete(parent, true);
   }
 
+  @Test
+  public void testListStatusIteratorWithDir() throws Exception {
+    Path parent = new Path(bucketPath, "testListStatus");
+    Path file1 = new Path(parent, "key1");
+    Path file2 = new Path(parent, "key2");
+
+    // Iterator should have no items when dir is empty
+    RemoteIterator<FileStatus> it = ofs.listStatusIterator(bucketPath);
+    while (it.hasNext()) {
+      Assert.assertFalse(it.hasNext());
+    }
+    ContractTestUtils.touch(fs, file1);
+    ContractTestUtils.touch(fs, file2);
+    // Iterator should have an item when dir is not empty
+    it = ofs.listStatusIterator(bucketPath);
+    while (it.hasNext()) {
+      FileStatus fileStatus = it.next();
+      Assert.assertNotNull(fileStatus);
+      Assert.assertEquals("Parent path doesn't match",
+              fileStatus.getPath().toUri().getPath(), parent.toString());
+    }
+    // Iterator on a directory should return all subdirs along with
+    // files, even if there exists a file and sub-dir with the same name.
+    it = ofs.listStatusIterator(parent);
+    int iCount = 0;
+    while (it.hasNext()) {
+      iCount++;
+      FileStatus fileStatus = it.next();
+      Assert.assertNotNull(fileStatus);
+    }
+    Assert.assertEquals(
+            "Iterator did not return all the file status",
+            2, iCount);
+    // Iterator should return file status for only the
+    // immediate children of a directory.
+    Path file3 = new Path(parent, "dir1/key3");
+    Path file4 = new Path(parent, "dir1/key4");
+    ContractTestUtils.touch(fs, file3);
+    ContractTestUtils.touch(fs, file4);
+    it = ofs.listStatusIterator(parent);
+    iCount = 0;
+    while (it.hasNext()) {
+      iCount++;
+      FileStatus fileStatus = it.next();
+      Assert.assertNotNull(fileStatus);
+    }
+    Assert.assertEquals("Iterator did not return file status " +
+            "of all the children of the directory", 3, iCount);
+
+    // Cleanup
+    fs.delete(parent, true);

Review Comment:
   corrected



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to