Skip to content

Commit 584ad4d

Browse files
committed
PYTHON-3088 Update load balancer tests to support dedicated load balancer port (mongodb#866)
(cherry picked from commit 341d489)
1 parent 14329ac commit 584ad4d

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

.evergreen/config.yml

Lines changed: 6 additions & 0 deletions
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
@@ -423,6 +424,7 @@ functions:
423424
fi
424425
if [ -n "${test_loadbalancer}" ]; then
425426
export TEST_LOADBALANCER=1
427+
export LOAD_BALANCER=1
426428
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}"
427429
export MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}"
428430
fi
@@ -1770,8 +1772,12 @@ tasks:
17701772
commands:
17711773
- func: "bootstrap mongo-orchestration"
17721774
vars:
1775+
VERSION: "latest"
17731776
TOPOLOGY: "sharded_cluster"
1777+
LOAD_BALANCER: true
17741778
- func: "run load-balancer"
1779+
vars:
1780+
LOAD_BALANCER: true
17751781
- func: "run tests"
17761782
# }}}
17771783
- name: "coverage-report"

pymongo/pool.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,6 @@ def _set_keepalive_times(sock):
220220
# main thread, to avoid the deadlock. See PYTHON-607.
221221
u'foo'.encode('idna')
222222

223-
# Remove after PYTHON-2712
224-
_MOCK_SERVICE_ID = False
225-
226223

227224
def _raise_connection_failure(address, error, msg_prefix=None):
228225
"""Convert a socket.error to ConnectionFailure and raise it."""
@@ -584,12 +581,7 @@ def _hello(self, cluster_time, topology_version,
584581
if auth_ctx:
585582
cmd['speculativeAuthenticate'] = auth_ctx.speculate_command()
586583

587-
doc = self.command('admin', cmd, publish_events=False,
588-
exhaust_allowed=awaitable)
589-
# PYTHON-2712 will remove this topologyVersion fallback logic.
590-
if self.opts.load_balanced and _MOCK_SERVICE_ID:
591-
process_id = doc.get('topologyVersion', {}).get('processId')
592-
doc.setdefault('serviceId', process_id)
584+
doc = self.command("admin", cmd, publish_events=False, exhaust_allowed=awaitable)
593585
if not self.opts.load_balanced:
594586
doc.pop('serviceId', None)
595587
hello = IsMaster(doc, awaitable=awaitable)

test/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,10 @@
9999
SINGLE_MONGOS_LB_URI = os.environ.get("SINGLE_MONGOS_LB_URI")
100100
MULTI_MONGOS_LB_URI = os.environ.get("MULTI_MONGOS_LB_URI")
101101
if TEST_LOADBALANCER:
102-
# Remove after PYTHON-2712
103-
from pymongo import pool
104-
pool._MOCK_SERVICE_ID = True
105-
res = parse_uri(SINGLE_MONGOS_LB_URI)
106-
host, port = res['nodelist'][0]
107-
db_user = res['username'] or db_user
108-
db_pwd = res['password'] or db_pwd
102+
res = parse_uri(SINGLE_MONGOS_LB_URI or "")
103+
host, port = res["nodelist"][0]
104+
db_user = res["username"] or db_user
105+
db_pwd = res["password"] or db_pwd
109106
elif TEST_SERVERLESS:
110107
TEST_LOADBALANCER = True
111108
res = parse_uri(SINGLE_MONGOS_LB_URI)

0 commit comments

Comments
 (0)