Skip to content

Commit 261dcb7

Browse files
committed
Fix testCleanUpCommitsWhenGlobalCheckpointAdvanced
Relates #48559
1 parent b52436a commit 261dcb7

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

0 commit comments

Comments
 (0)