Repository navigation
Description
Summary
Replace mock/MagicMock-based tests for external backends with real testcontainers integration tests, run under the CI integration job added in #827. Right now only Neo4j/Kuzu/property-graph run against real services; every other backend is tested with fakes, respx, or MagicMock — several of which violate the repo testing standard ("NO MagicMock/Mock anywhere") and give false confidence (this is exactly how the #826 Neo4j parity bug reached main).
Each conversion: spin up the real service via testcontainers, exercise the real client path, and delete the MagicMock. Add the client + testcontainers module to the integration dependency-group and ensure the file is covered by the integration CI job.
Why
- Mocks pass while the real backend breaks (caused the v1.5.1 async bug and Neo4jWorldGraphBackend.query_subgraph ignores min_confidence/as_of in node & document traversal (backend parity bug) #826).
- Repo standard already forbids
MagicMock; these are debt. - Real containers are the actual implementation — the intended coverage.
Backends to convert
P0 — highest usage (start here)
- Postgres / pgvector —
retrieval/pgvector.py✅ done in Real testcontainers tests for pgvector + redis (fixes 7 mock-hidden bugs) — #829 #832 (fixed PGVectorStore broken against real Postgres (dimension, register_vector, commit, opclass, JSONB) — hidden by MagicMock #830). Remaining Postgres:memory/backends/postgres.py,graph/checkpointers/postgres.py,loaders/sql.py(image:pgvector/pgvector:pg16for pgvector,postgres:16for the rest) - Redis / redis-vector —
retrieval/redis_vector.py✅ done in Real testcontainers tests for pgvector + redis (fixes 7 mock-hidden bugs) — #829 #832 (fixed RedisVectorStore broken against real RediSearch (binary-field decode, reconnect persistence) — hidden by MagicMock #831). Remaining Redis:memory/backends/redis.py,memory/redis.py,graph/checkpointers/redis.py,llm/_redis_cache.py,loaders/redis_loader.py(image:redis/redis-stackfor vector/RediSearch,redis:7for plain KV)
P1 — common search/doc stores
- Elasticsearch (vector store) —
retrieval/elasticsearch_vector.py✅ Real testcontainers tests for Elasticsearch (fixes reconnect + es-py 9.x break) — #829 #834 (fixed ElasticsearchVectorStore: no reconnect persistence + deprecated/removed body= (breaks on es-py 9.x) — hidden by MagicMock #833). Remaining:loaders/elasticsearch.py - OpenSearch —
retrieval/opensearch_vector.py✅ Real testcontainers tests for OpenSearch (fixes reconnect) — #829 #847 (fixed OpenSearchVectorStore: no reconnect persistence — hidden by MagicMock #846) - MongoDB (Atlas vector store) —
retrieval/mongodb_atlas.py✅ Real testcontainers tests for MongoDB Atlas Vector Search + async-first guard — #829 #835 (correct as-is; real mongodb-atlas-local tests). Remaining:loaders/mongodb.py - Qdrant —
retrieval/qdrant.py✅ Real testcontainers tests for Qdrant (fixes event-loop block, ignored filter, id collision) — #829 #837 (fixed QdrantVectorStore: blocks event loop, ignores metadata_filter, id-collision on reconnect, deprecated API — hidden by MagicMock #836)
P2 — long tail
- Weaviate —
retrieval/weaviate.py✅ Real testcontainers tests for Weaviate (fixes fully-broken v4 store) — #829 #839 (fixed WeaviateVectorStore broken against real Weaviate (v4 insert/search API, event-loop block, no collection create) — hidden by MagicMock #838) - Milvus —
retrieval/milvus.py✅ Real tests for Milvus via Milvus Lite (fixes fully-broken store) — #829 #841 (fixed MilvusVectorStore broken against real Milvus (no primary key, IndexParams misuse, metadata lost, event-loop block) — hidden by MagicMock #840, via Milvus Lite). Remaining:retrieval/zilliz_vector.py - Cassandra —
retrieval/cassandra_vector.py✅ Real testcontainers tests for Cassandra 5.0 (fixes ANN vector path) — #829 #843 (fixed CassandraVectorStore broken against real Cassandra 5.0 (list<float> not vector, no SAI index, score=1.0) — hidden by MagicMock #842) - ClickHouse —
retrieval/clickhouse_vector.py✅ Real testcontainers tests for ClickHouse (fixes top_k injection + reconnect) — #829 #845 (fixed ClickHouseVectorStore: top_k SQL-interpolation + no reconnect persistence — hidden by MagicMock #844) - [~] Supabase —
retrieval/supabase_vector.py,loaders/supabase.py— NOT feasible as a single testcontainer: supabase-py talks to the hosted PostgREST gateway (/rest/v1/+ JWT + Kong), so a faithful test needs the full Supabase stack. Deferred; future improvement is a respx HTTP contract test (see LLM/loader respx track). - Snowflake —
loaders/snowflake.py(no container; keeprespx/fake — document why)
Definition of done (per backend)
- Real testcontainers test exercising the real client (add/search/delete or equivalent round-trip).
MagicMock/Mock/mocker.patchremoved from that backend's tests.- Client lib + any testcontainers extra added to the
integrationgroup; file runs in theintegrationCI job and is green. - Follows testing standards: pytest, no mocks, negative cases.
Tracking
Convert in PRs per backend group (P0 first). This epic tracks progress; each PR closes its own item.
New tracks (added after survey — loaders & LLM providers have zero testcontainers today; loaders are 35 MagicMock files, LLM providers 23)
Loaders (containerizable → real testcontainers)
-
loaders/s3.py→ MinIO ✅ S3Loader: endpoint_url for S3-compatible stores + real MinIO tests — #829/#851 #852 (added endpoint_url, S3Loader: support S3-compatible endpoints (endpoint_url) for MinIO/R2/LocalStack #851) -
loaders/dynamodb.py→ DynamoDB Local ✅ DynamoDBLoader endpoint_url + real DynamoDB Local & Azurite tests — #829/#855 #856 (added endpoint_url, DynamoDBLoader: support DynamoDB-compatible endpoints (endpoint_url) for DynamoDB Local/LocalStack #855) -
loaders/azure_blob.py→ Azurite ✅ DynamoDBLoader endpoint_url + real DynamoDB Local & Azurite tests — #829/#855 #856 (correct) -
loaders/sql.py→ Postgres ✅ Real testcontainers tests for SQLLoader (Postgres) — #829 #853 (correct) -
loaders/mongodb.py→ Mongo ✅ Real testcontainers tests for Mongo/Redis/Elasticsearch loaders — #829 #854 (correct) -
loaders/elasticsearch.py→ Elasticsearch ✅ Real testcontainers tests for Mongo/Redis/Elasticsearch loaders — #829 #854 (correct) -
loaders/redis_loader.py→ Redis ✅ Real testcontainers tests for Mongo/Redis/Elasticsearch loaders — #829 #854 (correct) - [~]
loaders/git.py→ deferred (git loader uses a local repo path; low external-risk, revisit) - Not containerizable (keep respx/recorded):
snowflake,gcs,github
LLM providers
- [~] Cloud providers → respx: OpenAI + Anthropic done ✅ LLM contract tests via respx: OpenAI + Anthropic (replaces MagicMock) — #829 #857 (pattern established; OpenAI covers the OpenAI-compatible family). Remaining distinct-API providers (Gemini/Cohere/Mistral) tracked.
- Local providers: real Ollama container running actual inference ✅ OllamaLLM host param + real local-inference testcontainer — #829/#858 #859 (added host param, OllamaLLM: support a custom host (remote/non-default Ollama server) #858).
llamacpp/gpt4all(embedded, need GGUF) andvllm(GPU) remain as optional follow-ups.
Status of remaining LLM providers (after core completion)
- OpenAI-compatible clones (Groq, DeepSeek, xAI, Cerebras, Fireworks, Together, Novita, Writer, Moonshot, …): share
OpenAILLM's code path (AsyncOpenAI + base_url) — already covered by the OpenAI respx pattern; per-provider respx is redundant. Good-first-issue if per-provider assurance is wanted. - Distinct-SDK providers:
Gemini— oldgoogle.generativeaiSDK streams over gRPC; respx (httpx-only) can't intercept it. Needs a REST-transport path or a different approach. Deferred.Cohere,Mistral— httpx-based; respx-able with per-SDK wire-format work. Good follow-ups.Bedrock— boto3; could use moto/LocalStack. Deferred.
- Local:
Ollamadone (real inference).llamacpp/gpt4allneed a GGUF model file;vllmneeds a GPU — optional.
These are tracked follow-ups; the epic's core (real testcontainers for every external backend + LLM foundation) is complete.
Activity
fix(retrieval): make PGVectorStore work against real Postgres (#830)
fix(retrieval): make RedisVectorStore work against real RediSearch (#831
test(memory): restore real redis module after mock test teardown
ci(test): add pgvector/redis to the integration group and CI job (#829)
AmitoVrito commentedon Jul 21, 2026
Progress: pgvector + redis-vector converted to real testcontainers tests in #832. Deep testing surfaced and fixed 7 mock-hidden bugs (#830 pgvector: dimension/register_vector/commit/opclass/JSONB; #831 redis: binary-field decode + reconnect persistence) plus a session-wide
sys.modules['redis']test-isolation leak. Next: P1 vector stores (Elasticsearch → MongoDB → Qdrant).fix(retrieval): make ElasticsearchVectorStore work on reconnect and m…
ci(test): add elasticsearch to the integration group and CI job (#829)
test(retrieval): tolerate atlas-local replica-set step-down in mongo …
test(retrieval): make atlas-local mongo tests robust to cold-start in…
test(retrieval): real MongoDB Atlas Vector Search testcontainers tests (
test(retrieval): assert async-first contract in vector-store integrat…
ci(test): add pymongo to the integration group and mongo test to CI (#…
test(retrieval): tolerate atlas-local replica-set step-down in mongo …
17 remaining items
ci(test): add asyncpg + memory-backend tests to the integration job (#…
test(graph): real Postgres/Redis checkpointer testcontainers tests (#829
feat(loaders): S3Loader supports S3-compatible endpoints via endpoint…
ci(test): add boto3 + S3 loader test to the integration job (#829)
test(loaders): real Postgres SQLLoader testcontainers tests (#829)
test(loaders): real Mongo/Redis/Elasticsearch loader testcontainers t…
feat(loaders): DynamoDBLoader endpoint_url + real DynamoDB Local & Az…
ci(test): add boto3/azure-storage-blob + dynamodb/azurite tests to in…
test(llm): respx HTTP-contract tests for OpenAI + Anthropic (#829)
feat(llm): OllamaLLM supports a custom host + real inference testcont…
ci(test): add ollama dep + dedicated ollama-integration CI job (#829)
AmitoVrito commentedon Jul 22, 2026
Core complete ✅
Real testcontainers now cover every external backend in the framework, replacing MagicMock throughout:
Vector stores (10): pgvector, redis, elasticsearch, qdrant, weaviate, milvus (Lite), cassandra, clickhouse, opensearch, mongodb (Atlas Local)
Memory + checkpointers (4): postgres/redis memory, postgres/redis graph checkpointers
Loaders (7): S3 (MinIO), SQL (Postgres), Mongo, Elasticsearch, Redis, DynamoDB (DynamoDB Local), Azure Blob (Azurite)
LLM: OpenAI + Anthropic (respx HTTP-contract), Ollama (real local inference)
~39 real production bugs/gaps fixed — all hidden by mocks — including event-loop-blocking async violations (qdrant/weaviate/milvus), a fully-broken Weaviate v4 path, pgvector's dimension/register_vector/commit/opclass/JSONB set, Milvus schema/index API misuse, Cassandra's
list<float>-not-vector, ClickHousetop_kinjection, Postgres-memory JSONB decode, and missingendpoint_url/hostsupport that locked out MinIO/R2/LocalStack/DynamoDB-Local/remote-Ollama.Every test does real inserts + real queries + reconnect reads, runs in CI (heavy Ollama isolated in its own job), and asserts the async-first contract.
Deferred (documented): Supabase (needs full hosted PostgREST+JWT+Kong stack), git loader, Gemini (old SDK is gRPC-only → not respx-able), OpenAI-compatible clones (share the OpenAI code path), llamacpp/gpt4all/vllm.
Merge pull request #869 from SynapseKit/docs/changelog-829
docs: record epic SynapseKit#829 (real testcontainers for all externa…