File tree Expand file tree Collapse file tree 3 files changed +26
-21
lines changed
tests/performance/perftest Expand file tree Collapse file tree 3 files changed +26
-21
lines changed Original file line number Diff line number Diff line change 55import subprocess
66import sys
77from datetime import datetime
8+ < << << << Updated upstream
9+ == == == =
10+ from pathlib import Path
11+ > >> >> >> Stashed changes
812
913LOGGER = logging .getLogger ("test" )
1014logging .basicConfig (level = logging .INFO , format = "%(levelname)-8s %(message)s" )
@@ -48,8 +52,19 @@ def run_command(cmd: str | list[str], **kwargs) -> None:
4852 LOGGER .info ("Running command '%s'... done." , cmd )
4953
5054
51- os .chdir ("tests/performance" )
52-
5355start_time = datetime .now ()
5456run_command (["python manage.py test" ])
57+ ROOT = Path (__file__ ).absolute ().parent .parent
58+ data_dir = ROOT / "specifications/source/benchmarking/odm-data"
59+ if not data_dir .exists ():
60+ run_command ("git clone --depth 1 https://github.com/mongodb/specifications.git" )
61+ run_command ("tar xf flat_models.tgz" , cwd = data_dir )
62+ run_command ("tar xf nested_models.tgz" , cwd = data_dir )
63+
64+ os .chdir ("tests/performance" )
65+ start_time = datetime .now ()
66+ run_command (
67+ ["python manage.py test" ],
68+ env = os .environ | {"TEST_PATH" : str (data_dir ), "OUTPUT_FILE" : str (ROOT / "results.json" )},
69+ )
5570handle_perf (start_time )
Original file line number Diff line number Diff line change 1010https://docs.djangoproject.com/en/5.2/ref/settings/
1111"""
1212
13- import os
1413from pathlib import Path
1514
1615import django_mongodb_backend
5756
5857# Database
5958# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
60- USER = os .environ .get ("ATLAS_DEV_USER" )
61- PASSWORD = os .environ .get ("ATLAS_DEV_PASSWORD" )
62- # DATABASES = {
63- # "default": {
64- # "ENGINE": "django_mongodb_backend",
65- # "HOST": f"mongodb+srv://{USER}:{PASSWORD}@intpython736.oztdp.mongodb-dev.net/?retryWrites=true&w=majority&appName=INTPYTHON736",
66- # "NAME": "benchmarking",
67- # "PORT": 27017,
68- # },
69- # }
70-
71- settings = django_mongodb_backend .parse_uri (
72- "mongodb://localhost:27017/benchmarking" ,
73- )
7459DATABASES = {
75- "default" : settings ,
60+ "default" : {
61+ "ENGINE" : "django_mongodb_backend" ,
62+ "HOST" : "mongodb://localhost:27017/benchmarking" ,
63+ "NAME" : "benchmarking" ,
64+ "PORT" : 27017 ,
65+ },
7666}
7767
7868# Password validation
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ class SmallFlatDocTest(PerformanceTest):
168168
169169 def setUp (self ):
170170 super ().setUp ()
171- with open (Path (TEST_PATH ) / Path ("flat_models " ) / self .dataset ) as data : # noqa: PTH123
171+ with open (Path (TEST_PATH ) / Path ("flat-models " ) / self .dataset ) as data : # noqa: PTH123
172172 self .document = json_util .loads (data .read ())
173173
174174 self .data_size = len (encode (self .document )) * NUM_DOCS
@@ -251,7 +251,7 @@ class LargeFlatDocTest(PerformanceTest):
251251
252252 def setUp (self ):
253253 super ().setUp ()
254- with open (Path (TEST_PATH ) / Path ("flat_models " ) / self .dataset ) as data : # noqa: PTH123
254+ with open (Path (TEST_PATH ) / Path ("flat-models " ) / self .dataset ) as data : # noqa: PTH123
255255 self .document = json_util .loads (data .read ())
256256
257257 self .data_size = len (encode (self .document )) * NUM_DOCS
@@ -292,7 +292,7 @@ class LargeNestedDocTest(PerformanceTest):
292292
293293 def setUp (self ):
294294 super ().setUp ()
295- with open (Path (TEST_PATH ) / Path ("nested_models " ) / self .dataset ) as data : # noqa: PTH123
295+ with open (Path (TEST_PATH ) / Path ("nested-models " ) / self .dataset ) as data : # noqa: PTH123
296296 self .document = json_util .loads (data .read ())
297297
298298 self .data_size = len (encode (self .document )) * NUM_DOCS
You can’t perform that action at this time.
0 commit comments