use std::time::{Duration, Instant};
#[tokio::test]
#[ignore = "blackhole connect timing; run with --ignored"]
async fn test_http_client_with_connect_timeout_fix() {
let blackhole_ip = "10.255.255.1:80";
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(10)) .connect_timeout(Duration::from_secs(5)) .build()
.expect("Failed to build client");
let start = Instant::now();
let url = format!("http://{}/", blackhole_ip);
let result = client.get(&url).send().await;
let elapsed = start.elapsed();
println!("Request with fix took {:.2}s", elapsed.as_secs_f64());
println!("Result: {:?}", result.map(|r| r.status()));
assert!(
elapsed.as_secs() < 7,
"Request should fail fast (~5s) with connect_timeout"
);
}