From fe41de78272adda97a5f4a23849af9805fdcd789 Mon Sep 17 00:00:00 2001 From: hajdul88 <52442977+hajdul88@users.noreply.github.com> Date: Fri, 10 Oct 2025 13:35:22 +0200 Subject: [PATCH] feat: adds subprocess test frame just to test the GA --- .../workflows/concurrent_subprocess_tests.yml | 67 +++++++++++++++++++ .github/workflows/test_suites.yml | 5 ++ .../test_concurrent_subprocess_access.py | 48 +++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 .github/workflows/concurrent_subprocess_tests.yml create mode 100644 cognee/tests/test_concurrent_subprocess_access.py diff --git a/.github/workflows/concurrent_subprocess_tests.yml b/.github/workflows/concurrent_subprocess_tests.yml new file mode 100644 index 000000000..f0a5459fc --- /dev/null +++ b/.github/workflows/concurrent_subprocess_tests.yml @@ -0,0 +1,67 @@ +name: Concurrent Subprocess Access Tests + +permissions: + contents: read + +on: + workflow_call: + inputs: + databases: + required: false + type: string + default: "all" + description: "Which vector databases to test (comma-separated list or 'all')" + +jobs: + run_concurrent_subprocess_access_test: + name: Concurrent Subprocess access test + runs-on: ubuntu-22.04 + if: ${{ inputs.databases == 'all' || contains(inputs.databases, 'kuzu/pgvector/postgres') }} + services: + postgres: + image: pgvector/pgvector:pg17 + env: + POSTGRES_USER: cognee + POSTGRES_PASSWORD: cognee + POSTGRES_DB: cognee_db + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + - name: Check out + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: ${{ inputs.python-version }} + extra-dependencies: "postgres" + + - name: Dependencies already installed + run: echo "Dependencies already installed in setup" + + - name: Run Concurrent subprocess access test (Kuzu/Lancedb/Postgres) + env: + ENV: dev + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + GRAPH_DATABASE_PROVIDER: 'kuzu' + DB_PROVIDER: 'postgres' + DB_NAME: 'cognee_db' + DB_HOST: '127.0.0.1' + DB_PORT: 5432 + DB_USERNAME: cognee + DB_PASSWORD: cognee + run: uv run python ./cognee/tests/test_concurrent_subprocess_access.py diff --git a/.github/workflows/test_suites.yml b/.github/workflows/test_suites.yml index 2f1bdebf0..567384f16 100644 --- a/.github/workflows/test_suites.yml +++ b/.github/workflows/test_suites.yml @@ -22,6 +22,11 @@ jobs: uses: ./.github/workflows/basic_tests.yml secrets: inherit + concurrent-subprocess-tests: + name: Concurrent subprocess tests + uses: ./.github/workflows/concurrent_subprocess_tests.yml + secrets: inherit + e2e-tests: name: End-to-End Tests uses: ./.github/workflows/e2e_tests.yml diff --git a/cognee/tests/test_concurrent_subprocess_access.py b/cognee/tests/test_concurrent_subprocess_access.py new file mode 100644 index 000000000..d9c178433 --- /dev/null +++ b/cognee/tests/test_concurrent_subprocess_access.py @@ -0,0 +1,48 @@ +import os +import asyncio +import cognee +import pathlib + +from cognee.infrastructure.databases.graph import get_graph_engine +from collections import Counter +from cognee.modules.users.methods import get_default_user +from cognee.shared.logging_utils import get_logger + +logger = get_logger() + + +async def test_concurrent_subprocess_access(): + data_directory_path = str( + pathlib.Path( + os.path.join(pathlib.Path(__file__).parent, ".data_storage/concurrent_tasks") + ).resolve() + ) + cognee_directory_path = str( + pathlib.Path( + os.path.join(pathlib.Path(__file__).parent, ".cognee_system/concurrent_tasks") + ).resolve() + ) + + cognee.config.data_root_directory(data_directory_path) + cognee.config.system_root_directory(cognee_directory_path) + + await cognee.prune.prune_data() + await cognee.prune.prune_system(metadata=True) + + basic_nested_edges = ["is_a", "is_part_of", "contains", "made_from"] + + entity_to_entity_edges = ["likes", "prefers", "watches"] + + text1 = "Dave watches Dexter Resurrection" + text2 = "Ana likes apples" + text3 = "Bob prefers Cognee over other solutions" + + await cognee.add([text1, text2, text3], dataset_name="edge_ingestion_test") + + user = await get_default_user() + + await cognee.cognify(["edge_ingestion_test"], user=user) + + +if __name__ == "__main__": + asyncio.run(test_concurrent_subprocess_access())