This is an automated email from the ASF dual-hosted git repository.

siyao pushed a commit to branch HDDS-6517-Snapshot
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/HDDS-6517-Snapshot by this 
push:
     new 40688f637a HDDS-7819. [Snapshot] Add unit-testcases for fs delete of 
bucket havng snapshots (#4198)
40688f637a is described below

commit 40688f637a81f155582887ad2741636f7b2526fa
Author: jyotirmoy-gh <[email protected]>
AuthorDate: Thu Jan 26 10:50:10 2023 +0530

    HDDS-7819. [Snapshot] Add unit-testcases for fs delete of bucket havng 
snapshots (#4198)
---
 .../hadoop/fs/ozone/TestOzoneFsSnapshot.java       | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsSnapshot.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsSnapshot.java
index 95ba876c06..14ebd7fa00 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsSnapshot.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsSnapshot.java
@@ -278,4 +278,46 @@ public class TestOzoneFsSnapshot {
       shell.close();
     }
   }
+
+  @Test
+  public void testDeleteBucketWithSnapshot() throws Exception {
+    String volume = "vol-" + RandomStringUtils.randomNumeric(5);
+    String bucket = "buc-" + RandomStringUtils.randomNumeric(5);
+    String key = "key-" + RandomStringUtils.randomNumeric(5);
+    String snapshotName = "snap-" + RandomStringUtils.randomNumeric(5);
+
+    String testVolBucket = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket;
+    String testKey = testVolBucket + OM_KEY_PREFIX + key;
+
+    createVolBuckKey(testVolBucket, testKey);
+
+    OzoneFsShell shell = new OzoneFsShell(clientConf);
+    try {
+      int res = ToolRunner.run(shell,
+              new String[]{"-createSnapshot", testVolBucket, snapshotName});
+      // Asserts that create request succeeded
+      assertEquals(0, res);
+
+      res = ToolRunner.run(shell,
+              new String[]{"-rm", "-r", "-skipTrash", testKey});
+      assertEquals(0, res);
+
+      res = ToolRunner.run(shell,
+              new String[]{"-rm", "-r", "-skipTrash", testVolBucket});
+      assertEquals(1, res);
+
+      res = ToolRunner.run(shell,
+              new String[]{"-ls", testVolBucket});
+      assertEquals(0, res);
+
+      String snapshotPath = testVolBucket + OM_KEY_PREFIX + ".snapshot"
+              + OM_KEY_PREFIX + snapshotName + OM_KEY_PREFIX;
+      res = ToolRunner.run(shell,
+              new String[]{"-ls", snapshotPath});
+      assertEquals(0, res);
+
+    } finally {
+      shell.close();
+    }
+  }
 }


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

Reply via email to