Skip to content

Commit

Permalink
Fix SnapshotBasedIndexRecoveryIT#testSeqNoBasedRecoveryIsUsedAfterPri…
Browse files Browse the repository at this point in the history
…maryFailOver (#80002)

Order RecoveryStates to ensure that we get the latest recovery state
to assert that the peer recovery was successful.

Closes #79455
Backport of #79469
  • Loading branch information
fcofdez authored Oct 28, 2021
1 parent 1ab16fc commit 88c89f3
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -812,7 +813,6 @@ public void testRecoveryConcurrentlyWithIndexing() throws Exception {
assertDocumentsAreEqual(indexName, numDocs.get());
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/79455")
public void testSeqNoBasedRecoveryIsUsedAfterPrimaryFailOver() throws Exception {
List<String> dataNodes = internalCluster().startDataOnlyNodes(3);
String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
Expand Down Expand Up @@ -1373,8 +1373,10 @@ private RecoveryState getLatestPeerRecoveryStateForShard(String indexName, int s
assertThat(indexRecoveries, notNullValue());

List<RecoveryState> peerRecoveries = indexRecoveries.stream()
.filter(recoveryState -> recoveryState.getStage() == RecoveryState.Stage.DONE)
.filter(recoveryState -> recoveryState.getRecoverySource().equals(RecoverySource.PeerRecoverySource.INSTANCE))
.filter(recoveryState -> recoveryState.getShardId().getId() == shardId)
.sorted(Comparator.comparingLong(o -> o.getTimer().stopTime()))
.collect(Collectors.toList());

assertThat(peerRecoveries, is(not(empty())));
Expand Down

0 comments on commit 88c89f3

Please sign in to comment.