Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
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;
Expand Down Expand Up @@ -1786,6 +1787,56 @@ public void testDeleteSnapshotMissingMandatoryParams() throws Exception {
() -> 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 {
Expand Down