Skip to content

Commit

Permalink
add test to validate that requests survive SIGUSR1
Browse files Browse the repository at this point in the history
  • Loading branch information
robx committed Aug 24, 2022
1 parent 36e4268 commit a354557
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,27 @@ def test_app_settings_flush_pool(defaultenv):
assert response.text == '"0123456789abcdef"'


def test_flush_pool_no_interrupt(defaultenv):
"Flushing the pool via SIGUSR1 doesn't interrupt ongoing requests"

with run(env=defaultenv) as postgrest:

def sleep():
response = postgrest.session.get("/rpc/sleep?seconds=0.5")
assert response.status_code == 204

t = Thread(target=sleep)
t.start()

# make sure the request has started
time.sleep(0.1)

# SIGUSR1 causes the postgres connection pool to be flushed
postgrest.process.send_signal(signal.SIGUSR1)

t.join()


def test_app_settings_reload(tmp_path, defaultenv):
"App settings should be reloaded from file when PostgREST is sent SIGUSR2."
config = (CONFIGSDIR / "sigusr2-settings.config").read_text()
Expand Down

0 comments on commit a354557

Please sign in to comment.