Skip to content

Commit d4a4869

Browse files
committed
TEST: Update translog gen of the last commit
The test testWithRandomException was not updated accordingly to the latest translog policy. Method setTranslogGenerationOfLastCommit should be called before whenever setMinTranslogGenerationForRecovery is called. Relates #27606
1 parent 9b55821 commit d4a4869

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@
109109
import java.util.stream.Collectors;
110110
import java.util.stream.LongStream;
111111

112-
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomLongBetween;
113112
import static org.elasticsearch.common.util.BigArrays.NON_RECYCLING_INSTANCE;
114113
import static org.elasticsearch.index.translog.SnapshotMatchers.containsOperationsInAnyOrder;
115114
import static org.elasticsearch.index.translog.TranslogDeletionPolicies.createTranslogDeletionPolicy;
@@ -2225,6 +2224,7 @@ public void testWithRandomException() throws IOException {
22252224
unsynced.clear();
22262225
failableTLog.rollGeneration();
22272226
committing = true;
2227+
failableTLog.getDeletionPolicy().setTranslogGenerationOfLastCommit(failableTLog.currentFileGeneration());
22282228
failableTLog.getDeletionPolicy().setMinTranslogGenerationForRecovery(failableTLog.currentFileGeneration());
22292229
failableTLog.trimUnreferencedReaders();
22302230
committing = false;
@@ -2267,6 +2267,7 @@ public void testWithRandomException() throws IOException {
22672267
if (randomBoolean()) {
22682268
try {
22692269
TranslogDeletionPolicy deletionPolicy = createTranslogDeletionPolicy();
2270+
deletionPolicy.setTranslogGenerationOfLastCommit(minGenForRecovery);
22702271
deletionPolicy.setMinTranslogGenerationForRecovery(minGenForRecovery);
22712272
IOUtils.close(getFailableTranslog(fail, config, randomBoolean(), false, generationUUID, deletionPolicy));
22722273
} catch (TranslogException | MockDirectoryWrapper.FakeIOException ex) {
@@ -2278,6 +2279,7 @@ public void testWithRandomException() throws IOException {
22782279

22792280
fail.failNever(); // we don't wanna fail here but we might since we write a new checkpoint and create a new tlog file
22802281
TranslogDeletionPolicy deletionPolicy = createTranslogDeletionPolicy();
2282+
deletionPolicy.setTranslogGenerationOfLastCommit(minGenForRecovery);
22812283
deletionPolicy.setMinTranslogGenerationForRecovery(minGenForRecovery);
22822284
try (Translog translog = new Translog(config, generationUUID, deletionPolicy, () -> SequenceNumbers.UNASSIGNED_SEQ_NO);
22832285
Translog.Snapshot snapshot = translog.newSnapshotFromGen(minGenForRecovery)) {

0 commit comments

Comments
 (0)