smengcl commented on code in PR #4969:
URL: https://github.com/apache/ozone/pull/4969#discussion_r1245798430
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshot.java:
##########
@@ -1293,4 +1300,144 @@ public void
testCompactionDagDisableForSnapshotMetadata() throws Exception {
assertNull(snapshotDbStore.getRocksDBCheckpointDiffer());
assertEquals(0, snapshotDbStore.getDbOptions().listeners().size());
}
+
+ @Test
+ public void testDayWeekMonthSnapshotCreationExpiration() throws Exception {
+ String volumeA = "vol-a-" + RandomStringUtils.randomNumeric(5);
+ String bucketA = "buc-a-" + RandomStringUtils.randomNumeric(5);
+ store.createVolume(volumeA);
+ OzoneVolume volA = store.getVolume(volumeA);
+ volA.createBucket(bucketA);
+ OzoneBucket volAbucketA = volA.getBucket(bucketA);
+
+ int latestDayIndex = 0;
+ int latestWeekIndex = 0;
+ int latestMonthIndex = 0;
+ int oldestDayIndex = latestDayIndex;
+ int oldestWeekIndex = latestWeekIndex;
+ int oldestMonthIndex = latestMonthIndex;
+ int daySnapshotRetentionPeriodDays = 7;
+ int weekSnapshotRetentionPeriodWeek = 1;
+ int monthSnapshotRetentionPeriodMonth = 1;
+ int[] updatedDayIndexArr;
+ int[] updatedWeekIndexArr;
+ int[] updatedMonthIndexArr;
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 4; j++) {
+ for (int k = 0; k < 7; k++) {
+ // if there are seven day's snapshots in cluster already,
+ // remove the oldest day snapshot then create the latest day snapshot
+ updatedDayIndexArr = checkSnapshotExpirationThenCreateLatest(
+ SNAPSHOT_DAY_PREFIX, oldestDayIndex, latestDayIndex,
+ daySnapshotRetentionPeriodDays, volumeA, bucketA, volAbucketA);
+ oldestDayIndex = updatedDayIndexArr[0];
+ latestDayIndex = updatedDayIndexArr[1];
+ }
+ // if there is one week's snapshot in cluster already,
+ // remove the oldest week snapshot then create the latest week snapshot
+ updatedWeekIndexArr = checkSnapshotExpirationThenCreateLatest(
+ SNAPSHOT_WEEK_PREFIX, oldestWeekIndex, latestWeekIndex,
+ weekSnapshotRetentionPeriodWeek, volumeA, bucketA, volAbucketA);
+ oldestWeekIndex = updatedWeekIndexArr[0];
+ latestWeekIndex = updatedWeekIndexArr[1];
+ }
+ // if there is one month's snapshot in cluster already,
+ // remove the oldest month snapshot then create the latest month snapshot
+ updatedMonthIndexArr = checkSnapshotExpirationThenCreateLatest(
+ SNAPSHOT_MONTH_PREFIX, oldestMonthIndex, latestMonthIndex,
+ monthSnapshotRetentionPeriodMonth, volumeA, bucketA, volAbucketA);
+ oldestMonthIndex = updatedMonthIndexArr[0];
+ latestMonthIndex = updatedMonthIndexArr[1];
+ }
+
+ checkDayWeekMonthSnapshotData(volAbucketA,
+ latestDayIndex,
+ latestWeekIndex,
+ latestMonthIndex,
+ KEY_TEST_DATA);
Review Comment:
We should verify data integrity each time a snapshot is taken, not just
after the loop.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]