тесты lab4 переведены на 202 + worker; unit-тесты pipeline; кейсы рецензий как 415

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

PNG с фильтром строки 5/0xff, IDAT не zlib, JPEG из 27 байт, SOS с компонентом не из SOF:
415 при загрузке. 40 Мпикс проходит до ready в лимите памяти worker.
This commit is contained in:
Alexey Bodanyuk
2026-10-31 16:12:52 +03:00
parent bc32a50967
commit aef6eb1d4c
8 changed files with 449 additions and 91 deletions
+20 -12
View File
@@ -278,15 +278,15 @@ def test_scale_up_and_down_is_picked_up_without_errors(api):
def test_compose_policy_limits_ports_secrets_images():
config = json.loads(compose("config", "--format", "json").stdout)
services = config["services"]
# The reconciler (profile "tools") is started on demand and not part of the running stand.
assert set(services) == {"postgres", "valkey", "s3", "migrate", "s3-init", "api", "lb"}
# auditor and jobctl (profile "tools") are started on demand and not part of the running stand.
assert set(services) == {"postgres", "valkey", "s3", "broker", "migrate", "s3-init", "api", "lb", "relay", "worker"}
for name, svc in services.items():
limits = svc.get("deploy", {}).get("resources", {}).get("limits", {})
assert limits.get("cpus") and limits.get("memory"), f"{name}: CPU/RAM limits"
assert "container_name" not in svc, f"{name}: container_name prevents scaling"
if name in ("api", "migrate"):
assert "build" in svc # built from this repository's source
elif name == "s3-init":
elif name in ("s3-init", "relay", "worker"):
assert svc["image"] == services["api"]["image"] # the same locally built image
else:
assert "@sha256:" in svc["image"], f"{name}: image must be pinned by digest"
@@ -294,21 +294,28 @@ def test_compose_policy_limits_ports_secrets_images():
published = {name: svc.get("ports", []) for name, svc in services.items() if svc.get("ports")}
assert set(published) == {"lb"} and all(p["host_ip"] in ("127.0.0.1", "::1") for p in published["lb"])
secrets = {name: sorted(s["source"] for s in svc.get("secrets", [])) for name, svc in services.items()}
s3_keys = ['s3_admin_access_key_id', 's3_admin_secret_access_key', 's3_api_access_key_id', 's3_api_secret_access_key', 's3_reconciler_access_key_id', 's3_reconciler_secret_access_key']
s3_keys = sorted(f"s3_{who}_{part}" for who in ("admin", "api", "worker", "auditor")
for part in ("access_key_id", "secret_access_key"))
assert secrets == {"postgres": ["postgres_password"], "valkey": ["valkey_password"], "s3": s3_keys,
"migrate": ["database_url"], "s3-init": s3_keys, "lb": [],
# the API: its own S3 key pair only (no admin, no reconciler keys)
"api": ["cache_url", "database_url", "s3_api_access_key_id", "s3_api_secret_access_key"]}
"broker": ["rabbitmq_users"],
# the API: its own S3 key pair only (no admin/worker keys, no broker credentials)
"api": ["cache_url", "database_url", "s3_api_access_key_id", "s3_api_secret_access_key"],
# relay: database + its broker user only; worker: + its own S3 key pair
"relay": ["broker_url_relay", "database_url"],
"worker": ["broker_url_worker", "database_url", "s3_worker_access_key_id",
"s3_worker_secret_access_key"]}
volumes = {name: [v["source"] for v in svc.get("volumes", []) if v["type"] == "volume"]
for name, svc in services.items()}
assert volumes == {"postgres": ["pgdata"], "valkey": ["valkeydata"], "s3": ["s3data"], "migrate": [],
"s3-init": [], "api": [], "lb": []}
"s3-init": [], "api": [], "lb": [], "broker": ["rabbitmqdata"], "relay": [], "worker": []}
networks = {name: sorted(svc.get("networks", {})) for name, svc in services.items()}
assert networks == {"postgres": ["data"], "valkey": ["data"], "s3": ["storage"], "migrate": ["data"],
"s3-init": ["storage"], "api": ["data", "edge", "storage"],
"lb": ["edge"]}, networks # the LB cannot reach the stores at all
assert config["networks"]["data"].get("internal") is True
assert config["networks"]["storage"].get("internal") is True
"s3-init": ["storage"], "api": ["data", "edge", "storage"], "broker": ["queue"],
"relay": ["data", "queue"], "worker": ["data", "queue", "storage"],
"lb": ["edge"]}, networks # the LB cannot reach the stores; the API not the broker
for network in ("data", "storage", "queue"):
assert config["networks"][network].get("internal") is True, network
def test_running_containers_have_limits_and_no_bypass_ports():
@@ -326,7 +333,8 @@ def test_running_containers_have_limits_and_no_bypass_ports():
def test_migrations_ran_once_by_the_migrate_service():
applied = psql("SELECT version FROM schema_migrations ORDER BY version").split()
assert applied == ["0001_init", "0002_idempotency_keys", "0003_post_message_function", "0004_attachments"]
assert applied == ["0001_init", "0002_idempotency_keys", "0003_post_message_function", "0004_attachments",
"0005_pipeline"]
migrate = compose("ps", "-a", "--format", "json", "migrate").stdout
rows = [json.loads(line) for line in migrate.splitlines() if line.strip()]
assert rows and all(r["State"] == "exited" and r["ExitCode"] == 0 for r in rows)