Skip to content

Commit ea30fce

Browse files
Merge branch 'master' into DRIVERS-3123-PYTHON-5126
2 parents 9c5a4ae + 708ce16 commit ea30fce

23 files changed

+686
-172
lines changed

.evergreen/generated_configs/tasks.yml

+91-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ tasks:
99
tags: [atlas_connect]
1010

1111
# Atlas data lake tests
12-
- name: test-atlas-data-lake-with_ext
12+
- name: test-atlas-data-lake-without_ext
1313
commands:
1414
- func: run tests
1515
vars:
1616
TEST_NAME: data_lake
1717
NO_EXT: "1"
1818
tags: [atlas_data_lake]
19-
- name: test-atlas-data-lake-without_ext
19+
- name: test-atlas-data-lake-with_ext
2020
commands:
2121
- func: run tests
2222
vars:
@@ -727,6 +727,95 @@ tasks:
727727
working_dir: src
728728
type: test
729729

730+
# Compression tests
731+
- name: test-compression-v4.0-python3.9
732+
commands:
733+
- func: run server
734+
vars:
735+
VERSION: "4.0"
736+
- func: run tests
737+
tags: [compression, "4.0"]
738+
- name: test-compression-v4.2-python3.9
739+
commands:
740+
- func: run server
741+
vars:
742+
VERSION: "4.2"
743+
- func: run tests
744+
tags: [compression, "4.2"]
745+
- name: test-compression-v4.4-python3.9
746+
commands:
747+
- func: run server
748+
vars:
749+
VERSION: "4.4"
750+
- func: run tests
751+
tags: [compression, "4.4"]
752+
- name: test-compression-v5.0-python3.9
753+
commands:
754+
- func: run server
755+
vars:
756+
VERSION: "5.0"
757+
- func: run tests
758+
tags: [compression, "5.0"]
759+
- name: test-compression-v6.0-python3.9
760+
commands:
761+
- func: run server
762+
vars:
763+
VERSION: "6.0"
764+
- func: run tests
765+
tags: [compression, "6.0"]
766+
- name: test-compression-v7.0-python3.9
767+
commands:
768+
- func: run server
769+
vars:
770+
VERSION: "7.0"
771+
- func: run tests
772+
tags: [compression, "7.0"]
773+
- name: test-compression-v8.0-python3.9
774+
commands:
775+
- func: run server
776+
vars:
777+
VERSION: "8.0"
778+
- func: run tests
779+
tags: [compression, "8.0"]
780+
- name: test-compression-rapid-python3.9
781+
commands:
782+
- func: run server
783+
vars:
784+
VERSION: rapid
785+
- func: run tests
786+
tags: [compression, rapid]
787+
- name: test-compression-latest-python3.9
788+
commands:
789+
- func: run server
790+
vars:
791+
VERSION: latest
792+
- func: run tests
793+
tags: [compression, latest]
794+
- name: test-compression-latest-python3.13-no-c
795+
commands:
796+
- func: run server
797+
vars:
798+
VERSION: latest
799+
- func: run tests
800+
vars:
801+
NO_EXT: "1"
802+
tags: [compression, latest]
803+
- name: test-compression-latest-python3.13
804+
commands:
805+
- func: run server
806+
vars:
807+
VERSION: latest
808+
- func: run tests
809+
vars: {}
810+
tags: [compression, latest]
811+
- name: test-compression-latest-pypy3.10
812+
commands:
813+
- func: run server
814+
vars:
815+
VERSION: latest
816+
- func: run tests
817+
tags: [compression, latest]
818+
730819
# Coverage report tests
731820
- name: coverage-report
732821
commands:

.evergreen/generated_configs/variants.yml

+12-72
Original file line numberDiff line numberDiff line change
@@ -160,90 +160,30 @@ buildvariants:
160160
- rhel87-small
161161

