RussellSpitzer commented on a change in pull request #1361:
URL: https://github.com/apache/iceberg/pull/1361#discussion_r474290437
##########
File path: core/src/test/java/org/apache/iceberg/TestRemoveSnapshots.java
##########
@@ -50,6 +51,257 @@ public TestRemoveSnapshots(int formatVersion) {
super(formatVersion);
}
+ private long waitUntilAfter(long timestampMillis) {
+ long t = System.currentTimeMillis();
+ while (t <= timestampMillis) {
+ t = System.currentTimeMillis();
+ }
+ return t;
+ }
+
+ @Test
+ public void testExpireOlderThan() {
+ table.newAppend()
+ .appendFile(FILE_A)
+ .commit();
+
+ Snapshot firstSnapshot = table.currentSnapshot();
+
+ waitUntilAfter(table.currentSnapshot().timestampMillis());
+
+ table.newAppend()
+ .appendFile(FILE_B)
+ .commit();
+
+ long snapshotId = table.currentSnapshot().snapshotId();
+
+ long tAfterCommits =
waitUntilAfter(table.currentSnapshot().timestampMillis());
+
+ Set<String> deletedFiles = Sets.newHashSet();
+
+ table.expireSnapshots()
+ .expireOlderThan(tAfterCommits)
+ .deleteWith(deletedFiles::add)
+ .commit();
+
+ Assert.assertEquals("Expire should not change current snapshot",
snapshotId, table.currentSnapshot().snapshotId());
+ Assert.assertNull("Expire should remove the oldest snapshot",
table.snapshot(firstSnapshot.snapshotId()));
+ Assert.assertEquals("Should not remove only the expired manifest list
location",
Review comment:
Should only
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]