Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Comment on lines +110 to +127
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on the discussion in #4702 (comment), the pg connection is left running while postgREST shuts down.

I was thinking the right behavior is to also kill the connection immediately.

But on postgres that behavior happens under SIGINT, SIGTERM is the smart shutdown mode (ref). So this looks correct.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steve-chavez I guess I don't understand how it affects the test itself. Do you want to have different scenarios for SIGINT and SIGTERM?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it was just a comment so we don't forget (thinking out loud). All good here.



def test_random_port_bound(defaultenv):
"PostgREST should bind to a random port when PGRST_SERVER_PORT is 0."

Expand Down
Loading