From e96e16fa273092d5593186ce176211791112a68b Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Thu, 9 May 2024 09:17:43 +0200 Subject: [PATCH] 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. --- test/io/test_io.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/io/test_io.py b/test/io/test_io.py index e36bb9963..289be9fa9 100644 --- a/test/io/test_io.py +++ b/test/io/test_io.py @@ -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"