Skip to content

Commit c761c1f

Browse files
authored
PYTHON-3088 Update load balancer tests to support dedicated load balancer port (#866) (#869)
(cherry picked from commit 341d489)
1 parent 358e158 commit c761c1f

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

.evergreen/config.yml

+6
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ functions:
292292
DISABLE_TEST_COMMANDS=${DISABLE_TEST_COMMANDS} \
293293
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
294294
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
295+
LOAD_BALANCER=${LOAD_BALANCER} \
295296
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
296297
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
297298
- command: expansions.update
@@ -457,6 +458,7 @@ functions:
457458
fi
458459
if [ -n "${test_loadbalancer}" ]; then
459460
export TEST_LOADBALANCER=1
461+
export LOAD_BALANCER=1
460462
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}"
461463
export MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}"
462464
fi
@@ -1685,8 +1687,12 @@ tasks:
16851687
commands:
16861688
- func: "bootstrap mongo-orchestration"
16871689
vars:
1690+
VERSION: "latest"
16881691
TOPOLOGY: "sharded_cluster"
1692+
LOAD_BALANCER: true
16891693
- func: "run load-balancer"
1694+
vars:
1695+
LOAD_BALANCER: true
16901696
- func: "run tests"
16911697
# }}}
16921698
- name: "coverage-report"

pymongo/pool.py

-7
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,6 @@ def _set_keepalive_times(sock):
247247
# main thread, to avoid the deadlock. See PYTHON-607.
248248
"foo".encode("idna")
249249

250-
# Remove after PYTHON-2712
251-
_MOCK_SERVICE_ID = False
252-
253250

254251
def _raise_connection_failure(address, error, msg_prefix=None):
255252
"""Convert a socket.error to ConnectionFailure and raise it."""
@@ -638,10 +635,6 @@ def _hello(self, cluster_time, topology_version, heartbeat_frequency, all_creden
638635
cmd["speculativeAuthenticate"] = auth_ctx.speculate_command()
639636

640637
doc = self.command("admin", cmd, publish_events=False, exhaust_allowed=awaitable)
641-
# PYTHON-2712 will remove this topologyVersion fallback logic.
642-
if self.opts.load_balanced and _MOCK_SERVICE_ID:
643-
process_id = doc.get("topologyVersion", {}).get("processId")
644-
doc.setdefault("serviceId", process_id)
645638
if not self.opts.load_balanced:
646639
doc.pop("serviceId", None)
647640
hello = Hello(doc, awaitable=awaitable)

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)