From ed6e8eb0d2856e0be10c01a0982669d86654be13 Mon Sep 17 00:00:00 2001 From: Boris Arzentar Date: Tue, 6 Aug 2024 16:11:48 +0200 Subject: [PATCH] fix: wait for postgres to be ready before tests --- .github/workflows/test_common.yml | 6 ++++++ .github/workflows/test_neo4j.yml | 14 +++++++------- .github/workflows/test_qdrant.yml | 7 +++++++ .github/workflows/test_weaviate.yml | 6 ++++++ .../databases/graph/neo4j_driver/adapter.py | 3 ++- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 7ce0fb99c..d0f14a61e 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -98,6 +98,12 @@ jobs: mkdir .cognee_system echo $(pwd)/.cognee_system + - name: Wait for PostgreSQL to be ready + run: | + echo "Waiting for PostgreSQL to be ready..." + until pg_isready -h localhost -p 5432 -U cognee; do + sleep 1 + done - name: Run tests run: poetry run pytest tests/ diff --git a/.github/workflows/test_neo4j.yml b/.github/workflows/test_neo4j.yml index 3e04bcaa8..c2d04a467 100644 --- a/.github/workflows/test_neo4j.yml +++ b/.github/workflows/test_neo4j.yml @@ -63,13 +63,6 @@ jobs: virtualenvs-in-project: true installer-parallel: true - - name: Wait for PostgreSQL to be ready - run: | - echo "Waiting for PostgreSQL to be ready..." - until pg_isready -h localhost -p 5432 -U cognee; do - sleep 1 - done - - name: Install dependencies run: poetry install --no-interaction @@ -78,6 +71,13 @@ jobs: mkdir .cognee_system echo $(pwd)/.cognee_system + - name: Wait for PostgreSQL to be ready + run: | + echo "Waiting for PostgreSQL to be ready..." + until pg_isready -h localhost -p 5432 -U cognee; do + sleep 1 + done + - name: Run default Neo4j env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} diff --git a/.github/workflows/test_qdrant.yml b/.github/workflows/test_qdrant.yml index b35ee1f2e..b291be771 100644 --- a/.github/workflows/test_qdrant.yml +++ b/.github/workflows/test_qdrant.yml @@ -71,6 +71,13 @@ jobs: mkdir .cognee_system echo $(pwd)/.cognee_system + - name: Wait for PostgreSQL to be ready + run: | + echo "Waiting for PostgreSQL to be ready..." + until pg_isready -h localhost -p 5432 -U cognee; do + sleep 1 + done + - name: Run default Qdrant env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} diff --git a/.github/workflows/test_weaviate.yml b/.github/workflows/test_weaviate.yml index 48cc63c52..6534050be 100644 --- a/.github/workflows/test_weaviate.yml +++ b/.github/workflows/test_weaviate.yml @@ -71,6 +71,12 @@ jobs: mkdir .cognee_system echo $(pwd)/.cognee_system + - name: Wait for PostgreSQL to be ready + run: | + echo "Waiting for PostgreSQL to be ready..." + until pg_isready -h localhost -p 5432 -U cognee; do + sleep 1 + - name: Run default Weaviate env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} diff --git a/cognee/infrastructure/databases/graph/neo4j_driver/adapter.py b/cognee/infrastructure/databases/graph/neo4j_driver/adapter.py index 1c55f1e39..e7ccfb917 100644 --- a/cognee/infrastructure/databases/graph/neo4j_driver/adapter.py +++ b/cognee/infrastructure/databases/graph/neo4j_driver/adapter.py @@ -21,7 +21,8 @@ class Neo4jAdapter(GraphDBInterface): ): self.driver = driver or AsyncGraphDatabase.driver( graph_database_url, - auth = (graph_database_username, graph_database_password) + auth = (graph_database_username, graph_database_password), + max_connection_lifetime = 120 ) async def close(self) -> None: