Skip to content

Commit

Permalink
tests: bypass the proxy when testing timeouts
Browse files Browse the repository at this point in the history
If an explicit proxy is configured in the environment, the timeout tests
will actually go through it, and then the test results will depend on
the proxy's performance, which can vary.

Testing this is very simple:
```
export http_proxy="http://127.0.0.1:1234"
cargo test timeouts
```

We're hitting this issue in the Ubuntu CI. Further investigations
after 892569e seemed to point that
**sometimes**, the proxy would be too slow (particularly on non amd64
architectures), leading to the tests to actually timeout and pass.
  • Loading branch information
Hyask committed Sep 11, 2024
1 parent 09884ed commit 57b6659
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/timeouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ async fn client_timeout() {

let client = reqwest::Client::builder()
.timeout(Duration::from_millis(100))
.no_proxy()
.build()
.unwrap();

Expand All @@ -44,7 +45,7 @@ async fn request_timeout() {
}
});

let client = reqwest::Client::builder().build().unwrap();
let client = reqwest::Client::builder().no_proxy().build().unwrap();

let url = format!("http://{}/slow", server.addr());

Expand All @@ -71,6 +72,7 @@ async fn connect_timeout() {

let client = reqwest::Client::builder()
.connect_timeout(Duration::from_millis(100))
.no_proxy()
.build()
.unwrap();

Expand Down Expand Up @@ -101,6 +103,7 @@ async fn connect_many_timeout_succeeds() {
&["10.255.255.1:81".parse().unwrap(), server.addr()],
)
.connect_timeout(Duration::from_millis(100))
.no_proxy()
.build()
.unwrap();

Expand Down Expand Up @@ -128,6 +131,7 @@ async fn connect_many_timeout() {
],
)
.connect_timeout(Duration::from_millis(100))
.no_proxy()
.build()
.unwrap();

Expand Down Expand Up @@ -190,6 +194,7 @@ async fn read_timeout_applies_to_headers() {

let client = reqwest::Client::builder()
.read_timeout(Duration::from_millis(100))
.no_proxy()
.build()
.unwrap();

Expand Down Expand Up @@ -410,7 +415,7 @@ async fn response_body_timeout_forwards_size_hint() {

let server = server::http(move |_req| async { http::Response::new(b"hello".to_vec().into()) });

let client = reqwest::Client::new();
let client = reqwest::Client::builder().no_proxy().build().unwrap();

let url = format!("http://{}/slow", server.addr());

Expand Down

0 comments on commit 57b6659

Please sign in to comment.