Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare for neo4j 4.4 #690

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
python-version: ["3.10"]
env:
PIP_INDEX_URL: https://pypi.sunet.se/simple/
NEO4J_VERSION: 4.0-enterprise
NEO4J_VERSION: 4.4-enterprise

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .jenkins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ pre_build_script:
- "docker pull docker.sunet.se/eduid/redis:latest"
- "docker pull docker.sunet.se/eduid/mongodb:latest"
- "docker pull docker.sunet.se/eduid/smtpdfix:latest"
- "docker pull neo4j:4.0-enterprise"
- "docker pull neo4j:4.4-enterprise"
# pillow requires libjpeg and gs
- "apt-get install -y libjpeg-dev libfreetype6-dev ghostscript libcairo2-dev"
environment_variables:
NEO4J_VERSION: "4.0-enterprise"
NEO4J_VERSION: "4.4-enterprise"
script:
- "python3.10 -m venv venv"
- ". venv/bin/activate"
Expand Down
14 changes: 11 additions & 3 deletions src/eduid/graphdb/groupdb/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,20 @@ def db_setup(self):
"CREATE CONSTRAINT ON (n:User) ASSERT n.identifier IS UNIQUE",
# Replaced by CREATE CONSTRAINT [name] FOR (node:Label) REQUIRE node.prop IS UNIQUE
]
for statment in statements:
for statement in statements:
try:
session.run(statment)
session.run(statement)
except ClientError as e:
assert e.message is not None # please mypy
if "An equivalent constraint already exists" not in e.message:
acceptable_error_codes = [
"Neo.ClientError.Schema.ConstraintAlreadyExists",
"Neo.ClientError.Schema.EquivalentSchemaRuleAlreadyExists",
]
# e.message check is neo4j <= 4.1, e.code is neo4j >= 4.4
if (
"An equivalent constraint already exists" not in e.message
and e.code not in acceptable_error_codes
):
raise e
# Constraints already set up
pass
Expand Down
4 changes: 2 additions & 2 deletions src/eduid/graphdb/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


# Run tests with different Neo4j docker image versions using environment variables
NEO4J_VERSION = environ.get("NEO4J_VERSION", "4.1-enterprise")
NEO4J_VERSION = environ.get("NEO4J_VERSION", "4.4-enterprise")

logger = logging.getLogger(__name__)
logger.info(f"NEO4J_VERSION={NEO4J_VERSION}")
Expand All @@ -36,7 +36,7 @@ class Neo4jTemporaryInstance(EduidTemporaryInstance):
_bolt_port: int

DEFAULT_USERNAME = "neo4j"
DEFAULT_PASSWORD = "testing"
DEFAULT_PASSWORD = "testingtesting"

def __init__(self, max_retry_seconds: int = 60, neo4j_version: str = NEO4J_VERSION):
self._http_port = random.randint(40000, 43000)
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/graphdb/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def db_setup(self):
def test_base_db(self):
db_uri = self.neo4jdb.db_uri

config = {"encrypted": False, "auth": basic_auth("neo4j", "testing")}
config = {"encrypted": False, "auth": basic_auth("neo4j", "testingtesting")}
test_db = self.TestDB(db_uri=db_uri, config=config)
with test_db._db.driver.session() as session:
session.run("CREATE (n:Test $props)", props={"name": "test node", "testing": True})
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/graphdb/tests/test_groupdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class TestGroupDB(Neo4jTestCase):
def setUp(self) -> None:
self.db_config = {"encrypted": False, "auth": basic_auth("neo4j", "testing")}
self.db_config = {"encrypted": False, "auth": basic_auth("neo4j", "testingtesting")}
self.group_db = GroupDB(db_uri=self.neo4jdb.db_uri, scope="__testing__", config=self.db_config)
self.group1: dict[str, Union[str, list, None]] = {
"identifier": "test1",
Expand Down
Loading