Skip to content

Commit

Permalink
tests: update app settings test
Browse files Browse the repository at this point in the history
The original test no longer makes sense since connections don't
timeout. To somehow test that new connections have the settings,
convert it to flush the pool instead.
  • Loading branch information
robx committed Aug 4, 2022
1 parent 4a7c149 commit f64c0bd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,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
Expand All @@ -599,12 +599,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"'


Expand Down

0 comments on commit f64c0bd

Please sign in to comment.