From 0d4441852e1c2383227f03ee189e563c611b0966 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Tue, 19 Mar 2024 03:39:15 -0500 Subject: [PATCH] test: notify do nothing --- CHANGELOG.md | 1 + ...test_schema_cache_snapshot[dbRoutines].yaml | 17 +++++++++++++++++ test/io/fixtures.sql | 4 ++++ test/io/test_cli.py | 2 +- test/io/test_io.py | 18 ++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 355fc872f2..ec757c4e3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - #3237, Dump media handlers and timezones with --dump-schema - @wolfgangwalther - #3323, #3324, Don't hide error on LISTEN channel failure - @steve-chavez - #3330, Incorrect admin server `/ready` response on slow schema cache loads - @steve-chavez + - #3327, Fix slow responses on schema cache reloads - @steve-chavez - #3340, Log when the LISTEN channel gets a notification - @steve-chavez ### Deprecated diff --git a/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRoutines].yaml b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRoutines].yaml index cc12ccd733..ead912a9ec 100644 --- a/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRoutines].yaml +++ b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRoutines].yaml @@ -393,6 +393,23 @@ pdSchema: public pdVolatility: Volatile +- - qiName: notify_do_nothing + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: notify_do_nothing + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + - - qiName: sleep qiSchema: public - - pdDescription: null diff --git a/test/io/fixtures.sql b/test/io/fixtures.sql index f6df21710b..636505664d 100644 --- a/test/io/fixtures.sql +++ b/test/io/fixtures.sql @@ -89,6 +89,10 @@ begin perform pg_notify('pgrst', 'reload config'); end $_$ volatile security definer language plpgsql ; +create function notify_do_nothing() returns void as $_$ + notify pgrst, 'nothing'; +$_$ language sql; + create function reset_invalid_role_claim_key() returns void as $_$ begin alter role postgrest_test_authenticator reset pgrst.jwt_role_claim_key; diff --git a/test/io/test_cli.py b/test/io/test_cli.py index 498f10ece1..a85a0111c2 100644 --- a/test/io/test_cli.py +++ b/test/io/test_cli.py @@ -246,7 +246,7 @@ def test_invalid_openapi_mode(invalidopenapimodes, defaultenv): print(line) -# If this test is failing, run pytest with --snapshot-update. +# If this test is failing, run postgrest-test-io --snapshot-update -k test_schema_cache_snapshot @pytest.mark.parametrize( "key", [ diff --git a/test/io/test_io.py b/test/io/test_io.py index d35fdb6b89..bf48ddb160 100644 --- a/test/io/test_io.py +++ b/test/io/test_io.py @@ -430,6 +430,24 @@ def test_invalid_role_claim_key_notify_reload(defaultenv): assert response.status_code == 204 +def test_notify_do_nothing(defaultenv): + "NOTIFY with unknown message should do nothing" + + env = { + **defaultenv, + "PGRST_DB_CONFIG": "true", + "PGRST_DB_CHANNEL_ENABLED": "true", + "PGRST_LOG_LEVEL": "crit", + } + + with run(env=env) as postgrest: + response = postgrest.session.post("/rpc/notify_do_nothing") + assert response.status_code == 204 + + output = postgrest.read_stdout() + assert output == [] + + def test_db_prepared_statements_enable(defaultenv): "Should use prepared statements when the setting is enabled."