Merge branch 'master' of github.com:mongodb/mongo-python-driver

This commit is contained in:
Steven Silvester 2024-10-17 13:08:01 -05:00
commit 04fc9a5c54
No known key found for this signature in database
GPG Key ID: B1BF5EC3A8B32F91
7 changed files with 1166 additions and 33 deletions

View File

@ -2354,16 +2354,6 @@ axes:
variables:
ORCHESTRATION_FILE: "versioned-api-testing.json"
# Run load balancer tests?
- id: loadbalancer
display_name: "Load Balancer"
values:
- id: "enabled"
display_name: "Load Balancer"
variables:
test_loadbalancer: true
batchtime: 10080 # 7 days
- id: serverless
display_name: "Serverless"
values:
@ -3580,6 +3570,203 @@ buildvariants:
VERSION: "8.0"
PYTHON_BINARY: /Library/Frameworks/Python.Framework/Versions/3.13/bin/python3
# Load balancer tests
- name: load-balancer-rhel8-v6.0-py3.9-auth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 v6.0 py3.9 Auth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: "6.0"
AUTH: auth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.9/bin/python3
- name: load-balancer-rhel8-v6.0-py3.10-noauth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 v6.0 py3.10 NoAuth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: "6.0"
AUTH: noauth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.10/bin/python3
- name: load-balancer-rhel8-v6.0-py3.11-noauth-nossl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 v6.0 py3.11 NoAuth NoSSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: "6.0"
AUTH: noauth
SSL: nossl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.11/bin/python3
- name: load-balancer-rhel8-v7.0-py3.12-auth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 v7.0 py3.12 Auth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: "7.0"
AUTH: auth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.12/bin/python3
- name: load-balancer-rhel8-v7.0-py3.13-noauth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 v7.0 py3.13 NoAuth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: "7.0"
AUTH: noauth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.13/bin/python3
- name: load-balancer-rhel8-v7.0-pypy3.9-noauth-nossl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 v7.0 pypy3.9 NoAuth NoSSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: "7.0"
AUTH: noauth
SSL: nossl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/pypy3.9/bin/python3
- name: load-balancer-rhel8-v8.0-pypy3.10-auth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 v8.0 pypy3.10 Auth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: "8.0"
AUTH: auth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3
- name: load-balancer-rhel8-v8.0-py3.9-noauth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 v8.0 py3.9 NoAuth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: "8.0"
AUTH: noauth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.9/bin/python3
- name: load-balancer-rhel8-v8.0-py3.10-noauth-nossl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 v8.0 py3.10 NoAuth NoSSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: "8.0"
AUTH: noauth
SSL: nossl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.10/bin/python3
- name: load-balancer-rhel8-latest-py3.11-auth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 latest py3.11 Auth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: latest
AUTH: auth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.11/bin/python3
- name: load-balancer-rhel8-latest-py3.12-noauth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 latest py3.12 NoAuth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: latest
AUTH: noauth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.12/bin/python3
- name: load-balancer-rhel8-latest-py3.13-noauth-nossl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 latest py3.13 NoAuth NoSSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: latest
AUTH: noauth
SSL: nossl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.13/bin/python3
- name: load-balancer-rhel8-rapid-pypy3.9-auth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 rapid pypy3.9 Auth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: rapid
AUTH: auth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/pypy3.9/bin/python3
- name: load-balancer-rhel8-rapid-pypy3.10-noauth-ssl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 rapid pypy3.10 NoAuth SSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: rapid
AUTH: noauth
SSL: ssl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3
- name: load-balancer-rhel8-rapid-py3.9-noauth-nossl
tasks:
- name: load-balancer-test
display_name: Load Balancer RHEL8 rapid py3.9 NoAuth NoSSL
run_on:
- rhel87-small
batchtime: 10080
expansions:
VERSION: rapid
AUTH: noauth
SSL: nossl
test_loadbalancer: "true"
PYTHON_BINARY: /opt/python/3.9/bin/python3
- matrix_name: "oidc-auth-test"
matrix_spec:
platform: [ rhel8, macos, windows ]
@ -3643,17 +3830,6 @@ buildvariants:
- name: "aws-auth-test-rapid"
- name: "aws-auth-test-latest"
- matrix_name: "load-balancer"
matrix_spec:
platform: rhel8
mongodb-version: ["6.0", "7.0", "8.0", "rapid", "latest"]
auth-ssl: "*"
python-version: "*"
loadbalancer: "*"
display_name: "Load Balancer ${platform} ${python-version} ${mongodb-version} ${auth-ssl}"
tasks:
- name: "load-balancer-test"
- name: testgcpkms-variant
display_name: "GCP KMS"
run_on:

View File

