**Build scan:**
https://gradle-enterprise.elastic.co/s/vvbkwrzc672ea/tests/:x-pack:plugin:snapshot-based-recoveries:internalClusterTest/org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT/testCancelledRecoveryAbortsDownloadPromptly

**Reproduction line:**
```
./gradlew ':x-pack:plugin:snapshot-based-recoveries:internalClusterTest' --tests "org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT.testCancelledRecoveryAbortsDownloadPromptly" -Dtests.seed=DB2B89F27A651CDB -Dtests.locale=is -Dtests.timezone=Asia/Barnaul -Druntime.java=20
```

**Applicable branches:**
main

**Reproduces locally?:**
Didn't try

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT&tests.test=testCancelledRecoveryAbortsDownloadPromptly

**Failure excerpt:**
```
com.carrotsearch.randomizedtesting.UncaughtExceptionError: Captured an uncaught exception in thread: Thread[id=416, name=elasticsearch[node_t0][generic][T#4], state=RUNNABLE, group=TGRP-SnapshotBasedIndexRecoveryIT]

  at __randomizedtesting.SeedInfo.seed([DB2B89F27A651CDB:44A6B186778E6B1E]:0)

  Caused by: java.lang.AssertionError: (No message provided)

    at __randomizedtesting.SeedInfo.seed([DB2B89F27A651CDB]:0)
    at org.junit.Assert.fail(Assert.java:86)
    at org.junit.Assert.assertTrue(Assert.java:41)
    at org.junit.Assert.assertFalse(Assert.java:64)
    at org.junit.Assert.assertFalse(Assert.java:74)
    at org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT$1.beforeRead(SnapshotBasedIndexRecoveryIT.java:705)
    at org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.SnapshotBasedIndexRecoveryIT$1.read(SnapshotBasedIndexRecoveryIT.java:700)
    at org.elasticsearch.index.snapshots.blobstore.SlicedInputStream.read(SlicedInputStream.java:81)
    at java.io.FilterInputStream.read(FilterInputStream.java:119)
    at org.elasticsearch.index.snapshots.blobstore.RateLimitingInputStream.read(RateLimitingInputStream.java:62)
    at java.io.FilterInputStream.read(FilterInputStream.java:119)
    at org.elasticsearch.index.snapshots.blobstore.RateLimitingInputStream.read(RateLimitingInputStream.java:62)
    at java.io.FilterInputStream.read(FilterInputStream.java:119)
    at org.elasticsearch.indices.recovery.RecoveryTarget$1.read(RecoveryTarget.java:600)
    at java.io.FilterInputStream.read(FilterInputStream.java:95)
    at org.elasticsearch.indices.recovery.MultiFileWriter.writeFile(MultiFileWriter.java:103)
    at org.elasticsearch.indices.recovery.RecoveryTarget.restoreFileFromSnapshot(RecoveryTarget.java:590)
    at org.elasticsearch.indices.recovery.PeerRecoveryTargetService$2.handleRequest(PeerRecoveryTargetService.java:141)
    at org.elasticsearch.indices.recovery.PeerRecoveryTargetService$2.handleRequest(PeerRecoveryTargetService.java:138)
    at org.elasticsearch.indices.recovery.PeerRecoveryTargetService$RecoveryRequestHandler.messageReceived(PeerRecoveryTargetService.java:571)
    at org.elasticsearch.indices.recovery.PeerRecoveryTargetService$RecoveryRequestHandler.messageReceived(PeerRecoveryTargetService.java:558)
    at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:74)
    at org.elasticsearch.transport.InboundHandler$1.doRun(InboundHandler.java:315)
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.lang.Thread.run(Thread.java:1623)

```
x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java
assertThat(recoveryState.getTargetNode().getName(), equalTo(targetNode));
        RecoveryState.Index indexState = recoveryState.getIndex();
        assertThat(indexState.recoveredBytesPercent(), greaterThanOrEqualTo(0.0f));
        assertThat(indexState.recoveredBytesPercent(), lessThanOrEqualTo(100.0f));
    }
    private RecoveryState getLatestPeerRecoveryStateForShard(String indexName, int shardId) {
        RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries(indexName).get();
        assertThat(recoveryResponse.hasRecoveries(), equalTo(true));
        List<RecoveryState> indexRecoveries = recoveryResponse.shardRecoveryStates().get(indexName);
        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())));
        return peerRecoveries.get(peerRecoveries.size() - 1);
    }
    private void updateSetting(String key, String value) {
        updateClusterSettings(Settings.builder().put(key, value));
    }
    private void createRepo(String repoName, String type) {
        final Settings.Builder settings = Settings.builder()
            .put(BlobStoreRepository.USE_FOR_PEER_RECOVERY_SETTING.getKey(), true)
            .put("location", randomRepoPath());
        createRepository(logger, repoName, type, settings, true);
    }
}