PYTHON-3153 Update initial DNS seedlist discovery tests to support dedicated load balancer port (#1002)

This commit is contained in:
Steven Silvester 2022-07-14 14:57:52 -05:00 committed by GitHub
parent 418130d923
commit 135efdd23f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 20 deletions

View File

@ -2102,12 +2102,12 @@ class _MongoClientErrorHandler(object):
self.service_id = None
self.handled = False
def contribute_socket(self, sock_info):
def contribute_socket(self, sock_info, completed_handshake=True):
"""Provide socket information to the error handler."""
self.max_wire_version = sock_info.max_wire_version
self.sock_generation = sock_info.generation
self.service_id = sock_info.service_id
self.completed_handshake = True
self.completed_handshake = completed_handshake
def handle(self, exc_type, exc_val):
if self.handled or exc_type is None:

View File

@ -1344,7 +1344,7 @@ class Pool:
self.requests -= 1
self.size_cond.notify()
def connect(self):
def connect(self, handler=None):
"""Connect to Mongo and return a new SocketInfo.
Can raise ConnectionFailure.
@ -1378,6 +1378,8 @@ class Pool:
if self.handshake:
sock_info.hello()
self.is_writable = sock_info.is_writable
if handler:
handler.contribute_socket(sock_info, completed_handshake=False)
sock_info.authenticate()
except BaseException:
@ -1408,7 +1410,8 @@ class Pool:
if self.enabled_for_cmap:
listeners.publish_connection_check_out_started(self.address)
sock_info = self._get_socket()
sock_info = self._get_socket(handler=handler)
if self.enabled_for_cmap:
listeners.publish_connection_checked_out(self.address, sock_info.id)
try:
@ -1446,7 +1449,7 @@ class Pool:
)
_raise_connection_failure(self.address, AutoReconnect("connection pool paused"))
def _get_socket(self):
def _get_socket(self, handler=None):
"""Get or create a SocketInfo. Can raise ConnectionFailure."""
# We use the pid here to avoid issues with fork / multiprocessing.
# See test.test_client:TestClient.test_fork for an example of
@ -1520,7 +1523,7 @@ class Pool:
continue
else: # We need to create a new connection
try:
sock_info = self.connect()
sock_info = self.connect(handler=handler)
finally:
with self._max_connecting_cond:
self._pending -= 1

View File

@ -1,10 +1,10 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/?directConnection=false",
"uri": "mongodb+srv://test24.test.build.10gen.cc/?directConnection=false",
"seeds": [
"localhost.test.build.10gen.cc:27017"
"localhost.test.build.10gen.cc:8000"
],
"hosts": [
"localhost.test.build.10gen.cc:27017"
"localhost.test.build.10gen.cc:8000"
],
"options": {
"loadBalanced": true,

View File

@ -1,5 +1,5 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/?replicaSet=replset",
"uri": "mongodb+srv://test24.test.build.10gen.cc/?replicaSet=replset",
"seeds": [],
"hosts": [],
"error": true,

View File

@ -1,10 +1,10 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/",
"uri": "mongodb+srv://test24.test.build.10gen.cc/",
"seeds": [
"localhost.test.build.10gen.cc:27017"
"localhost.test.build.10gen.cc:8000"
],
"hosts": [
"localhost.test.build.10gen.cc:27017"
"localhost.test.build.10gen.cc:8000"
],
"options": {
"loadBalanced": true,

View File

@ -1,5 +1,5 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/?srvMaxHosts=1",
"uri": "mongodb+srv://test24.test.build.10gen.cc/?srvMaxHosts=1",
"seeds": [],
"hosts": [],
"error": true,

View File

@ -1,10 +1,10 @@
{
"uri": "mongodb+srv://test20.test.build.10gen.cc/?srvMaxHosts=0",
"uri": "mongodb+srv://test24.test.build.10gen.cc/?srvMaxHosts=0",
"seeds": [
"localhost.test.build.10gen.cc:27017"
"localhost.test.build.10gen.cc:8000"
],
"hosts": [
"localhost.test.build.10gen.cc:27017"
"localhost.test.build.10gen.cc:8000"
],
"options": {
"loadBalanced": true,

View File

@ -1,10 +1,10 @@
{
"uri": "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=0",
"uri": "mongodb+srv://test23.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=0",
"seeds": [
"localhost.test.build.10gen.cc:27017"
"localhost.test.build.10gen.cc:8000"
],
"hosts": [
"localhost.test.build.10gen.cc:27017"
"localhost.test.build.10gen.cc:8000"
],
"options": {
"loadBalanced": true,