File: tolerate-connection-refused-in-test-timeout.patch

package info (click to toggle)
rust-reqwest 0.12.15-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,860 kB
  • sloc: makefile: 2
file content (62 lines) | stat: -rw-r--r-- 2,394 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Index: reqwest/tests/timeouts.rs
===================================================================
--- reqwest.orig/tests/timeouts.rs
+++ reqwest/tests/timeouts.rs
@@ -85,6 +85,17 @@ async fn connect_timeout() {
 
     let err = res.unwrap_err();
 
+    // some networks (particularly those used by Ubuntu autopkgtest runners) 
+    // refuse connections to unknown IPs instead of rejecting them, tolerate this.
+    use std::error::Error;
+    let mut source = err.source();
+    while let Some(err) = source {
+        if let Some(io) = err.downcast_ref::<std::io::Error>() {
+            if io.kind() == std::io::ErrorKind::ConnectionRefused { return; }
+        }
+        source = err.source();
+    }
+
     assert!(err.is_connect() && err.is_timeout(),"assertion failed err.is_connect() && err.is_timeout(), err={:?}",err);
 }
 
Index: reqwest/tests/connector_layers.rs
===================================================================
--- reqwest.orig/tests/connector_layers.rs
+++ reqwest/tests/connector_layers.rs
@@ -50,6 +50,17 @@ async fn non_op_layer_with_timeout() {
 
     let err = res.unwrap_err();
 
+    // some networks (particularly those used by Ubuntu autopkgtest runners).
+    // refuse connections to unknown IPs instead of rejecting them, tolerate this
+    use std::error::Error;
+    let mut source = err.source();
+    while let Some(err) = source {
+        if let Some(io) = err.downcast_ref::<std::io::Error>() {
+            if io.kind() == std::io::ErrorKind::ConnectionRefused { return; }
+        }
+        source = err.source();
+    }
+
     assert!(err.is_connect() && err.is_timeout(),"assertion failed: err.is_connect() && err.is_timeout(), err={:?}",err);
 }
 
@@ -71,6 +82,17 @@ async fn with_connect_timeout_layer_neve
 
     let err = res.unwrap_err();
 
+    // some networks (particularly those used by Ubuntu autopkgtest runners).
+    // refuse connections to unknown IPs instead of rejecting them, tolerate this
+    use std::error::Error;
+    let mut source = err.source();
+    while let Some(err) = source {
+        if let Some(io) = err.downcast_ref::<std::io::Error>() {
+            if io.kind() == std::io::ErrorKind::ConnectionRefused { return; }
+        }
+        source = err.source();
+    }
+
     assert!(err.is_connect() && err.is_timeout(),"assertion failed: err.is_connect() && err.is_timeout(), err={:?}",err);
 }