Skip to content

Commit 964b1c6

Browse files
Hyaskseanmonstar
authored andcommitted
tests: bypass the proxy when testing timeouts
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.
1 parent 09884ed commit 964b1c6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/timeouts.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ async fn client_timeout() {
1919

2020
let client = reqwest::Client::builder()
2121
.timeout(Duration::from_millis(100))
22+
.no_proxy()
2223
.build()
2324
.unwrap();
2425

@@ -44,7 +45,7 @@ async fn request_timeout() {
4445
}
4546
});
4647

47-
let client = reqwest::Client::builder().build().unwrap();
48+
let client = reqwest::Client::builder().no_proxy().build().unwrap();
4849

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

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

7273
let client = reqwest::Client::builder()
7374
.connect_timeout(Duration::from_millis(100))
75+
.no_proxy()
7476
.build()
7577
.unwrap();
7678

@@ -101,6 +103,7 @@ async fn connect_many_timeout_succeeds() {
101103
&["10.255.255.1:81".parse().unwrap(), server.addr()],
102104
)
103105
.connect_timeout(Duration::from_millis(100))
106+
.no_proxy()
104107
.build()
105108
.unwrap();
106109

@@ -128,6 +131,7 @@ async fn connect_many_timeout() {
128131
],
129132
)
130133
.connect_timeout(Duration::from_millis(100))
134+
.no_proxy()
131135
.build()
132136
.unwrap();
133137

@@ -190,6 +194,7 @@ async fn read_timeout_applies_to_headers() {
190194

191195
let client = reqwest::Client::builder()
192196
.read_timeout(Duration::from_millis(100))
197+
.no_proxy()
193198
.build()
194199
.unwrap();
195200

@@ -410,7 +415,7 @@ async fn response_body_timeout_forwards_size_hint() {
410415

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

413-
let client = reqwest::Client::new();
418+
let client = reqwest::Client::builder().no_proxy().build().unwrap();
414419

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

0 commit comments

Comments
 (0)