From dcf764696ea2e3857d947897e6581869372e4894 Mon Sep 17 00:00:00 2001 From: Raju Balpande Date: Mon, 5 Feb 2024 20:11:10 +0530 Subject: [PATCH 1/6] HDDS-10218 reducing the initiation, we are using different volume for each Test. --- .../hadoop/ozone/om/TestSstFilteringService.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java index a8b026af05b5..7f81e5468eca 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java @@ -36,10 +36,10 @@ import org.apache.hadoop.ozone.om.request.OMRequestTestUtils; import org.apache.hadoop.ozone.om.snapshot.ReferenceCounted; import org.apache.hadoop.ozone.om.snapshot.SnapshotCache; +import org.apache.hadoop.security.authentication.client.AuthenticationException; import org.apache.ratis.util.ExitUtils; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.rocksdb.LiveFileMetaData; @@ -81,12 +81,8 @@ public class TestSstFilteringService { private KeyManager keyManager; @BeforeAll - public static void setup() { + void setup() throws AuthenticationException, IOException, InterruptedException, TimeoutException { ExitUtils.disableSystemExit(); - } - - @BeforeEach - void init() throws Exception { conf = new OzoneConfiguration(); conf.set(OZONE_METADATA_DIRS, folder.getAbsolutePath()); conf.setTimeDuration(HDDS_CONTAINER_REPORT_INTERVAL, 200, @@ -102,7 +98,7 @@ void init() throws Exception { om = omTestManagers.getOzoneManager(); } - @AfterEach + @AfterAll public void cleanup() throws Exception { if (keyManager != null) { keyManager.stop(); From e03efb1b1eb97fa0262c85afcbf1ca6fac9faf53 Mon Sep 17 00:00:00 2001 From: Raju Balpande Date: Tue, 6 Feb 2024 15:48:15 +0530 Subject: [PATCH 2/6] HDDS-10218 reducing the initiation, we are using different volume for each Test. --- .../apache/hadoop/ozone/om/TestSstFilteringService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java index 7f81e5468eca..f1ac1bf6a871 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java @@ -41,6 +41,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.io.TempDir; import org.rocksdb.LiveFileMetaData; @@ -71,17 +72,16 @@ /** * Test SST Filtering Service. */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class TestSstFilteringService { - public static final String SST_FILE_EXTENSION = ".sst"; - @TempDir - private File folder; + public static final String SST_FILE_EXTENSION = ".sst";; private OzoneManagerProtocol writeClient; private OzoneManager om; private OzoneConfiguration conf; private KeyManager keyManager; @BeforeAll - void setup() throws AuthenticationException, IOException, InterruptedException, TimeoutException { + void setup(@TempDir File folder) throws AuthenticationException, IOException, InterruptedException, TimeoutException { ExitUtils.disableSystemExit(); conf = new OzoneConfiguration(); conf.set(OZONE_METADATA_DIRS, folder.getAbsolutePath()); From d7e918a3421224396e770fa1a16debf01ffa9252 Mon Sep 17 00:00:00 2001 From: Raju Balpande Date: Tue, 6 Feb 2024 21:43:48 +0530 Subject: [PATCH 3/6] HDDS-10218 reducing the initiation, we are using different volume for each Test. --- .../ozone/om/TestSstFilteringService.java | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java index f1ac1bf6a871..a307accea769 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java @@ -38,10 +38,13 @@ import org.apache.hadoop.ozone.om.snapshot.SnapshotCache; import org.apache.hadoop.security.authentication.client.AuthenticationException; import org.apache.ratis.util.ExitUtils; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.rocksdb.LiveFileMetaData; @@ -73,6 +76,7 @@ * Test SST Filtering Service. */ @TestInstance(TestInstance.Lifecycle.PER_CLASS) +@TestMethodOrder(OrderAnnotation.class) public class TestSstFilteringService { public static final String SST_FILE_EXTENSION = ".sst";; private OzoneManagerProtocol writeClient; @@ -129,6 +133,7 @@ public void cleanup() throws Exception { * @throws IOException - on Failure. */ @Test + @Order(1) public void testIrrelevantSstFileDeletion() throws Exception { RDBStore activeDbStore = (RDBStore) om.getMetadataManager().getStore(); @@ -176,7 +181,7 @@ public void testIrrelevantSstFileDeletion() assertThat(nonLevel0FilesCountAfterCompact).isGreaterThan(0); String bucketName2 = "buck2"; - createVolumeAndBucket(volumeName, bucketName2); + addBucketToVolume(volumeName, bucketName2); createKeys(volumeName, bucketName2, keyCount); activeDbStore.getDb().flush(OmMetadataManagerImpl.KEY_TABLE); @@ -233,17 +238,22 @@ public void testIrrelevantSstFileDeletion() Set keysFromSnapshot2 = getKeysFromSnapshot(volumeName, bucketName2, snapshotName2); assertEquals(keysFromActiveDb2, keysFromSnapshot2); + writeClient.deleteSnapshot(volumeName, bucketName2, snapshotName1); + writeClient.deleteSnapshot(volumeName, bucketName2, snapshotName2); + await(10_000, 1_000, () -> filteringService.getSnapshotFilteredCount().get() == 0); } @Test + @Order(2) public void testActiveAndDeletedSnapshotCleanup() throws Exception { RDBStore activeDbStore = (RDBStore) om.getMetadataManager().getStore(); String volumeName = "volume1"; List bucketNames = Arrays.asList("bucket1", "bucket2"); + createVolume(volumeName); // Create 2 Buckets for (String bucketName : bucketNames) { - createVolumeAndBucket(volumeName, bucketName); + addBucketToVolume(volumeName, bucketName); } // Write 25 keys in each bucket, 2 sst files would be generated each for // keys in a single bucket @@ -300,6 +310,9 @@ public void testActiveAndDeletedSnapshotCleanup() throws Exception { assertEquals(snap1SstFileCountBeforeFilter, snap1SstFileCountAfterFilter); assertEquals(snap2SstFileCountBeforeFilter - 1, snap2SstFileCountAfterFilter); + //clear data + writeClient.deleteSnapshot(volumeName, bucketNames.get(0), "snap2"); + await(10_000, 1_000, () -> sstFilteringService.getSnapshotFilteredCount().get() == 0); } private void createKeys(String volumeName, @@ -329,6 +342,25 @@ private void createVolumeAndBucket(String volumeName, .build()); } + private void createVolume(String volumeName) + throws IOException { + OMRequestTestUtils.addVolumeToOM(keyManager.getMetadataManager(), + OmVolumeArgs.newBuilder() + .setOwnerName("o") + .setAdminName("a") + .setVolume(volumeName) + .build()); + } + + private void addBucketToVolume(String volumeName, String bucketName) + throws IOException { + OMRequestTestUtils.addBucketToOM(keyManager.getMetadataManager(), + OmBucketInfo.newBuilder().setVolumeName(volumeName) + .setBucketName(bucketName) + .setIsVersionEnabled(false) + .build()); + } + private void createKey(OzoneManagerProtocol managerProtocol, String volumeName, String bucketName, @@ -362,6 +394,7 @@ private void createKey(OzoneManagerProtocol managerProtocol, * snapshot bucket. */ @Test + @Order(3) public void testSstFilteringService() throws Exception { RDBStore activeDbStore = (RDBStore) om.getMetadataManager().getStore(); String volumeName = "volume"; @@ -425,6 +458,12 @@ public void testSstFilteringService() throws Exception { assertEquals(keyInBucket, keyInBucketAfterFilteringRun); assertEquals(keyInBucket1, keyInBucket1AfterFilteringRun); assertEquals(keyInBucket2, keyInBucket2AfterFilteringRun); + //clear data + for (int i = 0; i < 3; i++) { + writeClient.deleteSnapshot(volumeName, bucketNames.get(i), + snapshotNames.get(i)); + } + await(10_000, 1_000, () -> sstFilteringService.getSnapshotFilteredCount().get() == 0); } private static void waitForSnapshotsAtLeast(SstFilteringService filteringService, long n) From e0a76d9d912a644ba1f233a1d9bf85bd3570769b Mon Sep 17 00:00:00 2001 From: Raju Balpande Date: Thu, 8 Feb 2024 17:26:49 +0530 Subject: [PATCH 4/6] HDDS-10218 reducing the initiation, we are using different volume for each Test. --- .../ozone/om/TestSstFilteringService.java | 72 +++++++------------ 1 file changed, 26 insertions(+), 46 deletions(-) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java index a307accea769..6836936d9f51 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java @@ -36,20 +36,20 @@ import org.apache.hadoop.ozone.om.request.OMRequestTestUtils; import org.apache.hadoop.ozone.om.snapshot.ReferenceCounted; import org.apache.hadoop.ozone.om.snapshot.SnapshotCache; -import org.apache.hadoop.security.authentication.client.AuthenticationException; import org.apache.ratis.util.ExitUtils; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.io.TempDir; import org.rocksdb.LiveFileMetaData; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -83,12 +83,13 @@ public class TestSstFilteringService { private OzoneManager om; private OzoneConfiguration conf; private KeyManager keyManager; + private short countTotalSnapshots = 0; @BeforeAll - void setup(@TempDir File folder) throws AuthenticationException, IOException, InterruptedException, TimeoutException { + void setup(@TempDir Path folder) throws Exception { ExitUtils.disableSystemExit(); conf = new OzoneConfiguration(); - conf.set(OZONE_METADATA_DIRS, folder.getAbsolutePath()); + conf.set(OZONE_METADATA_DIRS, folder.toString()); conf.setTimeDuration(HDDS_CONTAINER_REPORT_INTERVAL, 200, TimeUnit.MILLISECONDS); conf.setTimeDuration(OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL, 100, @@ -143,7 +144,8 @@ public void testIrrelevantSstFileDeletion() final int keyCount = 100; String volumeName = "vol1"; String bucketName1 = "buck1"; - createVolumeAndBucket(volumeName, bucketName1); + createVolume(volumeName); + addBucketToVolume(volumeName, bucketName1); createKeys(volumeName, bucketName1, keyCount / 2); activeDbStore.getDb().flush(OmMetadataManagerImpl.KEY_TABLE); @@ -188,6 +190,7 @@ public void testIrrelevantSstFileDeletion() List allFiles = activeDbStore.getDb().getSstFileList(); String snapshotName1 = "snapshot1"; writeClient.createSnapshot(volumeName, bucketName2, snapshotName1); + countTotalSnapshots++; SnapshotInfo snapshotInfo = om.getMetadataManager().getSnapshotInfoTable() .get(SnapshotInfo.getTableKey(volumeName, bucketName2, snapshotName1)); assertFalse(snapshotInfo.isSstFiltered()); @@ -225,6 +228,7 @@ public void testIrrelevantSstFileDeletion() filteringService.getBootstrapStateLock().lock()) { count = filteringService.getSnapshotFilteredCount().get(); writeClient.createSnapshot(volumeName, bucketName2, snapshotName2); + countTotalSnapshots++; assertThrows(TimeoutException.class, () -> waitForSnapshotsAtLeast(filteringService, count + 1)); @@ -238,9 +242,6 @@ public void testIrrelevantSstFileDeletion() Set keysFromSnapshot2 = getKeysFromSnapshot(volumeName, bucketName2, snapshotName2); assertEquals(keysFromActiveDb2, keysFromSnapshot2); - writeClient.deleteSnapshot(volumeName, bucketName2, snapshotName1); - writeClient.deleteSnapshot(volumeName, bucketName2, snapshotName2); - await(10_000, 1_000, () -> filteringService.getSnapshotFilteredCount().get() == 0); } @Test @@ -272,7 +273,9 @@ public void testActiveAndDeletedSnapshotCleanup() throws Exception { sstFilteringService.pause(); writeClient.createSnapshot(volumeName, bucketNames.get(0), "snap1"); + countTotalSnapshots++; writeClient.createSnapshot(volumeName, bucketNames.get(0), "snap2"); + countTotalSnapshots++; SnapshotInfo snapshot1Info = om.getMetadataManager().getSnapshotInfoTable() .get(SnapshotInfo.getTableKey(volumeName, bucketNames.get(0), "snap1")); @@ -290,15 +293,15 @@ public void testActiveAndDeletedSnapshotCleanup() throws Exception { await(10_000, 1_000, () -> snap1Current.exists() && snap2Current.exists()); long snap1SstFileCountBeforeFilter = Arrays.stream(snapshot1Dir.listFiles()) - .filter(f -> f.getName().endsWith(".sst")).count(); + .filter(f -> f.getName().endsWith(SST_FILE_EXTENSION)).count(); long snap2SstFileCountBeforeFilter = Arrays.stream(snapshot2Dir.listFiles()) - .filter(f -> f.getName().endsWith(".sst")).count(); + .filter(f -> f.getName().endsWith(SST_FILE_EXTENSION)).count(); // delete snap1 writeClient.deleteSnapshot(volumeName, bucketNames.get(0), "snap1"); sstFilteringService.resume(); // Filtering service will only act on snap2 as it is an active snaphot - waitForSnapshotsAtLeast(sstFilteringService, 2); + waitForSnapshotsAtLeast(sstFilteringService, countTotalSnapshots); long snap1SstFileCountAfterFilter = Arrays.stream(snapshot1Dir.listFiles()) .filter(f -> f.getName().endsWith(SST_FILE_EXTENSION)).count(); long snap2SstFileCountAfterFilter = Arrays.stream(snapshot2Dir.listFiles()) @@ -306,13 +309,12 @@ public void testActiveAndDeletedSnapshotCleanup() throws Exception { // one sst will be filtered in both active but not in deleted snapshot // as sstFiltering svc won't run on already deleted snapshots but will mark // it as filtered. - assertEquals(2, sstFilteringService.getSnapshotFilteredCount().get()); + assertEquals(countTotalSnapshots, sstFilteringService.getSnapshotFilteredCount().get()); assertEquals(snap1SstFileCountBeforeFilter, snap1SstFileCountAfterFilter); - assertEquals(snap2SstFileCountBeforeFilter - 1, - snap2SstFileCountAfterFilter); - //clear data - writeClient.deleteSnapshot(volumeName, bucketNames.get(0), "snap2"); - await(10_000, 1_000, () -> sstFilteringService.getSnapshotFilteredCount().get() == 0); + // If method with order 1 is run .sst file from /vol1/buck1 and /vol1/buck2 will be deleted. + // As part of this method .sst file from /volume1/bucket2/ will be deleted. + // sstFiltering won't run on deleted snapshots /volume1/bucket1. + assertThat(snap2SstFileCountBeforeFilter).isGreaterThan(snap2SstFileCountAfterFilter); } private void createKeys(String volumeName, @@ -325,23 +327,6 @@ private void createKeys(String volumeName, } } - private void createVolumeAndBucket(String volumeName, - String bucketName) - throws IOException { - OMRequestTestUtils.addVolumeToOM(keyManager.getMetadataManager(), - OmVolumeArgs.newBuilder() - .setOwnerName("o") - .setAdminName("a") - .setVolume(volumeName) - .build()); - - OMRequestTestUtils.addBucketToOM(keyManager.getMetadataManager(), - OmBucketInfo.newBuilder().setVolumeName(volumeName) - .setBucketName(bucketName) - .setIsVersionEnabled(false) - .build()); - } - private void createVolume(String volumeName) throws IOException { OMRequestTestUtils.addVolumeToOM(keyManager.getMetadataManager(), @@ -400,8 +385,9 @@ public void testSstFilteringService() throws Exception { String volumeName = "volume"; List bucketNames = Arrays.asList("bucket", "bucket1", "bucket2"); + createVolume(volumeName); for (String bucketName : bucketNames) { - createVolumeAndBucket(volumeName, bucketName); + addBucketToVolume(volumeName, bucketName); } int keyCount = 150; @@ -436,15 +422,15 @@ public void testSstFilteringService() throws Exception { List snapshotNames = Arrays.asList("snap", "snap-1", "snap-2"); for (int i = 0; i < 3; i++) { - writeClient.createSnapshot(volumeName, bucketNames.get(i), - snapshotNames.get(i)); + writeClient.createSnapshot(volumeName, bucketNames.get(i), snapshotNames.get(i)); + countTotalSnapshots++; } SstFilteringService sstFilteringService = keyManager.getSnapshotSstFilteringService(); - waitForSnapshotsAtLeast(sstFilteringService, 3); - assertEquals(3, sstFilteringService.getSnapshotFilteredCount().get()); + waitForSnapshotsAtLeast(sstFilteringService, countTotalSnapshots); + assertEquals(countTotalSnapshots, sstFilteringService.getSnapshotFilteredCount().get()); Set keyInBucketAfterFilteringRun = getKeysFromSnapshot(volumeName, bucketNames.get(0), @@ -458,12 +444,6 @@ public void testSstFilteringService() throws Exception { assertEquals(keyInBucket, keyInBucketAfterFilteringRun); assertEquals(keyInBucket1, keyInBucket1AfterFilteringRun); assertEquals(keyInBucket2, keyInBucket2AfterFilteringRun); - //clear data - for (int i = 0; i < 3; i++) { - writeClient.deleteSnapshot(volumeName, bucketNames.get(i), - snapshotNames.get(i)); - } - await(10_000, 1_000, () -> sstFilteringService.getSnapshotFilteredCount().get() == 0); } private static void waitForSnapshotsAtLeast(SstFilteringService filteringService, long n) From 27122faed5aff2ccc4f5dc7919077430d27e0df2 Mon Sep 17 00:00:00 2001 From: Raju Balpande Date: Thu, 8 Feb 2024 18:46:47 +0530 Subject: [PATCH 5/6] HDDS-10218 reducing the initiation, we are using different volume for each Test. --- .../org/apache/hadoop/ozone/om/TestSstFilteringService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java index 6836936d9f51..c56ab1d76997 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java @@ -78,7 +78,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestMethodOrder(OrderAnnotation.class) public class TestSstFilteringService { - public static final String SST_FILE_EXTENSION = ".sst";; + private static final String SST_FILE_EXTENSION = ".sst";; private OzoneManagerProtocol writeClient; private OzoneManager om; private OzoneConfiguration conf; @@ -313,7 +313,7 @@ public void testActiveAndDeletedSnapshotCleanup() throws Exception { assertEquals(snap1SstFileCountBeforeFilter, snap1SstFileCountAfterFilter); // If method with order 1 is run .sst file from /vol1/buck1 and /vol1/buck2 will be deleted. // As part of this method .sst file from /volume1/bucket2/ will be deleted. - // sstFiltering won't run on deleted snapshots /volume1/bucket1. + // sstFiltering won't run on deleted snapshots in /volume1/bucket1. assertThat(snap2SstFileCountBeforeFilter).isGreaterThan(snap2SstFileCountAfterFilter); } From f9855bb97160fd72c71a3f90c1ebe5062ac7a9a0 Mon Sep 17 00:00:00 2001 From: Raju Balpande Date: Fri, 9 Feb 2024 17:09:51 +0530 Subject: [PATCH 6/6] HDDS-10218 reducing the initiation, we are using different volume for each Test. --- .../ozone/om/TestSstFilteringService.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java index c56ab1d76997..4b68875af232 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestSstFilteringService.java @@ -78,7 +78,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestMethodOrder(OrderAnnotation.class) public class TestSstFilteringService { - private static final String SST_FILE_EXTENSION = ".sst";; + private static final String SST_FILE_EXTENSION = ".sst"; private OzoneManagerProtocol writeClient; private OzoneManager om; private OzoneConfiguration conf; @@ -189,8 +189,7 @@ public void testIrrelevantSstFileDeletion() activeDbStore.getDb().flush(OmMetadataManagerImpl.KEY_TABLE); List allFiles = activeDbStore.getDb().getSstFileList(); String snapshotName1 = "snapshot1"; - writeClient.createSnapshot(volumeName, bucketName2, snapshotName1); - countTotalSnapshots++; + createSnapshot(volumeName, bucketName2, snapshotName1); SnapshotInfo snapshotInfo = om.getMetadataManager().getSnapshotInfoTable() .get(SnapshotInfo.getTableKey(volumeName, bucketName2, snapshotName1)); assertFalse(snapshotInfo.isSstFiltered()); @@ -227,8 +226,7 @@ public void testIrrelevantSstFileDeletion() try (BootstrapStateHandler.Lock lock = filteringService.getBootstrapStateLock().lock()) { count = filteringService.getSnapshotFilteredCount().get(); - writeClient.createSnapshot(volumeName, bucketName2, snapshotName2); - countTotalSnapshots++; + createSnapshot(volumeName, bucketName2, snapshotName2); assertThrows(TimeoutException.class, () -> waitForSnapshotsAtLeast(filteringService, count + 1)); @@ -272,10 +270,8 @@ public void testActiveAndDeletedSnapshotCleanup() throws Exception { keyManager.getSnapshotSstFilteringService(); sstFilteringService.pause(); - writeClient.createSnapshot(volumeName, bucketNames.get(0), "snap1"); - countTotalSnapshots++; - writeClient.createSnapshot(volumeName, bucketNames.get(0), "snap2"); - countTotalSnapshots++; + createSnapshot(volumeName, bucketNames.get(0), "snap1"); + createSnapshot(volumeName, bucketNames.get(0), "snap2"); SnapshotInfo snapshot1Info = om.getMetadataManager().getSnapshotInfoTable() .get(SnapshotInfo.getTableKey(volumeName, bucketNames.get(0), "snap1")); @@ -422,8 +418,7 @@ public void testSstFilteringService() throws Exception { List snapshotNames = Arrays.asList("snap", "snap-1", "snap-2"); for (int i = 0; i < 3; i++) { - writeClient.createSnapshot(volumeName, bucketNames.get(i), snapshotNames.get(i)); - countTotalSnapshots++; + createSnapshot(volumeName, bucketNames.get(i), snapshotNames.get(i)); } SstFilteringService sstFilteringService = @@ -484,4 +479,9 @@ private Set getKeysFromSnapshot(String volume, return getKeysFromDb(omSnapshot.getMetadataManager(), volume, bucket); } } + + private void createSnapshot(String volumeName, String bucketName, String snapshotName) throws IOException { + writeClient.createSnapshot(volumeName, bucketName, snapshotName); + countTotalSnapshots++; + } }