-
Notifications
You must be signed in to change notification settings - Fork 618
HDDS-13244. TestSnapshotDeletingServiceIntegrationTest should close snapshots after deleting them #8611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDDS-13244. TestSnapshotDeletingServiceIntegrationTest should close snapshots after deleting them #8611
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ | |
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.Random; | ||
| import java.util.Stack; | ||
| import java.util.UUID; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
|
|
@@ -79,9 +80,9 @@ | |
| import org.apache.hadoop.ozone.om.service.SnapshotDeletingService; | ||
| import org.apache.ozone.test.GenericTestUtils; | ||
| import org.apache.ozone.test.tag.Flaky; | ||
| import org.apache.ozone.test.tag.Unhealthy; | ||
| import org.apache.ratis.util.function.UncheckedAutoCloseableSupplier; | ||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; | ||
|
|
@@ -99,7 +100,6 @@ | |
|
|
||
| @TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
| @TestMethodOrder(OrderAnnotation.class) | ||
| @Unhealthy("HDDS-13244") | ||
| public class TestSnapshotDeletingServiceIntegrationTest { | ||
|
|
||
| private static final Logger LOG = | ||
|
|
@@ -115,6 +115,7 @@ public class TestSnapshotDeletingServiceIntegrationTest { | |
| private static final String BUCKET_NAME_ONE = "bucket1"; | ||
| private static final String BUCKET_NAME_TWO = "bucket2"; | ||
| private static final String BUCKET_NAME_FSO = "bucketfso"; | ||
| private static final Stack<UncheckedAutoCloseableSupplier<OmSnapshot>> RC_SNAPS = new Stack<>(); | ||
|
|
||
| private boolean runIndividualTest = true; | ||
|
|
||
|
|
@@ -154,6 +155,13 @@ public void teardown() { | |
| } | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void closeAllSnapshots() { | ||
| while (!RC_SNAPS.isEmpty()) { | ||
| RC_SNAPS.pop().close(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| @Order(2) | ||
| @Flaky("HDDS-11130") | ||
|
|
@@ -171,8 +179,8 @@ public void testSnapshotSplitAndMove() throws Exception { | |
| GenericTestUtils.waitFor(() -> snapshotDeletingService | ||
| .getSuccessfulRunCount() >= 1, 1000, 10000); | ||
| } | ||
| OmSnapshot bucket1snap3 = om.getOmSnapshotManager() | ||
| .getSnapshot(VOLUME_NAME, BUCKET_NAME_ONE, "bucket1snap3").get(); | ||
| OmSnapshot bucket1snap3 = RC_SNAPS.push(om.getOmSnapshotManager() | ||
| .getSnapshot(VOLUME_NAME, BUCKET_NAME_ONE, "bucket1snap3")).get(); | ||
|
|
||
| // Check bucket1key1 added to next non deleted snapshot db. | ||
| List<? extends Table.KeyValue<String, RepeatedOmKeyInfo>> omKeyInfos = | ||
|
|
@@ -403,9 +411,9 @@ public void testSnapshotWithFSO() throws Exception { | |
| } | ||
| om.getKeyManager().getDirDeletingService().suspend(); | ||
| om.getKeyManager().getDeletingService().suspend(); | ||
|
|
||
| OmSnapshot snap2 = om.getOmSnapshotManager() | ||
| .getSnapshot(VOLUME_NAME, BUCKET_NAME_FSO, "snap2").get(); | ||
| UncheckedAutoCloseableSupplier<OmSnapshot> rcSnap2 = RC_SNAPS.push(om.getOmSnapshotManager() | ||
| .getSnapshot(VOLUME_NAME, BUCKET_NAME_FSO, "snap2")); | ||
| OmSnapshot snap2 = rcSnap2.get(); | ||
| //Child directories should have moved to deleted Directory table to deleted directory table of snap2 | ||
| assertTableRowCount(dirTable, 0); | ||
| assertTableRowCount(keyTable, 11); | ||
|
|
@@ -414,7 +422,7 @@ public void testSnapshotWithFSO() throws Exception { | |
|
|
||
| client.getObjectStore().deleteSnapshot(VOLUME_NAME, BUCKET_NAME_FSO, | ||
| "snap2"); | ||
|
|
||
| rcSnap2.close(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to close this and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the snapshot to get purged we have to get write lock. OmSnapshotManager.get() acquires a read lock. So here we need to explicitly close references for it to get purged. |
||
|
|
||
| assertTableRowCount(snapshotInfoTable, 2); | ||
|
|
||
|
|
@@ -428,8 +436,9 @@ public void testSnapshotWithFSO() throws Exception { | |
| assertTableRowCount(om.getMetadataManager().getSnapshotInfoTable(), 2); | ||
|
|
||
| verifySnapshotChain(deletedSnap, "/vol1/bucketfso/snap3"); | ||
| OmSnapshot snap3 = om.getOmSnapshotManager() | ||
| .getSnapshot(VOLUME_NAME, BUCKET_NAME_FSO, "snap3").get(); | ||
| UncheckedAutoCloseableSupplier<OmSnapshot> rcSnap3 = RC_SNAPS.push(om.getOmSnapshotManager() | ||
| .getSnapshot(VOLUME_NAME, BUCKET_NAME_FSO, "snap3")); | ||
| OmSnapshot snap3 = rcSnap3.get(); | ||
|
|
||
| Table<String, OmKeyInfo> snapDeletedDirTable = | ||
| snap3.getMetadataManager().getDeletedDirTable(); | ||
|
|
@@ -471,6 +480,8 @@ public void testSnapshotWithFSO() throws Exception { | |
| // Delete Snapshot3 and check entries moved to active DB | ||
| client.getObjectStore().deleteSnapshot(VOLUME_NAME, BUCKET_NAME_FSO, | ||
| "snap3"); | ||
| rcSnap3.close(); | ||
|
|
||
| om.getKeyManager().getDirDeletingService().resume(); | ||
| om.getKeyManager().getDeletingService().resume(); | ||
| // Check entries moved to active DB | ||
|
|
@@ -480,8 +491,8 @@ public void testSnapshotWithFSO() throws Exception { | |
| assertTableRowCount(deletedTable, 15); | ||
|
|
||
| UncheckedAutoCloseableSupplier<OmSnapshot> rcSnap1 = | ||
| om.getOmSnapshotManager().getSnapshot( | ||
| VOLUME_NAME, BUCKET_NAME_FSO, "snap1"); | ||
| RC_SNAPS.push(om.getOmSnapshotManager().getSnapshot( | ||
| VOLUME_NAME, BUCKET_NAME_FSO, "snap1")); | ||
| OmSnapshot snap1 = rcSnap1.get(); | ||
| Table<String, OmKeyInfo> snap1KeyTable = | ||
| snap1.getMetadataManager().getFileTable(); | ||
|
|
@@ -516,7 +527,6 @@ public void testSnapshotWithFSO() throws Exception { | |
| assertTableRowCount(deletedTable, 15); | ||
|
|
||
| snap1 = null; | ||
| rcSnap1.close(); | ||
| } | ||
|
|
||
| private DirectoryDeletingService getMockedDirectoryDeletingService(AtomicBoolean dirDeletionWaitStarted, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
staticDequeoverStack(whichextends Vector)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done