From d2cc1459a35594f9d55d6c8dc42729c9c688b2eb Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sun, 3 Feb 2019 12:54:31 -0500 Subject: [PATCH] Fix ordering problem in add or renew lease test (#38280) We have to set the primary term before we add a retention lease, otherwise we can not assert the correct primary term. --- .../index/seqno/ReplicationTrackerRetentionLeaseTests.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java b/server/src/test/java/org/elasticsearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java index ca9ae65d273..e5c8fabd9f5 100644 --- a/server/src/test/java/org/elasticsearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java +++ b/server/src/test/java/org/elasticsearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java @@ -50,7 +50,6 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo; 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); @@ -72,13 +71,13 @@ public class ReplicationTrackerRetentionLeaseTests extends ReplicationTrackerTes 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); }