fix: address pipeline-reliability verify findings

Close the source image after converting to RGBA so PNGs at the pixel limit
fit the render memory limit. Strengthen the fencing test so that it fails
without the attempt check, and measure worker and relay stops under load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 18:55:38 +03:00
co-authored by Claude Opus 5.5
parent 6bd60532aa
commit 399da054f2
19 changed files with 596 additions and 41 deletions
@@ -36,6 +36,7 @@ VARIANT_TYPES = {
"optimized": "image/webp",
}
VARIANT_NAMES = tuple(VARIANT_TYPES)
LARGE_BODY_CLIENT_TIMEOUT_S = 30
def thumbnail_of(
@@ -242,6 +243,41 @@ def test_thumbnail_format_variants(
variant_of(api, alice, attachment, variant)
@pytest.mark.spec("attachment-processing", "Изображение в лимите пикселей")
@pytest.mark.parametrize(
("color", "depth", "transparent"),
[
pytest.param(4, 8, False, id="gray-alpha-8"),
pytest.param(2, 8, True, id="rgb-8-trns"),
pytest.param(2, 16, True, id="rgb-16-trns"),
pytest.param(3, 8, True, id="palette-trns"),
pytest.param(0, 16, False, id="gray-16"),
],
)
def test_pixel_limit_png_modes(
base_url: str,
alice: Actor,
chat: dict[str, Any],
color: int,
depth: int,
transparent: bool,
) -> None:
"""Контракт разрешает 40 млн пикселей в любом типе PNG. Эти типы
переводятся в другой режим при подготовке: держать исходник на время
перевода и масштаба — пик выше лимита памяти процесса обработки."""
data = images.png_at_pixel_limit(color, depth, transparent=transparent)
# срок клиента: тело на 40 млн пикселей проверяется дольше 5 с по умолчанию
with Api(base_url, timeout=LARGE_BODY_CLIENT_TIMEOUT_S) as slow:
attachment = slow.upload_ready(alice, chat["id"], data)
sizes = {
"thumbnail": (256, 160),
"crop": (128, 128),
"optimized": (1280, 800),
}
for name, size in sizes.items():
assert variant_of(slow, alice, attachment, name).size == size
@pytest.mark.spec("attachment-processing", "Crop большого изображения")
def test_crop_center(
api: Api,