Skip to content

Commit

Permalink
TEST: Adjust min_retained_seq_no expectation
Browse files Browse the repository at this point in the history
min_retained_seq_no is non-negative, however, if the number of retained
operations is greater than 0, then the expectation may be negative.
  • Loading branch information
dnhatn committed Dec 3, 2018
1 parent 7e40b47 commit 76c14db
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public void testKeepCommitsAfterGlobalCheckpoint() throws Exception {
}
assertThat(translogPolicy.getMinTranslogGenerationForRecovery(), equalTo(translogGenList.get(keptIndex)));
assertThat(translogPolicy.getTranslogGenerationOfLastCommit(), equalTo(lastTranslogGen));
assertThat(softDeletesPolicy.getMinRetainedSeqNo(),
equalTo(Math.min(getLocalCheckpoint(commitList.get(keptIndex)) + 1, globalCheckpoint.get() + 1 - extraRetainedOps)));
assertThat(softDeletesPolicy.getMinRetainedSeqNo(), equalTo(
Math.max(0, Math.min(getLocalCheckpoint(commitList.get(keptIndex)) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
}

public void testAcquireIndexCommit() throws Exception {
Expand Down Expand Up @@ -126,8 +126,8 @@ public void testAcquireIndexCommit() throws Exception {
commitList.forEach(this::resetDeletion);
indexPolicy.onCommit(commitList);
IndexCommit safeCommit = CombinedDeletionPolicy.findSafeCommitPoint(commitList, globalCheckpoint.get());
assertThat(softDeletesPolicy.getMinRetainedSeqNo(),
equalTo(Math.min(getLocalCheckpoint(safeCommit) + 1, globalCheckpoint.get() + 1 - extraRetainedOps)));
assertThat(softDeletesPolicy.getMinRetainedSeqNo(), equalTo(
Math.max(0, 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++) {
Expand Down Expand Up @@ -157,8 +157,8 @@ public void testAcquireIndexCommit() throws Exception {
equalTo(Long.parseLong(commitList.get(safeIndex).getUserData().get(Translog.TRANSLOG_GENERATION_KEY))));
assertThat(translogPolicy.getTranslogGenerationOfLastCommit(),
equalTo(Long.parseLong(commitList.get(commitList.size() - 1).getUserData().get(Translog.TRANSLOG_GENERATION_KEY))));
assertThat(softDeletesPolicy.getMinRetainedSeqNo(),
equalTo(Math.min(getLocalCheckpoint(commitList.get(safeIndex)) + 1, globalCheckpoint.get() + 1 - extraRetainedOps)));
assertThat(softDeletesPolicy.getMinRetainedSeqNo(), equalTo(
Math.max(0, Math.min(getLocalCheckpoint(commitList.get(safeIndex)) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
}
snapshottingCommits.forEach(indexPolicy::releaseCommit);
globalCheckpoint.set(randomLongBetween(lastMaxSeqNo, Long.MAX_VALUE));
Expand All @@ -171,8 +171,8 @@ public void testAcquireIndexCommit() throws Exception {
assertThat(translogPolicy.getMinTranslogGenerationForRecovery(), equalTo(lastTranslogGen));
assertThat(translogPolicy.getTranslogGenerationOfLastCommit(), equalTo(lastTranslogGen));
IndexCommit safeCommit = CombinedDeletionPolicy.findSafeCommitPoint(commitList, globalCheckpoint.get());
assertThat(softDeletesPolicy.getMinRetainedSeqNo(),
equalTo(Math.min(getLocalCheckpoint(safeCommit) + 1, globalCheckpoint.get() + 1 - extraRetainedOps)));
assertThat(softDeletesPolicy.getMinRetainedSeqNo(), equalTo(
Math.max(0, Math.min(getLocalCheckpoint(safeCommit) + 1, globalCheckpoint.get() + 1 - extraRetainedOps))));
}

public void testLegacyIndex() throws Exception {
Expand Down

0 comments on commit 76c14db

Please sign in to comment.