"""`/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