# Testing and validation ## Test layers | Layer | Coverage | |---|---| | Unit | settings, source validation, chunk constraints, reconciliation, provider retry policy | | Integration | all ten stages, API/worker jobs, repair/retry/resume | | PostgreSQL integration | migrations, PgVector extension, HNSW index, graph retrieval, advisory lock | | Performance | configurable vector query load against real PostgreSQL | The deterministic `FakeLLM` in `tests/conftest.py` keeps portable tests repeatable. It is not a quality or latency substitute for a production model. ## Local validation ```powershell pytest --ignore=.\tests\integration\test_pgvector_postgres.py python -m compileall -q src tests migrations python -m pip check ``` The CI workflow also validates Compose configuration and builds the `Containerfile` image. ## PostgreSQL integration Set `TEST_POSTGRES_URL` to a PgVector-enabled database. The migration test resets the schema, creates the external source table, runs stages 1-9, checks the vector extension and HNSW definition, and verifies advisory-lock behavior. ## Performance benchmark The benchmark is skipped unless both `TEST_POSTGRES_URL` and `RUN_PERFORMANCE_TESTS=1` are set: ```powershell $env:TEST_POSTGRES_URL = "postgresql+psycopg://knowledgegraph_app:password@localhost:5432/knowledgegraph" $env:RUN_PERFORMANCE_TESTS = "1" $env:PERF_VECTOR_ITEM_COUNT = "10000" $env:PERF_MAX_QUERY_SECONDS = "2.0" pytest .\tests\performance\test_vector_query_load.py -m performance ``` The benchmark inserts deterministic three-dimensional vectors and measures stage 9 retrieval. Results depend on hardware, database configuration, and load.