Add retries to tests that download from R2 (#15322)

Closes https://github.com/astral-sh/uv/issues/15318.
This commit is contained in:
Charlie Marsh 2025-08-16 00:31:22 +01:00 committed by GitHub
parent d8f3f03198
commit 0243f91c9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 1 deletions

1
Cargo.lock generated
View File

@ -4994,6 +4994,7 @@ dependencies = [
"assert_cmd",
"assert_fs",
"axoupdater",
"backon",
"base64 0.22.1",
"byteorder",
"clap",

View File

@ -117,6 +117,7 @@ windows-result = { workspace = true }
[dev-dependencies]
assert_cmd = { workspace = true }
assert_fs = { workspace = true }
backon = { workspace = true }
base64 = { workspace = true }
byteorder = { workspace = true }
filetime = { workspace = true }

View File

@ -1,10 +1,22 @@
#![cfg(feature = "r2")]
use backon::{BackoffBuilder, Retryable};
use futures::TryStreamExt;
use tokio_util::compat::FuturesAsyncReadCompatExt;
async fn unzip(url: &str) -> anyhow::Result<(), uv_extract::Error> {
let response = reqwest::get(url).await.unwrap();
let backoff = backon::ExponentialBuilder::default()
.with_min_delay(std::time::Duration::from_millis(500))
.with_max_times(5)
.build();
let download = || async {
let response = reqwest::get(url).await?;
Ok::<_, reqwest::Error>(response)
};
let response = download.retry(backoff).await.unwrap();
let reader = response
.bytes_stream()
.map_err(std::io::Error::other)