Skip to content
Open
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 @@ -571,7 +571,7 @@ public void testAOSKeyDeletingWithSnapshotCreateParallelExecution()
Table<String, SnapshotInfo> snapshotInfoTable = omMetadataManager.getSnapshotInfoTable();
Table<String, OmKeyInfo> deletedDirTable = omMetadataManager.getDeletedDirTable();
Table<String, String> renameTable = omMetadataManager.getSnapshotRenamedTable();
cluster.getOzoneManager().getKeyManager().getSnapshotDeletingService().shutdown();
cluster.getOzoneManager().getKeyManager().getSnapshotDeletingService().suspend();
DirectoryDeletingService dirDeletingService = cluster.getOzoneManager().getKeyManager().getDirDeletingService();
// Suspend KeyDeletingService
dirDeletingService.suspend();
Comment on lines +574 to 577
Comment on lines +574 to 577
Expand Down Expand Up @@ -659,23 +659,7 @@ public void testAOSKeyDeletingWithSnapshotCreateParallelExecution()
service.runPeriodicalTaskNow();
store.deleteSnapshot(testVolumeName, testBucketName, snap1);
cluster.getOzoneManager().awaitDoubleBufferFlush();
cluster.restartOzoneManager();
cluster.waitForClusterToBeReady();
cluster.getOzoneManager().awaitDoubleBufferFlush();
SnapshotDeletingService snapshotDeletingService =
cluster.getOzoneManager().getKeyManager().getSnapshotDeletingService();
GenericTestUtils.waitFor(() -> {
try {
snapshotDeletingService.runPeriodicalTaskNow();
cluster.getOzoneManager().awaitDoubleBufferFlush();
long currentSnapshotCount = cluster.getOzoneManager().getMetadataManager()
.countRowsInTable(cluster.getOzoneManager().getMetadataManager().getSnapshotInfoTable());
return currentSnapshotCount <= initialSnapshotCount;
} catch (Exception e) {
throw new RuntimeException(e);
}
}, 100, 10000);
assertTableRowCount(cluster.getOzoneManager().getMetadataManager().getSnapshotInfoTable(), initialSnapshotCount);
waitForSnapshotsPurged(snapshotInfoTable, initialSnapshotCount);
dirDeletingService.resume();
}

Expand Down Expand Up @@ -789,6 +773,8 @@ public void testDirDeletedTableCleanUpForSnapshot() throws Exception {

// Manual cleanup deletedDirTable for next tests
client.getObjectStore().deleteSnapshot(volumeName, bucketName, "snap1");
cluster.getOzoneManager().awaitDoubleBufferFlush();
waitForSnapshotsPurged(snapshotInfoTable, 0);
cleanupTables();
}

Expand Down Expand Up @@ -823,6 +809,28 @@ static void assertSubPathsCount(LongSupplier pathCount, long expectedCount)
1000, 120000);
}

/**
* Wait until SnapshotDeletingService has purged snapshots and snapshotInfoTable
* reaches the expected row count.
*/
private void waitForSnapshotsPurged(Table<String, SnapshotInfo> snapshotInfoTable,
int expectedCount) throws Exception {
SnapshotDeletingService snapshotDeletingService =
cluster.getOzoneManager().getKeyManager().getSnapshotDeletingService();
snapshotDeletingService.resume();
GenericTestUtils.waitFor(() -> {
try {
snapshotDeletingService.runPeriodicalTaskNow();
cluster.getOzoneManager().awaitDoubleBufferFlush();
return cluster.getOzoneManager().getMetadataManager()
.countRowsInTable(snapshotInfoTable) == expectedCount;
} catch (Exception e) {
throw new RuntimeException("Failed to run SnapshotDeletingService purge task", e);
}
}, 1000, 120000);
assertTableRowCount(snapshotInfoTable, expectedCount);
}
Comment on lines +820 to +832

private void assertTableRowCount(Table<String, ?> table, int count)
throws TimeoutException, InterruptedException {
GenericTestUtils.waitFor(() -> assertTableRowCount(count, table), 1000,
Expand Down
Loading