From d792ef423f4d7813e8bc34dc91ec438d68556a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C5=82eczek?= Date: Tue, 10 Mar 2026 10:56:08 +0100 Subject: [PATCH] test(io): add test_graceful_shutdown_waits_for_in_flight_request --- test/io/test_io.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/io/test_io.py b/test/io/test_io.py index 9b5c512b8f..9b3214b864 100644 --- a/test/io/test_io.py +++ b/test/io/test_io.py @@ -105,6 +105,28 @@ def sleep(): t.join() +@pytest.mark.xfail(reason="Graceful shutdown is currently failing", strict=True) +def test_graceful_shutdown_waits_for_in_flight_request(defaultenv): + "SIGTERM should allow in-flight requests to finish before exiting" + + with run(env=defaultenv, wait_max_seconds=5) as postgrest: + + def sleep(): + response = postgrest.session.get("/rpc/sleep?seconds=3", timeout=10) + assert response.text == "" + assert response.status_code == 204 + + t = Thread(target=sleep) + t.start() + + # Wait for the request to be in-flight before shutting down. + time.sleep(1) + + postgrest.process.terminate() + + t.join() + + def test_random_port_bound(defaultenv): "PostgREST should bind to a random port when PGRST_SERVER_PORT is 0."