Recover stale PostgreSQL connections before starting requests

This commit is contained in:
Artyom
2026-11-05 21:55:14 +03:00
parent 18de595740
commit 0a1f48bd73
13 changed files with 232 additions and 8 deletions
+3 -2
View File
@@ -9,7 +9,7 @@ from pathlib import Path
import httpx
from conftest import DATABASE, new_user
from conftest import DATABASE, free_port, new_user
from messenger.shared.infrastructure.readiness import DRAINING
DRAIN = 1.0
@@ -67,7 +67,7 @@ def begin_registration(port: int) -> tuple[socket.socket, bytes]:
def test_sigterm_leaves_rotation_then_closes_and_cancels_stuck_requests(tmp_path: Path) -> None:
port = 18083
port = free_port()
settings = {
"HOST": "127.0.0.1",
"PORT": str(port),
@@ -98,6 +98,7 @@ def test_sigterm_leaves_rotation_then_closes_and_cancels_stuck_requests(tmp_path
time.sleep(0.3)
during = status(port, "/health/ready"), status(port, "/health/live")
while status(port, "/health/live") == 200:
assert time.monotonic() - sent < SHUTDOWN + 2, log_path.read_text()
time.sleep(0.05)
closed = time.monotonic() - sent
pending.sendall(rest)