Adjust minRetainedSeqNo asssertion in CombinedDeletionPolicyTests
In these tests, we initialize the retained_seq_no with NO_OPS_PERFORMED, thus we should verify that the min of the retained_seq_no is at least NO_OPS_PERFORMED not 0. Closes #35994
This commit is contained in:
parent
4974684003
commit
864e465515
|
@ -39,6 +39,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.elasticsearch.index.seqno.SequenceNumbers.NO_OPS_PERFORMED;
|
||||
import static org.elasticsearch.index.translog.TranslogDeletionPolicies.createTranslogDeletionPolicy;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
|
@ -54,7 +55,7 @@ public class CombinedDeletionPolicyTests extends ESTestCase {
|
|||
final AtomicLong globalCheckpoint = new AtomicLong();
|
||||
final int extraRetainedOps = between(0, 100);
|
||||
final SoftDeletesPolicy softDeletesPolicy =
|
||||
new SoftDeletesPolicy(globalCheckpoint::get, -1, extraRetainedOps, Collections::emptyList);
|
||||
new SoftDeletesPolicy(globalCheckpoint::get, NO_OPS_PERFORMED, extraRetainedOps, Collections::emptyList);
|
||||
TranslogDeletionPolicy translogPolicy = createTranslogDeletionPolicy();
|
||||
CombinedDeletionPolicy indexPolicy = new CombinedDeletionPolicy(logger, translogPolicy, softDeletesPolicy, globalCheckpoint::get);
|
||||
|
||||
|
@ -91,8 +92,9 @@ public class CombinedDeletionPolicyTests extends ESTestCase {
|
|||
}
|
||||
assertThat(translogPolicy.getMinTranslogGenerationForRecovery(), equalTo(translogGenList.get(keptIndex)));
|
||||
assertThat(translogPolicy.getTranslogGenerationOfLastCommit(), equalTo(lastTranslogGen));
|
||||
assertThat(softDeletesPolicy.getMinRetainedSeqNo(), equalTo(
|
||||
Math.max(0, Math.min(getLocalCheckpoint(commitList.get(keptIndex)) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
|
||||
assertThat(softDeletesPolicy.getMinRetainedSeqNo(),
|
||||
equalTo(Math.max(NO_OPS_PERFORMED,
|
||||
Math.min(getLocalCheckpoint(commitList.get(keptIndex)) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
|
||||
}
|
||||
|
||||
public void testAcquireIndexCommit() throws Exception {
|
||||
|
@ -129,7 +131,7 @@ public class CombinedDeletionPolicyTests extends ESTestCase {
|
|||
indexPolicy.onCommit(commitList);
|
||||
IndexCommit safeCommit = CombinedDeletionPolicy.findSafeCommitPoint(commitList, globalCheckpoint.get());
|
||||
assertThat(softDeletesPolicy.getMinRetainedSeqNo(), equalTo(
|
||||
Math.max(0, Math.min(getLocalCheckpoint(safeCommit) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
|
||||
Math.max(NO_OPS_PERFORMED, Math.min(getLocalCheckpoint(safeCommit) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
|
||||
// Captures and releases some commits
|
||||
int captures = between(0, 5);
|
||||
for (int n = 0; n < captures; n++) {
|
||||
|
@ -160,7 +162,8 @@ public class CombinedDeletionPolicyTests extends ESTestCase {
|
|||
assertThat(translogPolicy.getTranslogGenerationOfLastCommit(),
|
||||
equalTo(Long.parseLong(commitList.get(commitList.size() - 1).getUserData().get(Translog.TRANSLOG_GENERATION_KEY))));
|
||||
assertThat(softDeletesPolicy.getMinRetainedSeqNo(), equalTo(
|
||||
Math.max(0, Math.min(getLocalCheckpoint(commitList.get(safeIndex)) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
|
||||
Math.max(NO_OPS_PERFORMED,
|
||||
Math.min(getLocalCheckpoint(commitList.get(safeIndex)) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
|
||||
}
|
||||
snapshottingCommits.forEach(indexPolicy::releaseCommit);
|
||||
globalCheckpoint.set(randomLongBetween(lastMaxSeqNo, Long.MAX_VALUE));
|
||||
|
@ -174,7 +177,7 @@ public class CombinedDeletionPolicyTests extends ESTestCase {
|
|||
assertThat(translogPolicy.getTranslogGenerationOfLastCommit(), equalTo(lastTranslogGen));
|
||||
IndexCommit safeCommit = CombinedDeletionPolicy.findSafeCommitPoint(commitList, globalCheckpoint.get());
|
||||
assertThat(softDeletesPolicy.getMinRetainedSeqNo(), equalTo(
|
||||
Math.max(0, Math.min(getLocalCheckpoint(safeCommit) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
|
||||
Math.max(NO_OPS_PERFORMED, Math.min(getLocalCheckpoint(safeCommit) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
|
||||
}
|
||||
|
||||
public void testLegacyIndex() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue