fix: use docker qdrant for tests

This commit is contained in:
Boris Arzentar 2025-06-05 15:07:37 +02:00
parent f58a8edac6
commit 5472975557
No known key found for this signature in database
GPG key ID: D5CC274C784807B7
3 changed files with 27 additions and 6 deletions

View file

@ -135,6 +135,21 @@ jobs:
run:
shell: bash
services:
qdrant:
image: qdrant/qdrant:1.14.1
env:
QDRANT__LOG_LEVEL: ERROR
QDRANT__SERVICE__API_KEY: qdrant_api_key
QDRANT__SERVICE__ENABLE_TLS: 0
options: >-
--health-cmd "curl 127.0.0.1:6333 || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6333:6333
steps:
- name: Check out
uses: actions/checkout@master
@ -159,8 +174,8 @@ jobs:
EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }}
EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }}
EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }}
VECTOR_DB_URL: ${{ secrets.QDRANT_API_URL }}
VECTOR_DB_KEY: ${{ secrets.QDRANT_API_KEY }}
VECTOR_DB_URL: 127.0.0.1
VECTOR_DB_KEY: qdrant_api_key
run: poetry run python ./cognee/tests/test_qdrant.py
run-postgres-tests:

View file

@ -1,3 +1,4 @@
import os
from typing import Dict, List, Optional
from qdrant_client import AsyncQdrantClient, models
@ -147,14 +148,15 @@ class QDrantAdapter(VectorDBInterface):
Returns:
--------
- AsyncQdrantClient: An instance of AsyncQdrantClient configured for database
operations.
"""
is_prod = os.getenv("ENV").lower() == "prod"
if self.qdrant_path is not None:
return AsyncQdrantClient(path=self.qdrant_path, port=6333)
return AsyncQdrantClient(path=self.qdrant_path, port=6333, https=is_prod)
elif self.url is not None:
return AsyncQdrantClient(url=self.url, api_key=self.api_key, port=6333)
return AsyncQdrantClient(url=self.url, api_key=self.api_key, port=6333, https=is_prod)
return AsyncQdrantClient(location=":memory:")

View file

@ -49,7 +49,11 @@ async def main():
from cognee.infrastructure.databases.vector import get_vector_engine
vector_engine = get_vector_engine()
random_node = (await vector_engine.search("Entity_name", "Quantum computer"))[0]
search_results = await vector_engine.search("Entity_name", "Quantum computer")
assert len(search_results) != 0, "The search results list is empty."
random_node = search_results[0]
random_node_name = random_node.payload["text"]
search_results = await cognee.search(