Gargi-jais11 commented on code in PR #12106:
URL: https://github.com/apache/ozone/pull/12106#discussion_r4735262645


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeysDeleteRequestWithFSO.java:
##########
@@ -113,6 +130,86 @@ public void testDuplicatePathsReleaseQuotaOnce() throws 
Exception {
     checkDuplicateKeysReleaseQuotaOnce(request, 2);
   }
 
+  @Test
+  public void testNonRecursiveKeepsNonEmptyDirectories() throws Exception {
+    addFile("a/b", "file");
+
+    OMResponse response = deleteNonRecursive("a/", "a/b/");
+
+    assertEquals(Status.PARTIAL_DELETE, response.getStatus());
+    DeleteKeysResponse deleteKeysResponse = response.getDeleteKeysResponse();
+    
assertThat(deleteKeysResponse.getUnDeletedKeys().getKeysList()).containsExactlyInAnyOrder("a/",
 "a/b/");
+    assertThat(deleteKeysResponse.getErrorsList())
+        .extracting(DeleteKeyError::getKey, DeleteKeyError::getErrorCode)
+        .containsExactlyInAnyOrder(tuple("a/", DIRECTORY_NOT_EMPTY.name()), 
tuple("a/b/", DIRECTORY_NOT_EMPTY.name()));
+    for (String key : Arrays.asList("a/", "a/b/", "a/b/file")) {
+      assertNotNull(getFileStatus(key), key);
+    }
+  }
+
+  @Test
+  public void testNonRecursiveDeletesDirectoriesEmptiedByTheRequest() throws 
Exception {
+    addFile("a/b", "file");
+
+    // A listing returns each directory before its contents.
+    OMResponse response = deleteNonRecursive("a/", "a/b/", "a/b/file");
+
+    assertEquals(Status.OK, response.getStatus());
+    for (String key : Arrays.asList("a/", "a/b/", "a/b/file")) {
+      assertNull(getFileStatus(key), key);
+    }
+  }
+
+  @Test
+  public void testNonRecursiveIsIgnoredBeforeFinalization() throws Exception {

Review Comment:
   Could you  also assert that `a/b/file` is deleted? That shows the subtree is 
removed recursively before finalization, not just a/. 



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