Files
cc-ci/tests/lasuite-drive/custom/test_minio_storage.py
T
notplantsandClaude Fable 5.1 9a80002b37
continuous-integration/drone/push Build is failing
lint: ruff format + one auto-fix so the push self-test is green again
`scripts/lint.sh --fix` from the pinned lint devshell: 90 Python files
reformatted (ruff format, mechanical) and one C420 (dict comprehension →
dict.fromkeys) in tests/unit/test_f211_sso_skip.py. The push self-test had
been failing at the lint stage since build 1313 (2026-08-31) on exactly
these files; nothing else changed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FqkQq3CDmFWcQ7u1LzoyRz
2026-09-07 21:15:05 +00:00

62 lines
2.6 KiB
Python

"""lasuite-drive — Q3.2 recipe-specific functional test (plan §4.3: "upload a file to a workspace,
list/download it; MinIO bucket present").
Drive stores all uploaded documents in MinIO (S3) — the `minio` service, bucket `drive-media-storage`
(created by the `minio-createbuckets` one-shot, versioning enabled). This exercises that storage
backend end-to-end at the S3 layer: it (1) confirms the bucket exists, and (2) does a real
upload → list → download round-trip and asserts the bytes survive.
It runs `mc` (bundled in the minio/minio image) INSIDE the `minio` service container, authenticating
with the in-container root creds (`/run/secrets/minio_{ru,rp}`) — the same path the recipe's own
createbuckets job uses. No dep on keycloak, so it runs on the base deploy regardless of SSO state.
NOT health-only: a drive whose object store is missing the bucket, or that can't persist/serve an
object, fails here even though the SPA at `/` returns 200.
"""
from __future__ import annotations
import os
import sys
import uuid
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner"))
from harness import lifecycle # noqa: E402
BUCKET = "drive-media-storage"
def _mc(domain: str, script: str) -> str:
"""Run an `mc` shell script inside the minio container (root creds from /run/secrets)."""
prelude = (
"set -e; "
"U=$(cat /run/secrets/minio_ru); P=$(cat /run/secrets/minio_rp); "
'mc alias set ccci http://localhost:9000 "$U" "$P" >/dev/null 2>&1; '
)
return lifecycle.exec_in_app(domain, ["sh", "-c", prelude + script], service="minio")
def test_minio_bucket_present_and_object_roundtrip(live_app):
domain = live_app # per-run drive app domain
# 1) The drive media bucket exists (mc ls returns 0; set -e raises otherwise).
_mc(domain, f"mc ls ccci/{BUCKET} >/dev/null")
# 2) Real upload -> list -> download round-trip with a unique marker.
marker = f"ccci-drive-probe-{uuid.uuid4().hex}"
key = f"ccci-probe/{marker}.txt"
out = _mc(
domain,
# upload via stdin; list the object; read it back (tagged); then delete.
f'printf %s "{marker}" | mc pipe ccci/{BUCKET}/{key} >/dev/null 2>&1; '
f"mc ls ccci/{BUCKET}/{key}; "
f'echo "READBACK:$(mc cat ccci/{BUCKET}/{key})"; '
f"mc rm ccci/{BUCKET}/{key} >/dev/null 2>&1",
)
# The object was listed (its key appears) and its content round-tripped intact.
assert f"{marker}.txt" in out, f"uploaded object not listed in bucket: {out!r}"
assert f"READBACK:{marker}" in out, (
f"object content did not round-trip through MinIO; got: {out!r}"
)