Refactor CI and runtime images to two-stage builds

This commit is contained in:
copilotcoder
2026-07-06 10:29:31 -04:00
parent 1f6cafa1bc
commit 7c06fa3474
14 changed files with 1279 additions and 2371 deletions

View File

@@ -0,0 +1,55 @@
"""Runtime black-box integration tests executed over the container network."""
from __future__ import annotations
import json
import os
import urllib.error
import urllib.request
import pytest
BACKEND_BASE_URL = os.getenv("INTEGRATION_BACKEND_URL", "http://backend:8000").rstrip(
"/"
)
def _fetch(path: str) -> tuple[int, str]:
"""Fetch an endpoint and return status code and body text."""
url = f"{BACKEND_BASE_URL}{path}"
request = urllib.request.Request(url=url, method="GET")
try:
with urllib.request.urlopen(request, timeout=5) as response:
body = response.read().decode("utf-8", errors="replace")
return response.status, body
except urllib.error.HTTPError as exc:
body = exc.read().decode("utf-8", errors="replace")
return exc.code, body
@pytest.mark.integration
def test_root_endpoint_runtime() -> None:
"""Runtime root endpoint should return backend API message."""
status, body = _fetch("/")
assert status == 200
payload = json.loads(body)
assert payload == {"message": "Plex Playlist Backend API"}
@pytest.mark.integration
def test_health_endpoint_runtime() -> None:
"""Runtime health endpoint should report healthy database connectivity."""
status, body = _fetch("/health")
assert status == 200
payload = json.loads(body)
assert payload.get("status") == "healthy"
assert payload.get("database") == "connected"
@pytest.mark.integration
def test_compatibility_endpoint_runtime() -> None:
"""Runtime compatibility endpoint should report policy check success."""
status, body = _fetch("/compatibility")
assert status == 200
payload = json.loads(body)
assert payload.get("ok") is True