confluence_web/tests/integration/crash_server.py
Artur Mukhamadiev d77b52ae86 integration: contract checks, error mapping, deployment entry points
- tests/integration: frontend served by backend, runtime error mapping,
  backend + real pi image with scripted model/Confluence (shared example,
  variants, failure paths, cancellation/busy gate, isolation canaries,
  HTTP download ownership, 16 MiB prompt round trip), real OpenAI-compatible
  adapter + real image over a scripted transport, real Chrome against the
  real backend with a scripted runtime peer, backend crash/restart
  reconciliation, and an opt-in live model check (marker: live).
- backend: map runtime terminal codes (model_output_limit,
  model_context_exceeded, query_timeout, connectivity_failed) to the
  contract's HTTP statuses; make the artifact 404 body identical for
  no-session, wrong-session, unknown and expired IDs.
- Makefile, scripts/run-backend.sh, deploy/confluence-web.env.example,
  root README for the integrated application; integration pytest marker.
2026-09-14 22:20:34 +03:00

49 lines
1.5 KiB
Python

"""Test-owned launcher: real backend + real runtime image with a stalling model.
Used by the backend-crash / restart-reconciliation check. Confluence is the
scripted transport; the model stalls so a container stays alive while the
backend process is killed.
"""
from __future__ import annotations
import asyncio
import os
from pathlib import Path
import uvicorn
from backend.app import create_app
from backend.artifacts import ArtifactStore
from backend.model import FakeModelAdapter
from backend.settings import Settings
from tests.integration.conftest import APPROVED_ORIGIN, RUNTIME_IMAGE, make_confluence_factory
class StallingModel(FakeModelAdapter):
async def complete(self, messages, tools, system_instruction, provider_state_meta=None):
await asyncio.sleep(600)
raise AssertionError("unreachable")
def main() -> None:
settings = Settings(
runtime_image=RUNTIME_IMAGE,
approved_confluence_origins=[APPROVED_ORIGIN],
container_label_value=os.environ["CW_LABEL_VALUE"],
artifact_storage_dir=Path(os.environ["CW_ARTIFACT_DIR"]),
query_timeout_seconds=170.0,
)
app = create_app(
settings=settings,
artifact_store=ArtifactStore(settings.artifact_storage_dir),
model_adapter=StallingModel(),
confluence_client_factory=make_confluence_factory(),
)
uvicorn.run(app, host="127.0.0.1", port=int(os.environ["CW_DEV_PORT"]), workers=1, log_level="warning")
if __name__ == "__main__":
main()