test: Reset statement timeout after each test

The statement timeout needs to be cleaned up after each test that
modifies it instead of before the test. Otherwise the changed timeout
leaks into other tests.
This commit is contained in:
Wolfgang Walther
2024-05-09 13:36:03 +02:00
committed by Wolfgang Walther
parent 0060abeb01
commit e96e16fa27
+10 -3
View File
@@ -506,12 +506,13 @@ def test_statement_timeout(defaultenv, metapostgrest):
data = response.json()
assert data["message"] == "canceling statement due to statement timeout"
reset_statement_timeout(metapostgrest, role)
def test_change_statement_timeout(defaultenv, metapostgrest):
"Statement timeout changes take effect immediately"
role = "timeout_authenticator"
reset_statement_timeout(metapostgrest, role)
env = {
**defaultenv,
@@ -544,6 +545,8 @@ def test_change_statement_timeout(defaultenv, metapostgrest):
response = postgrest.session.get("/rpc/sleep?seconds=1")
assert response.status_code == 204
reset_statement_timeout(metapostgrest, role)
def test_pool_size(defaultenv, metapostgrest):
"Verify that PGRST_DB_POOL setting allows the correct number of parallel requests"
@@ -606,7 +609,6 @@ def test_change_statement_timeout_held_connection(defaultenv, metapostgrest):
"Statement timeout changes take effect immediately, even with a request outliving the reconfiguration"
role = "timeout_authenticator"
reset_statement_timeout(metapostgrest, role)
env = {
**defaultenv,
@@ -651,6 +653,8 @@ def test_change_statement_timeout_held_connection(defaultenv, metapostgrest):
for t in threads:
t.join()
reset_statement_timeout(metapostgrest, role)
def test_admin_config(defaultenv):
"Should get a success response from the admin server containing current configuration"
@@ -701,7 +705,6 @@ def test_admin_ready_includes_schema_cache_state(defaultenv, metapostgrest):
"Should get a failed response from the admin server ready endpoint when the schema cache is not loaded"
role = "timeout_authenticator"
reset_statement_timeout(metapostgrest, role)
env = {
**defaultenv,
@@ -723,6 +726,8 @@ def test_admin_ready_includes_schema_cache_state(defaultenv, metapostgrest):
response = postgrest.session.get("/projects")
assert response.status_code == 503
reset_statement_timeout(metapostgrest, role)
def test_admin_not_found(defaultenv):
"Should get a not found from a undefined endpoint on the admin server"
@@ -1388,6 +1393,8 @@ def test_db_error_logging_to_stderr(level, defaultenv, metapostgrest):
assert " 500 " in output[0]
assert "canceling statement due to statement timeout" in output[1]
reset_statement_timeout(metapostgrest, role)
def test_function_setting_statement_timeout_fails(defaultenv):
"statement that takes three seconds to execute should fail with one second timeout"