test: Improve log output for failing io-tests

This commit is contained in:
Wolfgang Walther
2022-06-03 22:19:16 -05:00
committed by Steve Chavez
parent e8e3349a71
commit ce6ea74ee1
+18 -9
View File
@@ -175,6 +175,9 @@ def run(configpath=None, stdin=None, env=None, port=None):
yield PostgrestProcess(process=process, session=PostgrestSession(baseurl))
finally:
remaining_output = process.stdout.read()
if remaining_output:
print(remaining_output.decode())
process.terminate()
try:
process.wait(timeout=1)
@@ -195,6 +198,7 @@ def wait_until_ready(url):
"Wait for the given HTTP endpoint to return a status of 200."
session = requests_unixsocket.Session()
response = None
for _ in range(10):
try:
response = session.get(url, timeout=1)
@@ -205,7 +209,10 @@ def wait_until_ready(url):
time.sleep(0.1)
raise PostgrestTimedOut()
if response:
raise PostgrestTimedOut(f"{response.status_code}: {response.text}")
else:
raise PostgrestTimedOut()
def authheader(token):
@@ -481,7 +488,6 @@ def test_app_settings(defaultenv):
uri = "/rpc/get_guc_value?name=app.settings.external_api_secret"
response = postgrest.session.get(uri)
assert response.status_code == 200
assert response.text == '"0123456789abcdef"'
@@ -494,7 +500,6 @@ def test_app_settings_reload(tmp_path, defaultenv):
with run(configfile, env=defaultenv) as postgrest:
response = postgrest.session.get(uri)
assert response.status_code == 200
assert response.text == '"John"'
# change setting
@@ -505,7 +510,6 @@ def test_app_settings_reload(tmp_path, defaultenv):
time.sleep(0.1)
response = postgrest.session.get(uri)
assert response.status_code == 200
assert response.text == '"Jane"'
@@ -649,6 +653,7 @@ def test_max_rows_reload(defaultenv):
with run(config, env=env) as postgrest:
response = postgrest.session.head("/projects")
assert response.status_code == 200
assert response.headers["Content-Range"] == "0-4/*"
# change max-rows config on the db
@@ -660,11 +665,12 @@ def test_max_rows_reload(defaultenv):
time.sleep(0.1)
response = postgrest.session.head("/projects")
assert response.status_code == 200
assert response.headers["Content-Range"] == "0-0/*"
# reset max-rows config on the db
postgrest.session.post("/rpc/reset_max_rows_config")
response = postgrest.session.post("/rpc/reset_max_rows_config")
assert response.status_code == 200
def test_max_rows_notify_reload(defaultenv):
@@ -678,6 +684,7 @@ def test_max_rows_notify_reload(defaultenv):
with run(env=env) as postgrest:
response = postgrest.session.head("/projects")
assert response.status_code == 200
assert response.headers["Content-Range"] == "0-4/*"
# change max-rows config on the db and reload with notify
@@ -688,11 +695,12 @@ def test_max_rows_notify_reload(defaultenv):
time.sleep(0.1)
response = postgrest.session.head("/projects")
assert response.status_code == 200
assert response.headers["Content-Range"] == "0-0/*"
# reset max-rows config on the db
postgrest.session.post("/rpc/reset_max_rows_config")
response = postgrest.session.post("/rpc/reset_max_rows_config")
assert response.status_code == 200
def test_invalid_role_claim_key_notify_reload(defaultenv):
@@ -720,7 +728,8 @@ def test_invalid_role_claim_key_notify_reload(defaultenv):
in output.decode()
)
postgrest.session.post("/rpc/reset_invalid_role_claim_key")
response = postgrest.session.post("/rpc/reset_invalid_role_claim_key")
assert response.status_code == 200
def test_db_prepared_statements_enable(defaultenv):