Skip to content

Commit

Permalink
adjust test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitozi committed Apr 1, 2024
1 parent cabfcb6 commit 35f8b73
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ public int expireUntil(long earliestId, long endExclusiveId) {
snapshot.changelogRecordCount(),
snapshot.watermark(),
null);
commitChangelog(changelog);
snapshotDeletion.cleanUnusedManifests(snapshot, skippingSet, false);
} else {
// no changelog
Expand All @@ -265,9 +264,9 @@ public int expireUntil(long earliestId, long endExclusiveId) {
snapshot.changelogRecordCount(),
snapshot.watermark(),
snapshot.statistics());
commitChangelog(changelog);
snapshotDeletion.cleanUnusedManifests(snapshot, skippingSet, true);
}
commitChangelog(changelog);
} else {
snapshotDeletion.cleanUnusedManifests(snapshot, skippingSet, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,41 @@ public void testExpireWithUpgradedFile() throws Exception {
store.assertCleaned();
}

@Test
public void testChangelogOutLivedSnapshot() throws Exception {
List<KeyValue> allData = new ArrayList<>();
List<Integer> snapshotPositions = new ArrayList<>();
commit(10, allData, snapshotPositions);
ExpireSnapshots snapshot = store.newExpire(1, 2, Long.MAX_VALUE, true, true);
ExpireSnapshots changelog = store.newChangelogExpire(1, 3, Long.MAX_VALUE, true);
// expire twice to check for idempotence
snapshot.expire();
snapshot.expire();

int latestSnapshotId = snapshotManager.latestSnapshotId().intValue();
int earliestSnapshotId = snapshotManager.earliestSnapshotId().intValue();
int latestLongLivedChangelogId = snapshotManager.latestLongLivedChangelogId().intValue();
int earliestLongLivedChangelogId =
snapshotManager.earliestLongLivedChangelogId().intValue();

// 2 snapshot in /snapshot
assertThat(latestSnapshotId - earliestSnapshotId).isEqualTo(1);
assertThat(earliestLongLivedChangelogId).isEqualTo(1);
// The changelog id and snapshot id is continuous
assertThat(earliestSnapshotId - latestLongLivedChangelogId).isEqualTo(1);

changelog.expire();
changelog.expire();

assertThat(snapshotManager.latestSnapshotId().intValue()).isEqualTo(latestSnapshotId);
assertThat(snapshotManager.earliestSnapshotId().intValue()).isEqualTo(earliestSnapshotId);
assertThat(snapshotManager.latestLongLivedChangelogId())
.isEqualTo(snapshotManager.earliestSnapshotId() - 1);
assertThat(snapshotManager.earliestLongLivedChangelogId())
.isEqualTo(snapshotManager.earliestSnapshotId() - 1);
store.assertCleaned();
}

private TestFileStore createStore() {
ThreadLocalRandom random = ThreadLocalRandom.current();

Expand Down Expand Up @@ -449,38 +484,4 @@ protected void assertSnapshot(
Map<BinaryRow, BinaryRow> actual = store.toKvMap(actualKvs);
assertThat(actual).isEqualTo(expected);
}

@Test
public void testChangelogOutLivedSnapshot() throws Exception {
List<KeyValue> allData = new ArrayList<>();
List<Integer> snapshotPositions = new ArrayList<>();
commit(10, allData, snapshotPositions);
ExpireSnapshots snapshot = store.newExpire(1, 2, Long.MAX_VALUE, true, true);
ExpireSnapshots changelog = store.newChangelogExpire(1, 3, Long.MAX_VALUE, true);
// expire twice to check for idempotence
snapshot.expire();
snapshot.expire();

int latestSnapshotId = snapshotManager.latestSnapshotId().intValue();
int earliestSnapshotId = snapshotManager.earliestSnapshotId().intValue();
int latestLongLivedChangelogId = snapshotManager.latestLongLivedChangelogId().intValue();
int earliestLongLivedChangelogId =
snapshotManager.earliestLongLivedChangelogId().intValue();

// 2 snapshot in /snapshot
assertThat(latestSnapshotId - earliestSnapshotId).isEqualTo(1);
assertThat(earliestLongLivedChangelogId).isEqualTo(1);
// The changelog id and snapshot id is continuous
assertThat(earliestSnapshotId - latestLongLivedChangelogId).isEqualTo(1);

changelog.expire();
changelog.expire();

assertThat(snapshotManager.latestSnapshotId().intValue()).isEqualTo(latestSnapshotId);
assertThat(snapshotManager.earliestSnapshotId().intValue()).isEqualTo(earliestSnapshotId);
assertThat(snapshotManager.latestLongLivedChangelogId())
.isEqualTo(snapshotManager.earliestSnapshotId() - 1);
assertThat(snapshotManager.earliestLongLivedChangelogId())
.isEqualTo(snapshotManager.earliestSnapshotId() - 1);
}
}

0 comments on commit 35f8b73

Please sign in to comment.