Skip to content

Commit

Permalink
Fix testCleanUpCommitsWhenGlobalCheckpointAdvanced
Browse files Browse the repository at this point in the history
Relates #48559
  • Loading branch information
dnhatn committed Oct 29, 2019
1 parent e00dc09 commit c2e9a77
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4957,11 +4957,15 @@ public void testCleanUpCommitsWhenGlobalCheckpointAdvanced() throws Exception {
}
}
engine.flush(false, randomBoolean());
List<IndexCommit> commits = DirectoryReader.listCommits(store.directory());
// Global checkpoint advanced but not enough - all commits are kept.
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint() - 1));
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint()));
engine.syncTranslog();
assertThat(DirectoryReader.listCommits(store.directory()), equalTo(commits));
List<IndexCommit> commits = DirectoryReader.listCommits(store.directory());
assertThat(Long.parseLong(commits.get(0).getUserData().get(SequenceNumbers.MAX_SEQ_NO)),
lessThanOrEqualTo(globalCheckpoint.get()));
for (int i = 1; i < commits.size(); i++) {
assertThat(Long.parseLong(commits.get(i).getUserData().get(SequenceNumbers.MAX_SEQ_NO)),
greaterThan(globalCheckpoint.get()));
}
// Global checkpoint advanced enough - only the last commit is kept.
globalCheckpoint.set(randomLongBetween(engine.getPersistedLocalCheckpoint(), Long.MAX_VALUE));
engine.syncTranslog();
Expand Down

0 comments on commit c2e9a77

Please sign in to comment.