"""Smoke test - verify all infrastructure is reachable and indices are present. Exits non-zero on first hard error. """ from __future__ import annotations import sys from sqlalchemy import text from app.db.session import get_engine from app.indexing.opensearch_client import ensure_index, get_opensearch from app.indexing.qdrant_client import ensure_collection, get_qdrant from app.logging_config import configure_logging, get_logger from app.storage.minio_client import get_storage configure_logging() logger = get_logger(__name__) def main() -> int: failures: list[str] = [] # Postgres try: with get_engine().connect() as conn: conn.execute(text("SELECT 1")) print("[ok] postgres") except Exception as exc: # noqa: BLE001 failures.append(f"postgres: {exc}") print(f"[err] postgres: {exc}") # MinIO try: s = get_storage() s.ensure_buckets() info = s.health() if info.get("status") != "ok": raise RuntimeError(info) print("[ok] minio:", info.get("buckets")) except Exception as exc: # noqa: BLE001 failures.append(f"minio: {exc}") print(f"[err] minio: {exc}") # OpenSearch try: ensure_index() info = get_opensearch().cluster.health() print("[ok] opensearch:", info.get("status")) except Exception as exc: # noqa: BLE001 failures.append(f"opensearch: {exc}") print(f"[err] opensearch: {exc}") # Qdrant try: ensure_collection() cols = [c.name for c in get_qdrant().get_collections().collections] print("[ok] qdrant collections:", cols) except Exception as exc: # noqa: BLE001 failures.append(f"qdrant: {exc}") print(f"[err] qdrant: {exc}") if failures: print("\nSMOKE FAIL:") for f in failures: print(" -", f) return 1 print("\nSMOKE OK") return 0 if __name__ == "__main__": sys.exit(main())