"""Verify the Drive media bucket and an S3 object round-trip through RustFS. The recipe initializes the bucket from the backend at startup. Check the same S3 endpoint and credentials the backend uses, then write, list, read, and delete a synthetic object. A missing bucket or broken object store must fail this test. """ 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" PROBE = """ import os, sys, boto3 marker = sys.argv[1] bucket = os.environ.get("AWS_STORAGE_BUCKET_NAME", "drive-media-storage") key = f"ccci-probe/{marker}.txt" s3 = boto3.client( "s3", endpoint_url=os.environ["AWS_S3_ENDPOINT_URL"], aws_access_key_id=open("/run/secrets/rustfs_ru").read().strip(), aws_secret_access_key=open("/run/secrets/rustfs_rp").read().strip(), region_name=os.environ.get("AWS_S3_REGION_NAME", "us-east-1"), ) s3.head_bucket(Bucket=bucket) try: s3.put_object(Bucket=bucket, Key=key, Body=marker.encode()) listed = [row["Key"] for row in s3.list_objects_v2(Bucket=bucket, Prefix=key).get("Contents", [])] readback = s3.get_object(Bucket=bucket, Key=key)["Body"].read().decode() print("LISTED=" + str(key in listed)) print("READBACK=" + readback) finally: s3.delete_object(Bucket=bucket, Key=key) """ def test_rustfs_bucket_present_and_object_roundtrip(live_app): marker = f"ccci-drive-probe-{uuid.uuid4().hex}" out = lifecycle.exec_in_app(live_app, ["python", "-c", PROBE, marker], service="backend") assert "LISTED=True" in out, f"uploaded object not listed in bucket: {out!r}" assert f"READBACK={marker}" in out, f"object content did not round-trip: {out!r}"