@ -112,12 +112,14 @@ def get_python_binary(python: str, host: str) -> str:
def get_display_name(base: str, host: str, **kwargs) -> str:
"""Get the display name of a variant."""
display_name = f"{base} {HOSTS[host].display_name}"
version = kwargs.pop("VERSION", None)
if version:
if version not in ["rapid", "latest"]:
version = f"v{version}"
display_name = f"{display_name} {version}"
for key, value in kwargs.items():
name = value
if key == "version":
if value not in ["rapid", "latest"]:
name = f"v{value}"
elif key == "python":
if key.lower() == "python":
if not value.startswith("pypy"):
name = f"py{value}"
elif key.lower() in DISPLAY_LOOKUP:
@ -309,8 +311,34 @@ def create_encryption_variants() -> list[BuildVariant]:
return variants
def create_load_balancer_variants():
# Load balancer tests - run all supported versions for all combinations of auth and ssl and system python.
host = "rhel8"
task_names = ["load-balancer-test"]
batchtime = BATCHTIME_WEEK
expansions_base = dict(test_loadbalancer="true")
versions = ["6.0", "7.0", "8.0", "latest", "rapid"]
variants = []
pythons = CPYTHONS + PYPYS
for ind, (version, (auth, ssl)) in enumerate(product(versions, AUTH_SSLS)):
expansions = dict(VERSION=version, AUTH=auth, SSL=ssl)
expansions.update(expansions_base)
python = pythons[ind % len(pythons)]
display_name = get_display_name("Load Balancer", host, python=python, **expansions)
variant = create_variant(
task_names,
display_name,
python=python,
host=host,
expansions=expansions,
batchtime=batchtime,
)
variants.append(variant)
return variants
##################
# Generate Config
##################
generate_yaml(variants=create_encryption_variants())
generate_yaml(variants=create_load_balancer_variants())

View File

@ -205,7 +205,7 @@ else:
total_sent += sent
async def _async_receive_ssl(
conn: _sslConn, length: int, dummy: AbstractEventLoop
conn: _sslConn, length: int, dummy: AbstractEventLoop, once: Optional[bool] = False
) -> memoryview:
mv = memoryview(bytearray(length))
total_read = 0
@ -215,6 +215,9 @@ else:
while total_read < length:
try:
read = conn.recv_into(mv[total_read:])
# KMS responses update their expected size after the first batch, stop reading after one loop
if once:
return mv[:read]
if read == 0:
raise OSError("connection closed")
except BLOCKING_IO_ERRORS:

View File

@ -197,7 +197,7 @@
}
},
{
"level": "info",
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",
@ -383,7 +383,7 @@
}
},
{
"level": "info",
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",

View File

@ -184,7 +184,7 @@
}
},
{
"level": "info",
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",

View File

@ -193,7 +193,7 @@
}
},
{
"level": "info",
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",

View File

@ -47,9 +47,29 @@
}
}
],
"initialData": [
{
"collectionName": "server-selection",
"databaseName": "logging-tests",
"documents": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
],
"tests": [
{
"description": "A successful operation",
"description": "A successful insert operation",
"operations": [
{
"name": "waitForEvent",
@ -191,7 +211,7 @@
}
},
{
"level": "info",
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Waiting for suitable server to become available",
@ -230,6 +250,912 @@
]
}
]
},
{
"description": "A successful find operation",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "findOne",
"object": "collection",
"arguments": {
"filter": {
"x": 1
}
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "find",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "find",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
},
{
"description": "A successful findAndModify operation",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "findOneAndReplace",
"object": "collection",
"arguments": {
"filter": {
"x": 1
},
"replacement": {
"x": 11
}
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "findAndModify",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "findAndModify",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
},
{
"description": "A successful find and getMore operation",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "find",
"object": "collection",
"arguments": {
"batchSize": 3
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "find",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "find",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "getMore",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "getMore",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
},
{
"description": "A successful aggregate operation",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "aggregate",
"object": "collection",
"arguments": {
"pipeline": [
{
"$match": {
"_id": {
"$gt": 1
}
}
}
]
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "aggregate",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "aggregate",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
},
{
"description": "A successful count operation",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "countDocuments",
"object": "collection",
"arguments": {
"filter": {}
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "count",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "count",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
},
{
"description": "A successful distinct operation",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "distinct",
"object": "collection",
"arguments": {
"fieldName": "x",
"filter": {}
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "distinct",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "distinct",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
},
{
"description": "Successful collection management operations",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "createCollection",
"object": "database",
"arguments": {
"collection": "foo"
}
},
{
"name": "listCollections",
"object": "database"
},
{
"name": "dropCollection",
"object": "database",
"arguments": {
"collection": "foo"
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "create",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "create",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "listCollections",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "listCollections",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "drop",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "drop",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
},
{
"description": "Successful index operations",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "createIndex",
"object": "collection",
"arguments": {
"keys": {
"x": 1
},
"name": "x_1"
}
},
{
"name": "listIndexes",
"object": "collection"
},
{
"name": "dropIndex",
"object": "collection",
"arguments": {
"name": "x_1"
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "createIndexes",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "createIndexes",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "listIndexes",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "listIndexes",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "dropIndexes",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "dropIndexes",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
},
{
"description": "A successful update operation",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "updateOne",
"object": "collection",
"arguments": {
"filter": {
"x": 1
},
"update": {
"$inc": {
"x": 1
}
}
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "update",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "update",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
},
{
"description": "A successful delete operation",
"operations": [
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"client": "client",
"event": {
"topologyDescriptionChangedEvent": {}
},
"count": 2
}
},
{
"name": "deleteOne",
"object": "collection",
"arguments": {
"filter": {
"x": 1
}
}
}
],
"expectLogMessages": [
{
"client": "client",
"messages": [
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection started",
"selector": {
"$$exists": true
},
"operation": "delete",
"topologyDescription": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "serverSelection",
"data": {
"message": "Server selection succeeded",
"selector": {
"$$exists": true
},
"operation": "delete",
"topologyDescription": {
"$$exists": true
},
"serverHost": {
"$$type": "string"
},
"serverPort": {
"$$type": [
"int",
"long"
]
}
}
}
]
}
]
}
]
}