Skip to content

Commit 560837a

Browse files
committed
test: replace pathod with nginx for disconnects
Also correct `test_it_keeps_working_after_many_connection_refused` test, which was not comparing the right response body.
1 parent 32cfa5d commit 560837a

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

nix/nginxScript.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ let
77
src = fetchFromGitHub {
88
owner = "steve-chavez";
99
repo = name;
10-
rev = "46a6d48910b482cf82ecd8a3fce448498cc9f886";
11-
sha256 = "sha256-unPSFxbuvv5chyPKDRaKvxuekz3tPmhHiVzZzX1D4lk=";
10+
rev = "5eae52b15b0785765c5de17ede774f04cd60729d";
11+
sha256 = "sha256-oDvEZ2OVnM8lePYBUkQa294FLcLnxYMpE40S4XmqdBY=";
1212
};
1313
meta = with lib; {
1414
license = with licenses; [ mit ];

test/test_http_errors.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import pytest
44
from sqlalchemy import text
55

6+
wrong_port = 6666
7+
68
def test_get_bad_url(sess):
79
"""net.http_get returns a descriptive errors for bad urls"""
810

911
with pytest.raises(Exception) as execinfo:
1012
res = sess.execute(text(
11-
"""
12-
select net.http_get('localhost:8888');
13+
f"""
14+
select net.http_get('localhost:{wrong_port}');
1315
"""
1416
))
1517
assert r"Couldn\'t resolve proxy name" in str(execinfo)
@@ -31,15 +33,26 @@ def test_it_keeps_working_after_many_connection_refused(sess):
3133
"""the worker doesn't crash on many failed responses with connection refused"""
3234

3335
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);
3638
"""
3739
))
3840
sess.commit()
3941

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+
4053
(request_id,) = sess.execute(text(
4154
"""
42-
select net.http_get('http://localhost:9999/p/200');
55+
select net.http_get('http://localhost:8080/pathological?status=200');
4356
"""
4457
)).fetchone()
4558

@@ -63,7 +76,7 @@ def test_it_keeps_working_after_server_returns_nothing(sess):
6376

6477
sess.execute(text(
6578
"""
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);
6780
"""
6881
))
6982
sess.commit()
@@ -81,7 +94,7 @@ def test_it_keeps_working_after_server_returns_nothing(sess):
8194

8295
sess.execute(text(
8396
"""
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);
8598
"""
8699
)).fetchone()
87100

0 commit comments

Comments
 (0)