From 848aaf18470e61cc2d1df85717bc2d482c53d631 Mon Sep 17 00:00:00 2001 From: notplants <@notplants> Date: Mon, 23 Nov 2026 23:01:14 +0000 Subject: [PATCH] Update lasuite-drive CI tests for RustFS storage --- tests/lasuite-drive/PARITY.md | 2 +- .../custom/test_minio_storage.py | 61 ------------------- .../custom/test_rustfs_storage.py | 47 ++++++++++++++ tests/lasuite-drive/ops.py | 52 ---------------- tests/lasuite-drive/recipe_meta.py | 20 +++--- 5 files changed, 56 insertions(+), 126 deletions(-) delete mode 100644 tests/lasuite-drive/custom/test_minio_storage.py create mode 100644 tests/lasuite-drive/custom/test_rustfs_storage.py diff --git a/tests/lasuite-drive/PARITY.md b/tests/lasuite-drive/PARITY.md index af0163b..ec947e1 100644 --- a/tests/lasuite-drive/PARITY.md +++ b/tests/lasuite-drive/PARITY.md @@ -23,7 +23,7 @@ nothing is a silent omission. | cc-ci file | what's verified | status | |---|---|---| | `custom/test_oidc_with_keycloak.py` | SSO round-trip against the dep keycloak: OIDC discovery advertises realm `lasuite-drive`; password grant yields a valid JWT with iss/azp/typ/exp claims. Drive is OIDC-required — this is its defining auth path. | **landed** | -| `custom/test_minio_storage.py` | The §4.3 create-an-object + read-it-back, at Drive's storage layer: confirms the `drive-media-storage` MinIO bucket exists, then a real upload → list → download round-trip (unique marker) asserting the bytes survive. Runs `mc` inside the `minio` container with the in-container root creds. Non-health-only: a missing bucket or broken object store fails it. | **landed** | +| `custom/test_rustfs_storage.py` | The §4.3 create-an-object + read-it-back, at Drive's storage layer: confirms the `drive-media-storage` RustFS bucket exists, then a real upload → list → download round-trip (unique marker) asserting the bytes survive. Uses the backend's boto3 S3 client with the recipe's RustFS credentials. Non-health-only: a missing bucket or broken object store fails it. | **landed** | | `custom/test_wopi_configured.py` (planned, 3rd beyond floor) | Collabora WOPI discovery XML served + valid over the flattened `collabora-` route — Drive's in-browser office-editing feature. | **planned** | ## Backup data-integrity (P4) — landed diff --git a/tests/lasuite-drive/custom/test_minio_storage.py b/tests/lasuite-drive/custom/test_minio_storage.py deleted file mode 100644 index 345579c..0000000 --- a/tests/lasuite-drive/custom/test_minio_storage.py +++ /dev/null @@ -1,61 +0,0 @@ -"""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}" - ) diff --git a/tests/lasuite-drive/custom/test_rustfs_storage.py b/tests/lasuite-drive/custom/test_rustfs_storage.py new file mode 100644 index 0000000..e7090a3 --- /dev/null +++ b/tests/lasuite-drive/custom/test_rustfs_storage.py @@ -0,0 +1,47 @@ +"""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}" diff --git a/tests/lasuite-drive/ops.py b/tests/lasuite-drive/ops.py index 279d347..0774634 100644 --- a/tests/lasuite-drive/ops.py +++ b/tests/lasuite-drive/ops.py @@ -5,7 +5,6 @@ in the `db` service. The backup path exercises the recipe's pg_backup.sh DB-dump backupbot-labelled).""" import os -import subprocess import sys import time @@ -13,57 +12,6 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "runner") from harness import lifecycle # noqa: E402 -def pre_install(ctx): - """Post-deploy seed for the custom tier (the former post-deploy setup hook, moved here in rcust - P2b — install_steps.sh runs PRE-deploy and cannot touch the live stack). The deploy alone does - NOT create the MinIO bucket: `minio-createbuckets` is a `replicas:0` one-shot (restart_policy: - none) that must be triggered. The MinIO storage test asserts the bucket exists, so trigger it - here and poll. `--detach` is REQUIRED: the job creates the bucket then EXITS 0, so it never - holds a steady 1/1 replica — a blocking scale would wait forever. - - BEST-EFFORT, like the old post-deploy hook it replaced: on poll timeout we WARN and continue - (the one-shot often lands just after the window). The custom-tier MinIO storage test is the - real gate for a genuinely missing bucket — failing the install op here was an rcust M2 - regression (the original hook fell through on timeout by design).""" - stack = ctx.domain.replace(".", "_") - print(" pre_install: creating MinIO bucket via the minio-createbuckets one-shot", flush=True) - subprocess.run( - ["docker", "service", "scale", "--detach", f"{stack}_minio-createbuckets=1"], - capture_output=True, - check=False, - ) - check = ( - 'mc alias set _c http://localhost:9000 "$(cat /run/secrets/minio_ru)" ' - '"$(cat /run/secrets/minio_rp)" >/dev/null 2>&1 && ' - "mc ls _c/drive-media-storage >/dev/null 2>&1" - ) - for i in range(30): - cid = subprocess.run( - ["docker", "ps", "-q", "-f", f"name={stack}_minio.1"], - capture_output=True, - text=True, - check=False, - ).stdout.split() - if cid and ( - subprocess.run( - ["docker", "exec", cid[0], "sh", "-c", check], capture_output=True, check=False - ).returncode - == 0 - ): - print( - f" pre_install: bucket drive-media-storage present after {i + 1} poll(s)", - flush=True, - ) - return - time.sleep(3) - print( - " !! pre_install: minio-createbuckets one-shot did not create drive-media-storage in 90s " - "— continuing (best-effort, as the pre-restructure hook did); the custom-tier MinIO test " - "gates a genuinely missing bucket", - flush=True, - ) - - def _wait_collabora_ready(domain, timeout=420): """Gate the upgrade op on collabora being FULLY ready (WOPI discovery endpoint → 200), not just container 1/1 'running'. coolwsd takes ~2min to boot (pre-reads 1300+ l10n files + RSA keygen); diff --git a/tests/lasuite-drive/recipe_meta.py b/tests/lasuite-drive/recipe_meta.py index f0cd877..1aaa96d 100644 --- a/tests/lasuite-drive/recipe_meta.py +++ b/tests/lasuite-drive/recipe_meta.py @@ -2,7 +2,7 @@ # WOPI office, OIDC-dependent). Sibling of lasuite-docs (same La Suite / impress lineage). # # Stack: app(frontend SPA) + backend(Django/drive) + celery + celery-beat + db(postgres) + redis + -# mailcatcher + minio(S3) + minio-createbuckets(one-shot) + collabora(WOPI office). ~10 services → +# mailcatcher + rustfs(S3) + collabora(WOPI office). ~10 services → # generous timeouts. # # Health: the React SPA is served at `/` by the `app` service and returns 200 unauthenticated @@ -11,7 +11,7 @@ HEALTH_PATH = "/" HEALTH_OK = (200, 301, 302) # This is the heaviest stack in the Phase-2 set: 12 services incl. BOTH office backends # (collabora/code ~1GB + onlyoffice/documentserver ~2GB) plus impress front/backend, postgres, -# minio, redis, nginx. Cold image pull + onlyoffice's multi-minute internal boot exceed the +# rustfs, redis, nginx. Cold image pull + onlyoffice's multi-minute internal boot exceed the # default abra TIMEOUT (300s) and even 900s, so allow a wide window (abra TIMEOUT below stays # under DEPLOY_TIMEOUT so the Python subprocess never kills abra mid-wait). DEPLOY_TIMEOUT = 1800 @@ -27,8 +27,8 @@ DEPS = ["keycloak"] # the orchestrator provisions the per-run realm on the live-warm keycloak BEFORE the single # `abra app deploy`, and tests/lasuite-drive/install_steps.sh writes the OIDC env + client secret # into the .env that one deploy reads. No post-deploy reconverge (the flaky 12-service collabora -# WOPI race is structurally gone). The post-deploy MinIO bucket one-shot lives in ops.py -# pre_install (the former post-deploy setup hook, moved here in P2b). +# WOPI race is structurally gone). The backend initializes the RustFS media bucket at +# startup; the custom S3 test verifies it. def READY_PROBE(ctx): @@ -43,16 +43,12 @@ def READY_PROBE(ctx): def EXTRA_ENV(ctx): - # Two of lasuite-drive's services route on DOMAIN-DERIVED **nested** subdomains — - # `MINIO_DOMAIN="minio.${DOMAIN}"` and `COLLABORA_DOMAIN="collabora.${DOMAIN}"`. The cc-ci - # wildcard TLS cert is `*.ci.commoninternet.net` (single label only), so a 2-label name like - # `minio.lasuite-drive-pr0-abc.ci.commoninternet.net` is NOT covered → TLS failure on those - # routers. Flatten each to a single-label SIBLING under the wildcard (`minio-`, - # `collabora-`) so the existing wildcard cert covers them and Traefik routes them with - # no cert/gateway change. See DECISIONS.md "Phase 2 — nested DOMAIN-derived subdomains". - # `AWS_S3_DOMAIN_REPLACE` derives from MINIO_DOMAIN in-compose, so setting MINIO_DOMAIN is enough. + # Both the published base and PR head use a nested S3 hostname. Flatten + # both names under the wildcard certificate: the base uses MINIO_DOMAIN, + # while the current recipe uses RUSTFS_DOMAIN. return { "MINIO_DOMAIN": f"minio-{ctx.domain}", + "RUSTFS_DOMAIN": f"rustfs-{ctx.domain}", "COLLABORA_DOMAIN": f"collabora-{ctx.domain}", # abra's internal per-deploy convergence timeout (recipe TIMEOUT env, default 300s) is too # short for this 12-service stack on a cold image cache (impress frontend/backend, minio,