Files
cc-ci/tests/ghost/functional/test_content_api.py
autonomic-bot 1bd7c7a1d3 feat(2): Q4.4 ghost + DEPLOY_TIMEOUT plumb-through for heavy recipes
Harness change (small, surgical):
- runner/harness/lifecycle.deploy_app gains a deploy_timeout param (default 900s); passes
  through to abra.deploy(timeout=...). For heavy recipes (ghost, matrix-synapse, lasuite-meet),
  the orchestrator + dep resolver now read recipe_meta.DEPLOY_TIMEOUT and pass it so the Python
  subprocess wrapping abra deploy doesn't SIGKILL it before the recipe's INTERNAL TIMEOUT
  (via EXTRA_ENV) finishes swarm convergence.
- runner/run_recipe_ci.py + runner/harness/deps.py: thread recipe_meta.DEPLOY_TIMEOUT into
  the per-recipe deploy_app call.

Q4.4 ghost enrollment:
- recipe_meta.py: HEALTH_PATH=/, DEPLOY_TIMEOUT=1200 (subprocess), EXTRA_ENV={TIMEOUT: 1200}
  (recipe internal). Ghost cold-start with theme + DB migration runs ~12-15min on cc-ci.
- functional/test_health_check.py: GET / returns 200 (themed site).
- functional/test_content_api.py: GET /ghost/api/content/settings/ returns 200 (settings JSON)
  or 401/403 (Ghost error envelope) — distinguishes ghost-server up + JSON API working from
  static fallback.
- functional/test_admin_redirect.py: GET /ghost/ returns 200 or 302 + Ghost branding;
  proves admin route is wired through nginx proxy.
- PARITY.md: recipe-maintainer corpus has no ghost tests/, Phase-2 health_check is the
  parity baseline; create-a-post deeper test deferred (DEFERRED.md, --extra-tests linked).

Cold-verifiable (log /root/ccci-q44-ghost-r3.log):
  RECIPE=ghost STAGES=install,custom cc-ci-run runner/run_recipe_ci.py
  install + 3 functional tests PASS, deploy-count=1. 28/28 unit tests still PASS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 17:23:40 +01:00

45 lines
1.9 KiB
Python

"""ghost — recipe-specific functional test (Phase 2 P3).
Ghost exposes a public JSON Content API at `/ghost/api/content/settings/` which returns the
site's public configuration (title, description, etc.) WITHOUT requiring an API key for the
basic settings endpoint. Some Ghost versions DO require a key here — accept either:
- 200 with JSON envelope: API alive + accessible.
- 401/403 with JSON error: API alive + correctly gating.
Distinguishes "ghost-server JS process is up + serving its API" from "a static page is served
at /" (which the parity test catches by 200).
A wedged Ghost backend returns 502/504 or 503. A misrouted nginx returns 404.
"""
from __future__ import annotations
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner"))
from harness import http as harness_http # noqa: E402
def test_content_api_settings_endpoint(live_app):
"""GET /ghost/api/content/settings/ → 200 or 401/403; JSON shape."""
url = f"https://{live_app}/ghost/api/content/settings/"
status, body = harness_http.retry_http_get(
url, expect_status=(200, 400, 401, 403), max_wait=60, interval=3
)
assert status in (200, 400, 401, 403), (
f"GET {url} HTTP {status} (expected 200/401/403, NOT 404/5xx — 404=route missing, "
f"5xx=backend broken)"
)
# The API ALWAYS returns JSON (success or error envelope).
assert body is not None, f"GET {url} returned non-JSON body"
# On success: {"settings": {...}}. On error: {"errors": [...]}. Either shape is valid.
if status == 200:
assert isinstance(body, dict) and "settings" in body, (
f"200 response missing 'settings' envelope: {body!r}"
)
else:
assert isinstance(body, dict) and ("errors" in body or "message" in body or body), (
f"error response not a proper Ghost error envelope: {body!r}"
)