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

sshenoy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 82d3155cb0 HDDS-9269. [Snapshot] Add unit test case for Snapshot Quota 
handling. (#5284)
82d3155cb0 is described below

commit 82d3155cb08efca6577f13712b66e8b0d335507f
Author: jyotirmoy-gh <[email protected]>
AuthorDate: Fri Sep 15 09:52:47 2023 +0530

    HDDS-9269. [Snapshot] Add unit test case for Snapshot Quota handling. 
(#5284)
---
 .../org/apache/hadoop/ozone/om/TestOmSnapshot.java | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshot.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshot.java
index 566a75ec7c..7f85674aa7 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshot.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshot.java
@@ -32,6 +32,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hdds.utils.IOUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.hadoop.hdds.client.StandaloneReplicationConfig;
+import org.apache.hadoop.hdds.client.OzoneQuota;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
 import org.apache.hadoop.hdds.scm.HddsWhiteboxTestUtils;
@@ -1829,6 +1830,56 @@ public class TestOmSnapshot {
             () -> store.deleteSnapshot(nullstr, bucket, snap1));
   }
 
+  @Test
+  public void testSnapshotQuotaHandling() throws Exception {
+    String volume = "vol-" + counter.incrementAndGet();
+    String bucket = "buck-" + counter.incrementAndGet();
+    store.createVolume(volume);
+    OzoneVolume volume1 = store.getVolume(volume);
+    volume1.createBucket(bucket);
+    OzoneBucket bucket1 = volume1.getBucket(bucket);
+    bucket1.setQuota(OzoneQuota.parseQuota("102400000", "500"));
+    volume1.setQuota(OzoneQuota.parseQuota("204800000", "1000"));
+
+    long volUsedNamespaceInitial = volume1.getUsedNamespace();
+    long buckUsedNamspaceInitial = bucket1.getUsedNamespace();
+    long buckUsedBytesIntial = bucket1.getUsedBytes();
+
+    String key1 = "key-1-";
+    key1 = createFileKeyWithPrefix(bucket1, key1);
+
+    long volUsedNamespaceBefore = volume1.getUsedNamespace();
+    long buckUsedNamspaceBefore = bucket1.getUsedNamespace();
+    long buckUsedBytesBefore = bucket1.getUsedBytes();
+
+    String snap1 = "snap" + counter.incrementAndGet();
+    createSnapshot(volume, bucket, snap1);
+
+    long volUsedNamespaceAfter = volume1.getUsedNamespace();
+    long buckUsedNamespaceAfter = bucket1.getUsedNamespace();
+    long buckUsedBytesAfter = bucket1.getUsedBytes();
+
+    assertEquals(volUsedNamespaceBefore, volUsedNamespaceAfter);
+    assertEquals(buckUsedNamspaceBefore, buckUsedNamespaceAfter);
+    assertEquals(buckUsedBytesBefore, buckUsedBytesAfter);
+
+    store.deleteSnapshot(volume, bucket, snap1);
+
+    long volUsedNamespaceFinal = volume1.getUsedNamespace();
+    long buckUsedNamespaceFinal = bucket1.getUsedNamespace();
+    long buckUsedBytesFinal = bucket1.getUsedBytes();
+
+    assertEquals(volUsedNamespaceBefore, volUsedNamespaceFinal);
+    assertEquals(buckUsedNamspaceBefore, buckUsedNamespaceFinal);
+    assertEquals(buckUsedBytesBefore, buckUsedBytesFinal);
+
+    bucket1.deleteKey(key1);
+
+    assertEquals(volUsedNamespaceInitial, volume1.getUsedNamespace());
+    assertEquals(buckUsedNamspaceInitial, bucket1.getUsedNamespace());
+    assertEquals(buckUsedBytesIntial, bucket1.getUsedBytes());
+  }
+
   @NotNull
   private static List<LiveFileMetaData> getKeyTableSstFiles()
       throws IOException {


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

Reply via email to