Files
chatbot_v3/tests/integration/qdrant/test_readiness.py
Ali Zarinkolah fa933b08ff fix(qdrant): verify collection existence in the readiness check
Why:
- The chunks collection is now created by an explicit deployment step
  (qdrant_bootstrap), not at startup, which means a process can boot against
  a healthy Qdrant that has no collection at all. /readyz's previous check
  only called get_collections(), so it reported ready in that state — the
  misconfiguration stayed invisible until the first upload failed with a 502
  after already paying for the MinIO write and embedding round trips.

Changes:
- ping_qdrant() now checks collection_exists(collection) instead of just
  reachability.
2026-08-20 18:17:56 +03:30

46 lines
1.6 KiB
Python

"""`/readyz`'s Qdrant probe against a real Qdrant.
The case worth an integration test is the one a fake cannot produce
convincingly: Qdrant is up and answering, but the collection the deployment
step was supposed to create is not there.
"""
import uuid
import pytest
from qdrant_client import AsyncQdrantClient
from src.config import QdrantSettings
from src.infrastructure.qdrant.client import ping
from src.infrastructure.qdrant.collection import ensure_chunks_collection
pytestmark = [
pytest.mark.integration,
pytest.mark.qdrant,
pytest.mark.asyncio(loop_scope="session"),
]
async def test_ping_is_not_ready_when_the_collection_was_never_bootstrapped(
qdrant_client: AsyncQdrantClient, qdrant_settings: QdrantSettings
) -> None:
"""A healthy Qdrant with no collection is *not* ready: uploads would 502."""
assert await ping(qdrant_client, 5.0, collection=qdrant_settings.collection) is False
async def test_ping_is_ready_after_bootstrap(
qdrant_client: AsyncQdrantClient, qdrant_settings: QdrantSettings
) -> None:
await ensure_chunks_collection(qdrant_client, collection=qdrant_settings.collection)
assert await ping(qdrant_client, 5.0, collection=qdrant_settings.collection) is True
async def test_ping_is_not_ready_for_a_different_collection_name(
qdrant_client: AsyncQdrantClient, qdrant_settings: QdrantSettings
) -> None:
"""A misconfigured QDRANT_COLLECTION is as unready as a missing one."""
await ensure_chunks_collection(qdrant_client, collection=qdrant_settings.collection)
assert await ping(qdrant_client, 5.0, collection=f"absent_{uuid.uuid4().hex}") is False