162162
# Compression tests
163-
- name: compression-snappy-rhel8-python3.9-no-c
163+
- name: compression-snappy-rhel8
164164
tasks:
165-
- name: .standalone .noauth .nossl .sync_async
166-
display_name: Compression snappy RHEL8 Python3.9 No C
167-
run_on:
168-
- rhel87-small
169-
expansions:
170-
COMPRESSORS: snappy
171-
NO_EXT: "1"
172-
PYTHON_BINARY: /opt/python/3.9/bin/python3
173-
- name: compression-snappy-rhel8-python3.10
174-
tasks:
175-
- name: .standalone .noauth .nossl .sync_async
176-
display_name: Compression snappy RHEL8 Python3.10
177-
run_on:
178-
- rhel87-small
179-
expansions:
180-
COMPRESSORS: snappy
181-
PYTHON_BINARY: /opt/python/3.10/bin/python3
182-
- name: compression-zlib-rhel8-python3.11-no-c
183-
tasks:
184-
- name: .standalone .noauth .nossl .sync_async
185-
display_name: Compression zlib RHEL8 Python3.11 No C
186-
run_on:
187-
- rhel87-small
188-
expansions:
189-
COMPRESSORS: zlib
190-
NO_EXT: "1"
191-
PYTHON_BINARY: /opt/python/3.11/bin/python3
192-
- name: compression-zlib-rhel8-python3.12
193-
tasks:
194-
- name: .standalone .noauth .nossl .sync_async
195-
display_name: Compression zlib RHEL8 Python3.12
165+
- name: .compression
166+
display_name: Compression snappy RHEL8
196167
run_on:
197168
- rhel87-small
198169
expansions:
199-
COMPRESSORS: zlib
200-
PYTHON_BINARY: /opt/python/3.12/bin/python3
201-
- name: compression-zstd-rhel8-python3.13-no-c
170+
COMPRESSOR: snappy
171+
- name: compression-zlib-rhel8
202172
tasks:
203-
- name: .standalone .noauth .nossl .sync_async !.4.0
204-
display_name: Compression zstd RHEL8 Python3.13 No C
173+
- name: .compression
174+
display_name: Compression zlib RHEL8
205175
run_on:
206176
- rhel87-small
207177
expansions:
208-
COMPRESSORS: zstd
209-
NO_EXT: "1"
210-
PYTHON_BINARY: /opt/python/3.13/bin/python3
211-
- name: compression-zstd-rhel8-python3.9
178+
COMPRESSOR: zlib
179+
- name: compression-zstd-rhel8
212180
tasks:
213-
- name: .standalone .noauth .nossl .sync_async !.4.0
214-
display_name: Compression zstd RHEL8 Python3.9
181+
- name: .compression !.4.0
182+
display_name: Compression zstd RHEL8
215183
run_on:
216184
- rhel87-small
217185
expansions:
218-
COMPRESSORS: zstd
219-
PYTHON_BINARY: /opt/python/3.9/bin/python3
220-
- name: compression-snappy-rhel8-pypy3.10
221-
tasks:
222-
- name: .standalone .noauth .nossl .sync_async
223-
display_name: Compression snappy RHEL8 PyPy3.10
224-
run_on:
225-
- rhel87-small
226-
expansions:
227-
COMPRESSORS: snappy
228-
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3
229-
- name: compression-zlib-rhel8-pypy3.10
230-
tasks:
231-
- name: .standalone .noauth .nossl .sync_async
232-
display_name: Compression zlib RHEL8 PyPy3.10
233-
run_on:
234-
- rhel87-small
235-
expansions:
236-
COMPRESSORS: zlib
237-
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3
238-
- name: compression-zstd-rhel8-pypy3.10
239-
tasks:
240-
- name: .standalone .noauth .nossl .sync_async !.4.0
241-
display_name: Compression zstd RHEL8 PyPy3.10
242-
run_on:
243-
- rhel87-small
244-
expansions:
245-
COMPRESSORS: zstd
246-
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3
186+
COMPRESSOR: zstd
247187

248188
# Coverage report tests
249189
- name: coverage-report

.evergreen/scripts/generate_config.py

