You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/07/07 19:46:11 UTC

[GitHub] [hadoop-ozone] xiaoyuyao commented on a change in pull request #1089: HDDS-3705. [OFS] Implement getTrashRoots for trash cleanup

xiaoyuyao commented on a change in pull request #1089:
URL: https://github.com/apache/hadoop-ozone/pull/1089#discussion_r451102321



##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java
##########
@@ -871,4 +876,103 @@ public void testFailToDeleteRoot() throws IOException {
     Assert.assertFalse(fs.delete(new Path("/"), true));
   }
 
+  /**
+   * Test getTrashRoots() in OFS. Different from the existing test for o3fs.
+   */
+  @Test
+  public void testGetTrashRoots() throws IOException {
+    String username = UserGroupInformation.getCurrentUser().getShortUserName();
+    OzoneVolume volume1 = objectStore.getVolume(volumeName);
+    String prevOwner = volume1.getOwner();
+    // Set owner of the volume to current user, so it will show up in vol list
+    Assert.assertTrue(volume1.setOwner(username));
+
+    Path trashRoot1 = new Path(bucketPath, TRASH_PREFIX);
+    Path user1Trash1 = new Path(trashRoot1, username);
+    // When user trash dir isn't been created
+    Assert.assertEquals(0, fs.getTrashRoots(false).size());
+    Assert.assertEquals(0, fs.getTrashRoots(true).size());
+    // Let's create our first user1 (current user) trash dir.
+    fs.mkdirs(user1Trash1);
+    // Results should be getTrashRoots(false)=1, gTR(true)=1
+    Collection<FileStatus> res = fs.getTrashRoots(false);
+    Assert.assertEquals(1, res.size());
+    res.forEach(e -> Assert.assertEquals(

Review comment:
       NIT: forEach is unnecessary as we have assert the size is 1.




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

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



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