Skip to content

Commit 1443d76

Browse files
authored
PYTHON-3088 [v3.13] Update load balancer tests to support dedicated load balancer port (#870)
PYTHON-3088 Update load balancer tests to support dedicated load balancer port (#866) (cherry picked from commit 341d489)
1 parent 402cf6d commit 1443d76

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

.evergreen/config.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ functions:
291291
DISABLE_TEST_COMMANDS=${DISABLE_TEST_COMMANDS} \
292292
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
293293
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
294+
LOAD_BALANCER=${LOAD_BALANCER} \
294295
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
295296
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
296297
- command: expansions.update
@@ -1798,6 +1799,7 @@ tasks:
17981799
- func: "bootstrap mongo-orchestration"
17991800
vars:
18001801
TOPOLOGY: "sharded_cluster"
1802+
LOAD_BALANCER: true
18011803
- func: "run load-balancer"
18021804
- func: "run tests"
18031805
# }}}
@@ -2023,6 +2025,10 @@ axes:
20232025
display_name: "MongoDB 5.0"
20242026
variables:
20252027
VERSION: "5.0"
2028+
- id: "rapid"
2029+
display_name: "MongoDB rapid"
2030+
variables:
2031+
VERSION: "rapid"
20262032

20272033
# Choice of Python runtime version
20282034
- id: python-version
@@ -2986,7 +2992,7 @@ buildvariants:
29862992
- matrix_name: "load-balancer"
29872993
matrix_spec:
29882994
platform: awslinux
2989-
mongodb-version: ["5.0", "latest"]
2995+
mongodb-version: ["rapid", "latest"]
29902996
auth-ssl: "*"
29912997
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy", "pypy3.5", "pypy3.7"]
29922998
loadbalancer: "*"

pymongo/pool.py

-12
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@ def _set_keepalive_times(sock):
242242
# main thread, to avoid the deadlock. See PYTHON-607.
243243
u"foo".encode("idna")
244244

245-
# Remove after PYTHON-2712
246-
_MOCK_SERVICE_ID = False
247-
248245

249246
def _raise_connection_failure(address, error, msg_prefix=None):
250247
"""Convert a socket.error to ConnectionFailure and raise it."""
@@ -619,12 +616,6 @@ def _hello(self, cluster_time, topology_version, heartbeat_frequency, all_creden
619616
cmd["speculativeAuthenticate"] = auth_ctx.speculate_command()
620617

621618
doc = self.command("admin", cmd, publish_events=False, exhaust_allowed=awaitable)
622-
# PYTHON-2712 will remove this topologyVersion fallback logic.
623-
if self.opts.load_balanced and _MOCK_SERVICE_ID:
624-
process_id = doc.get("topologyVersion", {}).get("processId")
625-
doc.setdefault("serviceId", process_id)
626-
if not self.opts.load_balanced:
627-
doc.pop("serviceId", None)
628619
hello = IsMaster(doc, awaitable=awaitable)
629620
self.is_writable = hello.is_writable
630621
self.max_wire_version = hello.max_wire_version
@@ -661,9 +652,6 @@ def _next_reply(self):
661652
unpacked_docs = reply.unpack_response()
662653
response_doc = unpacked_docs[0]
663654
helpers._check_command_response(response_doc, self.max_wire_version)
664-
# Remove after PYTHON-2712.
665-
if not self.opts.load_balanced:
666-
response_doc.pop("serviceId", None)
667655
return response_doc
668656

669657
def command(

test/__init__.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@
9898
SINGLE_MONGOS_LB_URI = os.environ.get("SINGLE_MONGOS_LB_URI")
9999
MULTI_MONGOS_LB_URI = os.environ.get("MULTI_MONGOS_LB_URI")
100100
if TEST_LOADBALANCER:
101-
# Remove after PYTHON-2712
102-
from pymongo import pool
103-
104-
pool._MOCK_SERVICE_ID = True
105-
res = parse_uri(SINGLE_MONGOS_LB_URI)
101+
res = parse_uri(SINGLE_MONGOS_LB_URI or "")
106102
host, port = res["nodelist"][0]
107103
db_user = res["username"] or db_user
108104
db_pwd = res["password"] or db_pwd

0 commit comments

Comments
 (0)