test: add idle S3 upload fault check on a short S3 timeout API

Fourth API of the failure stand (S3__TIMEOUT_SECONDS=1), slow streamed
download in the test client, test_upload_after_idle_s3 and the
fix-upload-put-flake spec deltas synced into the main specs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 01:05:00 +03:00
co-authored by Claude Opus 5.5
parent 7d4b2cb37e
commit 4cfaab0063
8 changed files with 223 additions and 22 deletions
+34
View File
@@ -4,6 +4,7 @@ import base64
import dataclasses
import hashlib
import secrets
import time
import uuid
from collections.abc import Callable, Sequence
from dataclasses import dataclass
@@ -21,6 +22,8 @@ MAX_PAGES = 1000
# с лабы 3 обязателен у POST сообщения: одна отправка — один ключ, повтор
# неподтверждённой отправки — тот же ключ
IDEMPOTENCY_KEY = "Idempotency-Key"
# блок медленного скачивания: столько же отдаёт за раз поток S3 в API
DOWNLOAD_CHUNK_BYTES = 64 * 1024
class _NewKey:
@@ -332,6 +335,37 @@ class Api:
params=params,
)
def attachment_content_slowly(
self,
actor: Actor | None,
attachment_id: str,
*,
pause_s: float,
chunk_bytes: int = DOWNLOAD_CHUNK_BYTES,
) -> httpx.Response:
"""Байты оригинала потоком: пауза `pause_s` после каждого блока
`chunk_bytes` — клиент читает медленнее сети.
Отдаёт ответ со статусом, заголовками и прочитанными байтами в
`content`, как `attachment_content`: его проверяет тот же
`assert_content`.
"""
with self.client.stream(
"GET",
f"{API}/attachments/{attachment_id}/content",
headers=actor.headers() if actor is not None else {},
) as streamed:
chunks = []
for chunk in streamed.iter_bytes(chunk_bytes):
chunks.append(chunk)
time.sleep(pause_s)
return httpx.Response(
streamed.status_code,
headers=streamed.headers,
content=b"".join(chunks),
request=streamed.request,
)
def messages_page(
self,
actor: Actor,