Skip to content

Commit

Permalink
Fix ordering problem in add or renew lease test (#38280)
Browse files Browse the repository at this point in the history
We have to set the primary term before we add a retention lease,
otherwise we can not assert the correct primary term.
  • Loading branch information
jasontedor authored Feb 3, 2019
1 parent 6ca7a91 commit d2cc145
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

public class ReplicationTrackerRetentionLeaseTests extends ReplicationTrackerTestCase {

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/38245")
public void testAddOrRenewRetentionLease() {
final AllocationId allocationId = AllocationId.newInitializing();
long primaryTerm = randomLongBetween(1, Long.MAX_VALUE);
Expand All @@ -72,13 +71,13 @@ public void testAddOrRenewRetentionLease() {
final int length = randomIntBetween(0, 8);
final long[] minimumRetainingSequenceNumbers = new long[length];
for (int i = 0; i < length; i++) {
minimumRetainingSequenceNumbers[i] = randomLongBetween(SequenceNumbers.NO_OPS_PERFORMED, Long.MAX_VALUE);
replicationTracker.addRetentionLease(
Integer.toString(i), minimumRetainingSequenceNumbers[i], "test-" + i, ActionListener.wrap(() -> {}));
if (rarely() && primaryTerm < Long.MAX_VALUE) {
primaryTerm = randomLongBetween(primaryTerm + 1, Long.MAX_VALUE);
replicationTracker.setOperationPrimaryTerm(primaryTerm);
}
minimumRetainingSequenceNumbers[i] = randomLongBetween(SequenceNumbers.NO_OPS_PERFORMED, Long.MAX_VALUE);
replicationTracker.addRetentionLease(
Integer.toString(i), minimumRetainingSequenceNumbers[i], "test-" + i, ActionListener.wrap(() -> {}));
assertRetentionLeases(replicationTracker, i + 1, minimumRetainingSequenceNumbers, () -> 0L, primaryTerm, 1 + i, true);
}

Expand Down

0 comments on commit d2cc145

Please sign in to comment.