Skip to content

Commit

Permalink
Merge pull request #2781 from vtomasr5/master
Browse files Browse the repository at this point in the history
Add mongodb 6.0 and 7.0 to the CI pipeline
bagerard authored Dec 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents f9eb279 + bda4955 commit 8f865ba
Showing 7 changed files with 92 additions and 24 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ env:
MONGODB_4_0: 4.0.28
MONGODB_4_4: 4.4
MONGODB_5_0: "5.0"
MONGODB_6_0: "6.0"
MONGODB_7_0: "7.0"

PYMONGO_3_4: 3.4
PYMONGO_3_6: 3.6
@@ -25,6 +27,8 @@ env:
PYMONGO_3_12: 3.12
PYMONGO_4_0: 4.0
PYMONGO_4_3: 4.3.2
PYMONGO_4_4: 4.4.1
PYMONGO_4_6: 4.6.0

MAIN_PYTHON_VERSION: 3.7

@@ -68,6 +72,12 @@ jobs:
- python-version: "3.11"
MONGODB: $MONGODB_5_0
PYMONGO: $PYMONGO_4_3
- python-version: "3.11"
MONGODB: $MONGODB_6_0
PYMONGO: $PYMONGO_4_4
- python-version: "3.11"
MONGODB: $MONGODB_7_0
PYMONGO: $PYMONGO_4_6
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
4 changes: 4 additions & 0 deletions .github/workflows/install_mongo.sh
Original file line number Diff line number Diff line change
@@ -11,6 +11,10 @@ elif [[ "$MONGODB" == *"4.4"* ]]; then
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
elif [[ "$MONGODB" == *"5.0"* ]]; then
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
elif [[ "$MONGODB" == *"6.0"* ]]; then
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
elif [[ "$MONGODB" == *"7.0"* ]]; then
mongo_build=mongodb-linux-x86_64-ubuntu2004-v${MONGODB}-latest
fi

wget http://fastdl.mongodb.org/linux/$mongo_build.tgz
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ an `API reference <https://mongoengine-odm.readthedocs.io/apireference.html>`_.

Supported MongoDB Versions
==========================
MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.4 and v5.0. Future versions
MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.4, v5.0, v6.0 and v7.0. Future versions
should be supported as well, but aren't actively tested at the moment. Make
sure to open an issue or submit a pull request if you experience any problems
with a more recent MongoDB versions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ Development
===========
- (Fill this out as you fix issues and develop your features).
- Fix for uuidRepresentation not read when provided in URI #2741
- Add tests against MongoDB 6.0 and MongoDB 7.0 in the pipeline

Changes in 0.27.0
=================
3 changes: 3 additions & 0 deletions mongoengine/mongodb_support.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@
MONGODB_36 = (3, 6)
MONGODB_42 = (4, 2)
MONGODB_44 = (4, 4)
MONGODB_50 = (5, 0)
MONGODB_60 = (6, 0)
MONGODB_70 = (7, 0)


def get_mongodb_version():
92 changes: 70 additions & 22 deletions tests/document/test_indexes.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
from mongoengine.connection import get_db
from mongoengine.mongodb_support import (
MONGODB_42,
MONGODB_70,
get_mongodb_version,
)
from mongoengine.pymongo_support import PYMONGO_VERSION
@@ -466,30 +467,73 @@ class Test(Document):
== "IDHACK"
)

query_plan = Test.objects(a=1).only("a").exclude("id").explain()
assert (
query_plan.get("queryPlanner")
.get("winningPlan")
.get("inputStage")
.get("stage")
== "IXSCAN"
)
mongo_db = get_mongodb_version()
query_plan = Test.objects(a=1).only("a").exclude("id").explain()
if mongo_db < MONGODB_70:
assert (
query_plan.get("queryPlanner")
.get("winningPlan")
.get("inputStage")
.get("stage")
== "IXSCAN"
)
else:
assert (
query_plan.get("queryPlanner")
.get("winningPlan")
.get("queryPlan")
.get("inputStage")
.get("stage")
== "IXSCAN"
)

PROJECTION_STR = "PROJECTION" if mongo_db < MONGODB_42 else "PROJECTION_COVERED"
assert (
query_plan.get("queryPlanner").get("winningPlan").get("stage")
== PROJECTION_STR
)
if mongo_db < MONGODB_70:
assert (
query_plan.get("queryPlanner").get("winningPlan").get("stage")
== PROJECTION_STR
)
else:
assert (
query_plan.get("queryPlanner")
.get("winningPlan")
.get("queryPlan")
.get("stage")
== PROJECTION_STR
)

query_plan = Test.objects(a=1).explain()
assert (
query_plan.get("queryPlanner")
.get("winningPlan")
.get("inputStage")
.get("stage")
== "IXSCAN"
)
assert query_plan.get("queryPlanner").get("winningPlan").get("stage") == "FETCH"
if mongo_db < MONGODB_70:
assert (
query_plan.get("queryPlanner")
.get("winningPlan")
.get("inputStage")
.get("stage")
== "IXSCAN"
)
else:
assert (
query_plan.get("queryPlanner")
.get("winningPlan")
.get("queryPlan")
.get("inputStage")
.get("stage")
== "IXSCAN"
)

if mongo_db < MONGODB_70:
assert (
query_plan.get("queryPlanner").get("winningPlan").get("stage")
== "FETCH"
)
else:
assert (
query_plan.get("queryPlanner")
.get("winningPlan")
.get("queryPlan")
.get("stage")
== "FETCH"
)

def test_index_on_id(self):
class BlogPost(Document):
@@ -536,8 +580,12 @@ class BlogPost(Document):
BlogPost.objects.hint("Bad Name").count()

# Invalid shape argument (missing list brackets) should fail.
with pytest.raises(ValueError):
BlogPost.objects.hint(("tags", 1)).count()
if PYMONGO_VERSION <= (4, 3):
with pytest.raises(ValueError):
BlogPost.objects.hint(("tags", 1)).count()
else:
with pytest.raises(TypeError):
BlogPost.objects.hint(("tags", 1)).count()

def test_collation(self):
base = {"locale": "en", "strength": 2}
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = pypy3-{mg34,mg36,mg39,mg311,mg312,mg4}
envlist = pypy3-{mg34,mg36,mg39,mg311,mg312,mg4,mg432,mg441,mg460}

[testenv]
commands =
@@ -12,5 +12,7 @@ deps =
mg312: pymongo>=3.12,<3.13
mg4: pymongo>=4.0,<4.1
mg432: pymongo>=4.3,<4.4
mg441: pymongo>=4.4,<4.5
mg460: pymongo>=4.6,<4.7
setenv =
PYTHON_EGG_CACHE = {envdir}/python-eggs

0 comments on commit 8f865ba

Please sign in to comment.