Skip to content

Commit c2e9a77

Browse files
committed
Fix testCleanUpCommitsWhenGlobalCheckpointAdvanced
Relates #48559
1 parent e00dc09 commit c2e9a77

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
@@ -4957,11 +4957,15 @@ public void testCleanUpCommitsWhenGlobalCheckpointAdvanced() throws Exception {
49574957
}
49584958
}
49594959
engine.flush(false, randomBoolean());
4960-
List<IndexCommit> commits = DirectoryReader.listCommits(store.directory());
4961-
// Global checkpoint advanced but not enough - all commits are kept.
4962-
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint() - 1));
4960+
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint()));
49634961
engine.syncTranslog();
4964-
assertThat(DirectoryReader.listCommits(store.directory()), equalTo(commits));
4962+
List<IndexCommit> commits = DirectoryReader.listCommits(store.directory());
4963+
assertThat(Long.parseLong(commits.get(0).getUserData().get(SequenceNumbers.MAX_SEQ_NO)),
4964+
lessThanOrEqualTo(globalCheckpoint.get()));
4965+
for (int i = 1; i < commits.size(); i++) {
4966+
assertThat(Long.parseLong(commits.get(i).getUserData().get(SequenceNumbers.MAX_SEQ_NO)),
4967+
greaterThan(globalCheckpoint.get()));
4968+
}
49654969
// Global checkpoint advanced enough - only the last commit is kept.
49664970
globalCheckpoint.set(randomLongBetween(engine.getPersistedLocalCheckpoint(), Long.MAX_VALUE));
49674971
engine.syncTranslog();

0 commit comments

Comments
 (0)