Skip to content

Commit 2a863ac

Browse files
committed
Fix testCleanUpCommitsWhenGlobalCheckpointAdvanced
Relates #48559
1 parent b08cd05 commit 2a863ac

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
@@ -4973,11 +4973,15 @@ public void testCleanUpCommitsWhenGlobalCheckpointAdvanced() throws Exception {
49734973
}
49744974
}
49754975
engine.flush(false, randomBoolean());
4976-
List<IndexCommit> commits = DirectoryReader.listCommits(store.directory());
4977-
// Global checkpoint advanced but not enough - all commits are kept.
4978-
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint() - 1));
4976+
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint()));
49794977
engine.syncTranslog();
4980-
assertThat(DirectoryReader.listCommits(store.directory()), equalTo(commits));
4978+
List<IndexCommit> commits = DirectoryReader.listCommits(store.directory());
4979+
assertThat(Long.parseLong(commits.get(0).getUserData().get(SequenceNumbers.MAX_SEQ_NO)),
4980+
lessThanOrEqualTo(globalCheckpoint.get()));
4981+
for (int i = 1; i < commits.size(); i++) {
4982+
assertThat(Long.parseLong(commits.get(i).getUserData().get(SequenceNumbers.MAX_SEQ_NO)),
4983+
greaterThan(globalCheckpoint.get()));
4984+
}
49814985
// Global checkpoint advanced enough - only the last commit is kept.
49824986
globalCheckpoint.set(randomLongBetween(engine.getPersistedLocalCheckpoint(), Long.MAX_VALUE));
49834987
engine.syncTranslog();

0 commit comments

Comments
 (0)