Skip to content

Commit 48ddb1f

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver
2 parents 059c19f + cbff329 commit 48ddb1f

File tree

45 files changed

+947
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+947
-100
lines changed

.evergreen/run-tests.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ AUTH=${AUTH:-noauth}
3232
SSL=${SSL:-nossl}
3333
TEST_ARGS="${*:1}"
3434
PYTHON=$(which python)
35+
# TODO: Remove when we drop PyPy 3.8 support.
36+
OLD_PYPY=$(python -c "import sys; print(sys.implementation.name.lower() == 'pypy' and sys.implementation.version < (7, 3, 12))")
37+
3538
export PIP_QUIET=1 # Quiet by default
3639
export PIP_PREFER_BINARY=1 # Prefer binary dists by default
3740

@@ -110,6 +113,9 @@ fi
110113

111114
if [ "$COMPRESSORS" = "snappy" ]; then
112115
python -m pip install '.[snappy]'
116+
if [ "$OLD_PYPY" == "True" ]; then
117+
pip install "python-snappy<0.7.0"
118+
fi
113119
PYTHON=python
114120
elif [ "$COMPRESSORS" = "zstd" ]; then
115121
python -m pip install zstandard
@@ -250,6 +256,9 @@ fi
250256
if [ -n "$GREEN_FRAMEWORK" ]; then
251257
# Install all optional deps to ensure lazy imports are getting patched.
252258
python -m pip install -q ".[aws,encryption,gssapi,ocsp,snappy,zstd]"
259+
if [ "$OLD_PYPY" == "True" ]; then
260+
pip install "python-snappy<0.7.0"
261+
fi
253262
python -m pip install $GREEN_FRAMEWORK
254263
fi
255264

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ocsp = [
7171
"service_identity>=18.1.0",
7272
]
7373
snappy = [
74-
"python-snappy",
74+
"python-snappy"
7575
]
7676
# PYTHON-3423 Removed in 4.3 but kept here to avoid pip warnings.
7777
srv = []

