Skip to content

Commit cb89b3b

Browse files
committed
test(io): add test_graceful_shutdown_waits_for_in_flight_request
1 parent 1a85385 commit cb89b3b

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

test/io/test_io.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,28 @@ def sleep():
105105
t.join()
106106

107107

108+
@pytest.mark.xfail(reason="Graceful shutdown is currently failing")
109+
def test_graceful_shutdown_waits_for_in_flight_request(defaultenv):
110+
"SIGTERM should allow in-flight requests to finish before exiting"
111+
112+
with run(env=defaultenv, wait_max_seconds=5) as postgrest:
113+
114+
def sleep():
115+
response = postgrest.session.get("/rpc/sleep?seconds=3", timeout=10)
116+
assert response.text == ""
117+
assert response.status_code == 204
118+
119+
t = Thread(target=sleep)
120+
t.start()
121+
122+
# Wait for the request to be in-flight before shutting down.
123+
time.sleep(1)
124+
125+
postgrest.process.terminate()
126+
127+
t.join()
128+
129+
108130
def test_random_port_bound(defaultenv):
109131
"PostgREST should bind to a random port when PGRST_SERVER_PORT is 0."
110132

0 commit comments

Comments
 (0)