Skip to content

Commit 49b348c

Browse files
authored
Fix SnapshotBasedIndexRecoveryIT#testSeqNoBasedRecoveryIsUsedAfterPrimaryFailOver (elastic#79997)
Order RecoveryStates to ensure that we get the latest recovery state to assert that the peer recovery was successful. Closes elastic#79455 Backport of elastic#79469
1 parent f15f432 commit 49b348c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import java.util.Arrays;
7474
import java.util.Collection;
7575
import java.util.Collections;
76+
import java.util.Comparator;
7677
import java.util.List;
7778
import java.util.Locale;
7879
import java.util.Map;
@@ -787,7 +788,6 @@ public void testRecoveryConcurrentlyWithIndexing() throws Exception {
787788
assertDocumentsAreEqual(indexName, numDocs.get());
788789
}
789790

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

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

13981400
assertThat(peerRecoveries, is(not(empty())));

0 commit comments

Comments
 (0)