test/command_logging/unacknowledged-write.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "unacknowledged-write",
3-
"schemaVersion": "1.13",
3+
"schemaVersion": "1.16",
44
"createEntities": [
55
{
66
"client": {
@@ -53,11 +53,27 @@
5353
"_id": 2
5454
}
5555
}
56+
},
57+
{
58+
"name": "find",
59+
"object": "collection",
60+
"arguments": {
61+
"filter": {}
62+
},
63+
"expectResult": [
64+
{
65+
"_id": 1
66+
},
67+
{
68+
"_id": 2
69+
}
70+
]
5671
}
5772
],
5873
"expectLogMessages": [
5974
{
6075
"client": "client",
76+
"ignoreExtraMessages": true,
6177
"messages": [
6278
{
6379
"level": "debug",

test/command_monitoring/unacknowledgedBulkWrite.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "unacknowledgedBulkWrite",
3-
"schemaVersion": "1.0",
3+
"schemaVersion": "1.7",
44
"createEntities": [
55
{
66
"client": {
@@ -64,11 +64,29 @@
6464
],
6565
"ordered": false
6666
}
67+
},
68+
{
69+
"name": "find",
70+
"object": "collection",
71+
"arguments": {
72+
"filter": {}
73+
},
74+
"expectResult": [
75+
{
76+
"_id": 1,
77+
"x": 11
78+
},
79+
{
80+
"_id": "unorderedBulkWriteInsertW0",
81+
"x": 44
82+
}
83+
]
6784
}
6885
],
6986
"expectEvents": [
7087
{
7188
"client": "client",
89+
"ignoreExtraEvents": true,
7290
"events": [
7391
{
7492
"commandStartedEvent": {

test/performance/perf_test.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import os
4444
import sys
4545
import tempfile
46+
import threading
4647
import time
4748
import warnings
4849
from typing import Any, List, Optional
@@ -101,10 +102,19 @@ def __exit__(self, *args):
101102
self.interval = self.end - self.start
102103

103104

105+
def threaded(n_threads, func):
106+
threads = [threading.Thread(target=func) for _ in range(n_threads)]
107+
for t in threads:
108+
t.start()
109+
for t in threads:
110+
t.join()
111+
112+
104113
class PerformanceTest:
105114
dataset: str
106115
data_size: int
107116
fail: Any
117+
n_threads: int = 1
108118

109119
@classmethod
110120
def setUpClass(cls):
@@ -118,7 +128,7 @@ def tearDown(self):
118128
# Remove "Test" so that TestFlatEncoding is reported as "FlatEncoding".
119129
name = self.__class__.__name__[4:]
120130
median = self.percentile(50)
121-
megabytes_per_sec = self.data_size / median / 1000000
131+
megabytes_per_sec = (self.data_size * self.n_threads) / median / 1000000
122132
print(
123133
f"Completed {self.__class__.__name__} {megabytes_per_sec:.3f} MB/s, MEDIAN={self.percentile(50):.3f}s, "
124134
f"total time={duration:.3f}s, iterations={len(self.results)}"
@@ -128,7 +138,7 @@ def tearDown(self):
128138
"info": {
129139
"test_name": name,
130140
"args": {
131-
"threads": 1,
141+
"threads": self.n_threads,
132142
},
133143
},
134144
"metrics": [
@@ -163,7 +173,10 @@ def runTest(self):
163173
i += 1
164174
self.before()
165175
with Timer() as timer:
166-
self.do_task()
176+
if self.n_threads == 1:
177+
self.do_task()
178+
else:
179+
threaded(self.n_threads, self.do_task)
167180
self.after()
168181
results.append(timer.interval)
169182
duration = time.monotonic() - start
@@ -308,6 +321,10 @@ def do_task(self):
308321
command("hello", True)
309322

310323

324+
class TestRunCommand8Threads(TestRunCommand):
325+
n_threads = 8
326+
327+
311328
class TestDocument(PerformanceTest):
312329
def setUp(self):
313330
super().setUp()
@@ -356,6 +373,10 @@ def do_task(self):
356373
find_one({"_id": _id})
357374

358375

376+
class TestFindOneByID8Threads(TestFindOneByID):
377+
n_threads = 8
378+
379+
359380
class SmallDocInsertTest(TestDocument):
360381
dataset = "small_doc.json"
361382

@@ -395,6 +416,10 @@ def do_task(self):
395416
list(self.corpus.find())
396417

397418

419+
class TestFindManyAndEmptyCursor8Threads(TestFindManyAndEmptyCursor):
420+
n_threads = 8
421+
422+
398423
class TestSmallDocBulkInsert(SmallDocInsertTest, unittest.TestCase):
399424
def do_task(self):
400425
self.corpus.insert_many(self.documents, ordered=True)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"description": "entity-client-observeLogMessages-minProperties",
3+
"schemaVersion": "1.13",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"observeLogMessages": {}
9+
}
10+
}
11+
],
12+
"tests": [
13+
{
14+
"description": "foo",
15+
"operations": []
16+
}
17+
]
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"description": "entity-client-observeLogMessages-property-type",
3+
"schemaVersion": "1.13",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"observeLogMessages": {
9+
"command": {}
10+
}
11+
}
12+
}
13+
],
14+
"tests": [
15+
{
16+
"description": "foo",
17+
"operations": []
18+
}
19+
]
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"description": "entity-client-observeLogMessages-property-type",
3+
"schemaVersion": "1.13",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"observeLogMessages": {
9+
"command": "notALogLevel"
10+
}
11+
}
12+
}
13+
],
14+
"tests": [
15+
{
16+
"description": "foo",
17+
"operations": []
18+
}
19+
]
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"description": "entity-client-observeLogMessages-type",
3+
"schemaVersion": "1.13",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"observeLogMessages": 0
9+
}
10+
}
11+
],
12+
"tests": [
13+
{
14+
"description": "foo",
15+
"operations": []
16+
}
17+
]
18+
}

test/unified-test-format/invalid/expectedCmapEvent-poolClearedEvent-interruptInUseConnections-type.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
]
2121
}
2222
]
23-
}
23+
}

0 commit comments

Comments
 (0)