Skip to content

Commit

Permalink
tests: Add more verbosity to test runs by logging neo4j docker contai…
Browse files Browse the repository at this point in the history
…ner details
  • Loading branch information
prosto committed Feb 29, 2024
1 parent e8d2e63 commit 9f3529b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

runs-on: ${{ matrix.os }}

name: Python ${{ matrix.python-version }} test on Neo4j:${{ matrix.python-version }} OS:${{ matrix.os }}
name: Python ${{ matrix.python-version }} test on Neo4j:${{ matrix.neo4j-version }} OS:${{ matrix.os }}

steps:
- name: Check out repository
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ markers = [
"integration: integration tests",
"neo4j: requires Neo4j container",
]
log_cli = true
log_cli_level = "INFO"


[tool.hatch.envs.docs]
template = "docs"
Expand Down
10 changes: 9 additions & 1 deletion tests/neo4j_haystack/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
import os
import socket
import time
Expand All @@ -20,6 +21,8 @@
NEO4J_PORT = 7689
EMBEDDING_DIM = 768

logger = logging.getLogger("conftest")


@pytest.fixture
def documents() -> List[Document]:
Expand Down Expand Up @@ -99,6 +102,7 @@ def neo4j_database():
"""
neo4j_port = _get_free_tcp_port()
neo4j_version = os.environ.get("NEO4J_VERSION", "neo4j:5.13.0")
neo4j_container = f"test_neo4j_haystack-{neo4j_port}"

config = Neo4jClientConfig(
f"bolt://localhost:{neo4j_port}", database="neo4j", username="neo4j", password="passw0rd"
Expand All @@ -111,7 +115,7 @@ def neo4j_database():
environment={
"NEO4J_AUTH": f"{config.username}/{config.password}",
},
name=f"test_neo4j_haystack-{neo4j_port}",
name=neo4j_container,
ports={"7687/tcp": ("127.0.0.1", neo4j_port)},
detach=True,
remove=True,
Expand All @@ -122,8 +126,12 @@ def neo4j_database():
if not _connection_established(db_driver):
pytest.exit("Could not startup neo4j docker container and establish connection with database")

logger.info(f"Started neo4j docker container: {neo4j_container}, image: {neo4j_version}, port: {neo4j_port}")

yield config

logger.info(f"Stopping neo4j docker container: {neo4j_container}")

db_driver.close()
container.stop()

Expand Down

0 comments on commit 9f3529b

Please sign in to comment.