3
3
import pytest
4
4
from sqlalchemy import text
5
5
6
+ wrong_port = 6666
7
+
6
8
def test_get_bad_url (sess ):
7
9
"""net.http_get returns a descriptive errors for bad urls"""
8
10
9
11
with pytest .raises (Exception ) as execinfo :
10
12
res = sess .execute (text (
11
- """
12
- select net.http_get('localhost:8888 ');
13
+ f """
14
+ select net.http_get('localhost:{ wrong_port } ');
13
15
"""
14
16
))
15
17
assert r"Couldn\'t resolve proxy name" in str (execinfo )
@@ -31,15 +33,26 @@ def test_it_keeps_working_after_many_connection_refused(sess):
31
33
"""the worker doesn't crash on many failed responses with connection refused"""
32
34
33
35
res = sess .execute (text (
34
- """
35
- select net.http_get('http://localhost:8888 ') from generate_series(1,10);
36
+ f """
37
+ select net.http_get('http://localhost:{ wrong_port } ') from generate_series(1,10);
36
38
"""
37
39
))
38
40
sess .commit ()
39
41
42
+ time .sleep (1.5 )
43
+
44
+ (error_msg ,count ) = sess .execute (text (
45
+ """
46
+ select error_msg, count(*) from net._http_response where status_code is null group by error_msg;
47
+ """
48
+ )).fetchone ()
49
+
50
+ assert error_msg == "Couldn't connect to server"
51
+ assert count == 10
52
+
40
53
(request_id ,) = sess .execute (text (
41
54
"""
42
- select net.http_get('http://localhost:9999/p/ 200');
55
+ select net.http_get('http://localhost:8080/pathological?status= 200');
43
56
"""
44
57
)).fetchone ()
45
58
@@ -63,7 +76,7 @@ def test_it_keeps_working_after_server_returns_nothing(sess):
63
76
64
77
sess .execute (text (
65
78
"""
66
- select net.http_get('http://localhost:9999/p/200:d1 ') from generate_series(1,10);
79
+ select net.http_get('http://localhost:8080/pathological?disconnect=true ') from generate_series(1,10);
67
80
"""
68
81
))
69
82
sess .commit ()
@@ -81,7 +94,7 @@ def test_it_keeps_working_after_server_returns_nothing(sess):
81
94
82
95
sess .execute (text (
83
96
"""
84
- select net.http_get('http://localhost:9999/p/ 200:b"still_working" ') from generate_series(1,10);
97
+ select net.http_get('http://localhost:8080/pathological?status= 200') from generate_series(1,10);
85
98
"""
86
99
)).fetchone ()
87
100
0 commit comments