+48-35
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
BATCHTIME_WEEK = 10080
2727
AUTH_SSLS = [("auth", "ssl"), ("noauth", "ssl"), ("noauth", "nossl")]
2828
TOPOLOGIES = ["standalone", "replica_set", "sharded_cluster"]
29-
C_EXTS = ["with_ext", "without_ext"]
29+
C_EXTS = ["without_ext", "with_ext"]
3030
# By default test each of the topologies with a subset of auth/ssl.
3131
SUB_TASKS = [
3232
".sharded_cluster .auth .ssl",
@@ -217,7 +217,7 @@ def get_variant_name(base: str, host: Host | None = None, **kwargs) -> str:
217217

218218

219219
def get_task_name(base: str, **kwargs):
220-
return get_common_name(base, "-", **kwargs).lower()
220+
return get_common_name(base, "-", **kwargs).replace(" ", "-").lower()
221221

222222

223223
def zip_cycle(*iterables, empty_default=None):
@@ -430,42 +430,22 @@ def create_load_balancer_variants():
430430

431431

432432
def create_compression_variants():
433-
# Compression tests - standalone versions of each server, across python versions, with and without c extensions.
434-
# PyPy interpreters are always tested without extensions.
433+
# Compression tests - standalone versions of each server, across python versions.
435434
host = DEFAULT_HOST
436-
base_task = ".standalone .noauth .nossl .sync_async"
437-
task_names = dict(snappy=[base_task], zlib=[base_task], zstd=[f"{base_task} !.4.0"])
435+
base_task = ".compression"
438436
variants = []
439-
for ind, (compressor, c_ext) in enumerate(product(["snappy", "zlib", "zstd"], C_EXTS)):
440-
expansions = dict(COMPRESSORS=compressor)
441-
handle_c_ext(c_ext, expansions)
442-
base_name = f"Compression {compressor}"
443-
python = CPYTHONS[ind % len(CPYTHONS)]
444-
display_name = get_variant_name(base_name, host, python=python, **expansions)
445-
variant = create_variant(
446-
task_names[compressor],
447-
display_name,
448-
python=python,
449-
host=host,
450-
expansions=expansions,
451-
)
452-
variants.append(variant)
453-
454-
other_pythons = PYPYS + CPYTHONS[ind:]
455-
for compressor, python in zip_cycle(["snappy", "zlib", "zstd"], other_pythons):
456-
expansions = dict(COMPRESSORS=compressor)
457-
handle_c_ext(c_ext, expansions)
458-
base_name = f"Compression {compressor}"
459-
display_name = get_variant_name(base_name, host, python=python, **expansions)
460-
variant = create_variant(
461-
task_names[compressor],
462-
display_name,
463-
python=python,
464-
host=host,
465-
expansions=expansions,
437+
for compressor in "snappy", "zlib", "zstd":
438+
expansions = dict(COMPRESSOR=compressor)
439+
tasks = [base_task] if compressor != "zstd" else [f"{base_task} !.4.0"]
440+
display_name = get_variant_name(f"Compression {compressor}", host)
441+
variants.append(
442+
create_variant(
443+
tasks,
444+
display_name,
445+
host=host,
446+
expansions=expansions,
447+
)
466448
)
467-
variants.append(variant)
468-
469449
return variants
470450

471451

@@ -866,6 +846,39 @@ def create_load_balancer_tasks():
866846
return tasks
867847

868848

849+
def create_compression_tasks():
850+
tasks = []
851+
versions = get_versions_from("4.0")
852+
# Test all server versions with min python.
853+
for version in versions:
854+
python = CPYTHONS[0]
855+
tags = ["compression", version]
856+
name = get_task_name("test-compression", python=python, version=version)
857+
server_func = FunctionCall(func="run server", vars=dict(VERSION=version))
858+
test_func = FunctionCall(func="run tests")
859+
tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func]))
860+
861+
# Test latest with max python, with and without c exts.
862+
version = "latest"
863+
tags = ["compression", "latest"]
864+
for c_ext in C_EXTS:
865+
python = CPYTHONS[-1]
866+
expansions = dict()
867+
handle_c_ext(c_ext, expansions)
868+
name = get_task_name("test-compression", python=python, version=version, **expansions)
869+
server_func = FunctionCall(func="run server", vars=dict(VERSION=version))
870+
test_func = FunctionCall(func="run tests", vars=expansions)
871+
tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func]))
872+
873+
# Test on latest with pypy.
874+
python = PYPYS[-1]
875+
name = get_task_name("test-compression", python=python, version=version)
876+
server_func = FunctionCall(func="run server", vars=dict(VERSION=version))
877+
test_func = FunctionCall(func="run tests")
878+
tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func]))
879+
return tasks
880+
881+
869882
def create_kms_tasks():
870883
tasks = []
871884
for kms_type in ["gcp", "azure"]:

doc/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ PyMongo 4.12 brings a number of changes including:
2424
:class:`~pymongo.read_preferences.SecondaryPreferred`,
2525
:class:`~pymongo.read_preferences.Nearest`. Support for ``hedge`` will be removed in PyMongo 5.0.
2626
- Removed PyOpenSSL support from the asynchronous API due to limitations of the CPython asyncio.Protocol SSL implementation.
27+
- Allow valid SRV hostnames with less than 3 parts.
2728

2829
Issues Resolved
2930
...............

pymongo/asynchronous/mongo_client.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ def __init__(
878878

879879
self._opened = False
880880
self._closed = False
881+
self._loop: Optional[asyncio.AbstractEventLoop] = None
881882
if not is_srv:
882883
self._init_background()
883884

@@ -1709,6 +1710,13 @@ async def _get_topology(self) -> Topology:
17091710
If this client was created with "connect=False", calling _get_topology
17101711
launches the connection process in the background.
17111712
"""
1713+
if not _IS_SYNC:
1714+
if self._loop is None:
1715+
self._loop = asyncio.get_running_loop()
1716+
elif self._loop != asyncio.get_running_loop():
1717+
raise RuntimeError(
1718+
"Cannot use AsyncMongoClient in different event loop. AsyncMongoClient uses low-level asyncio APIs that bind it to the event loop it was created on."
1719+
)
17121720
if not self._opened:
17131721
if self._resolve_srv_info["is_srv"]:
17141722
await self._resolve_srv()
@@ -2840,7 +2848,7 @@ async def _write(self) -> T:
28402848
_debug_log(
28412849
_COMMAND_LOGGER,
28422850
message=f"Retrying write attempt number {self._attempt_number}",
2843-
clientId=self._client.client_id,
2851+
clientId=self._client._topology_settings._topology_id,
28442852
commandName=self._operation,
28452853
operationId=self._operation_id,
28462854
)

0 commit comments

Comments
 (0)