From 0595e564da3e5ca9206858256dc7c7d171621d41 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Wed, 27 Jul 2022 12:32:35 +0200 Subject: [PATCH] tests: update app settings test The original test no longer makes sense once we drop pool timeouts with the hasql-pool upgrade. To somehow test that new connections have the settings, convert it to flush the pool instead. --- test/io/test_io.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/io/test_io.py b/test/io/test_io.py index 21cedfeff..ef81be818 100644 --- a/test/io/test_io.py +++ b/test/io/test_io.py @@ -590,9 +590,9 @@ def test_iat_claim(defaultenv): time.sleep(0.1) -def test_app_settings(defaultenv): +def test_app_settings_flush_pool(defaultenv): """ - App settings should not reset when the db pool times out. + App settings should not reset when the db pool is flushed. See: https://github.com/PostgREST/postgrest/issues/1141 @@ -601,12 +601,16 @@ def test_app_settings(defaultenv): env = {**defaultenv, "PGRST_APP_SETTINGS_EXTERNAL_API_SECRET": "0123456789abcdef"} with run(env=env) as postgrest: - # Wait for the db pool to time out, set to 1s in config - time.sleep(2) + uri = "/rpc/get_guc_value?name=app.settings.external_api_secret" + response = postgrest.session.get(uri) + assert response.text == '"0123456789abcdef"' + + # SIGUSR1 causes the postgres connection pool to be flushed + postgrest.process.send_signal(signal.SIGUSR1) + time.sleep(0.1) uri = "/rpc/get_guc_value?name=app.settings.external_api_secret" response = postgrest.session.get(uri) - assert response.text == '"0123456789abcdef"'