Skip to content

Commit a64f1f3

Browse files
committed
Fix testCleanUpCommitsWhenGlobalCheckpointAdvanced
Relates #48559
1 parent ae2738d commit a64f1f3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4972,11 +4972,15 @@ public void testCleanUpCommitsWhenGlobalCheckpointAdvanced() throws Exception {
49724972
}
49734973
}
49744974
engine.flush(false, randomBoolean());
4975-
List<IndexCommit> commits = DirectoryReader.listCommits(store.directory());
4976-
// Global checkpoint advanced but not enough - all commits are kept.
4977-
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint() - 1));
4975+
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint()));
49784976
engine.syncTranslog();
4979-
assertThat(DirectoryReader.listCommits(store.directory()), equalTo(commits));
4977+
List<IndexCommit> commits = DirectoryReader.listCommits(store.directory());
4978+
assertThat(Long.parseLong(commits.get(0).getUserData().get(SequenceNumbers.MAX_SEQ_NO)),
4979+
lessThanOrEqualTo(globalCheckpoint.get()));
4980+
for (int i = 1; i < commits.size(); i++) {
4981+
assertThat(Long.parseLong(commits.get(i).getUserData().get(SequenceNumbers.MAX_SEQ_NO)),
4982+
greaterThan(globalCheckpoint.get()));
4983+
}
49804984
// Global checkpoint advanced enough - only the last commit is kept.
49814985
globalCheckpoint.set(randomLongBetween(engine.getPersistedLocalCheckpoint(), Long.MAX_VALUE));
49824986
engine.syncTranslog();

0 commit comments

Comments
 (0)