Skip to content

Commit

Permalink
test: Reset statement timeout after each test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wolfgangwalther committed May 9, 2024
1 parent 0060abe commit 50000a5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -651,6 +653,8 @@ def sleep(i=i):
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"
Expand Down Expand Up @@ -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,
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 50000a5

Please sign in to comment.