Skip to content

Commit b052a13

Browse files
committed
test: System Testing: Fixed HTTP query to handle 400 response code issued by QuestDB 6.3 and newer.
1 parent 0451339 commit b052a13

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

system_test/test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
retry)
4141
import urllib.request
4242
import urllib.parse
43+
import urllib.error
4344
import json
4445
import subprocess
4546
from collections import namedtuple
@@ -57,10 +58,12 @@ def http_sql_query(sql_query):
5758
url = (
5859
f'http://{host}:{port}/exec?' +
5960
urllib.parse.urlencode({'query': sql_query}))
60-
resp = urllib.request.urlopen(url, timeout=0.2)
61-
if resp.status != 200:
62-
raise RuntimeError(f'Error response {resp.status} from {sql_query!r}')
63-
buf = resp.read()
61+
buf = None
62+
try:
63+
resp = urllib.request.urlopen(url, timeout=0.2)
64+
buf = resp.read()
65+
except urllib.error.HTTPError as http_error:
66+
buf = http_error.read()
6467
try:
6568
data = json.loads(buf)
6669
except json.JSONDecodeError as jde:

0 commit comments

Comments
 (0)