diff --git a/.evergreen/spec-patch/PYTHON-5493.patch b/.evergreen/spec-patch/PYTHON-5493.patch new file mode 100644 index 000000000..cf1afbb27 --- /dev/null +++ b/.evergreen/spec-patch/PYTHON-5493.patch @@ -0,0 +1,99 @@ +diff --git a/test/connection_logging/connection-logging.json b/test/connection_logging/connection-logging.json +index d40cfbb7e..5799e834d 100644 +--- a/test/connection_logging/connection-logging.json ++++ b/test/connection_logging/connection-logging.json +@@ -272,7 +272,13 @@ + "level": "debug", + "component": "connection", + "data": { +- "message": "Connection pool closed", ++ "message": "Connection closed", ++ "driverConnectionId": { ++ "$$type": [ ++ "int", ++ "long" ++ ] ++ }, + "serverHost": { + "$$type": "string" + }, +@@ -281,20 +287,15 @@ + "int", + "long" + ] +- } ++ }, ++ "reason": "Connection pool was closed" + } + }, + { + "level": "debug", + "component": "connection", + "data": { +- "message": "Connection closed", +- "driverConnectionId": { +- "$$type": [ +- "int", +- "long" +- ] +- }, ++ "message": "Connection pool closed", + "serverHost": { + "$$type": "string" + }, +@@ -303,8 +304,7 @@ + "int", + "long" + ] +- }, +- "reason": "Connection pool was closed" ++ } + } + } + ] +@@ -446,22 +446,6 @@ + } + } + }, +- { +- "level": "debug", +- "component": "connection", +- "data": { +- "message": "Connection pool cleared", +- "serverHost": { +- "$$type": "string" +- }, +- "serverPort": { +- "$$type": [ +- "int", +- "long" +- ] +- } +- } +- }, + { + "level": "debug", + "component": "connection", +@@ -514,6 +498,22 @@ + ] + } + } ++ }, ++ { ++ "level": "debug", ++ "component": "connection", ++ "data": { ++ "message": "Connection pool cleared", ++ "serverHost": { ++ "$$type": "string" ++ }, ++ "serverPort": { ++ "$$type": [ ++ "int", ++ "long" ++ ] ++ } ++ } + } + ] + } diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index b7b8fb506..96729e3a6 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -50,33 +50,31 @@ jobs: cppcheck pymongo build: - # supercharge/mongodb-github-action requires containers so we don't test other platforms runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: + # Tests currently only pass on ubuntu on GitHub Actions. os: [ubuntu-latest] - python-version: ["3.9", "pypy-3.10", "3.13", "3.13t"] + python-version: ["3.9", "pypy-3.10", "3.13t"] + mongodb-version: ["8.0"] + name: CPython ${{ matrix.python-version }}-${{ matrix.os }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - - name: Install just - uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3 - name: Install uv uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5 with: enable-cache: true python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: just install - - name: Start MongoDB - uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0 + - id: setup-mongodb + uses: mongodb-labs/drivers-evergreen-tools@master with: - mongodb-version: 6.0 + version: "${{ matrix.mongodb-version }}" - name: Run tests - run: just test + run: uv run --extra test pytest -v doctest: runs-on: ubuntu-latest @@ -92,10 +90,10 @@ jobs: with: enable-cache: true python-version: "3.9" - - name: Start MongoDB - uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0 + - id: setup-mongodb + uses: mongodb-labs/drivers-evergreen-tools@master with: - mongodb-version: '8.0.0-rc4' + version: "8.0" - name: Install dependencies run: just install - name: Run tests @@ -210,8 +208,8 @@ jobs: cache-dependency-path: 'sdist/test/pyproject.toml' # Test sdist on lowest supported Python python-version: '3.9' - - name: Start MongoDB - uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0 + - id: setup-mongodb + uses: mongodb-labs/drivers-evergreen-tools@master - name: Run connect test from sdist shell: bash run: | @@ -234,10 +232,10 @@ jobs: uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5 with: python-version: '3.9' - - name: Start MongoDB - uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0 + - id: setup-mongodb + uses: mongodb-labs/drivers-evergreen-tools@master with: - mongodb-version: 6.0 + version: "8.0" # Async and our test_dns do not support dnspython 1.X, so we don't run async or dns tests here - name: Run tests shell: bash @@ -260,10 +258,10 @@ jobs: uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v5 with: python-version: '3.9' - - name: Start MongoDB - uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0 + - id: setup-mongodb + uses: mongodb-labs/drivers-evergreen-tools@master with: - mongodb-version: 6.0 + version: "8.0" # The lifetime kwarg we use in srv resolution was added to the async resolver API in dnspython 2.1.0 - name: Run tests shell: bash diff --git a/.github/zizmor.yml b/.github/zizmor.yml new file mode 100644 index 000000000..10fd4cdfc --- /dev/null +++ b/.github/zizmor.yml @@ -0,0 +1,7 @@ +rules: + unpinned-uses: + config: + policies: + actions/*: ref-pin + mongodb-labs/drivers-github-tools/*: ref-pin + mongodb-labs/drivers-evergreen-tools: ref-pin diff --git a/test/asynchronous/test_pooling.py b/test/asynchronous/test_pooling.py index 66edf0177..cbf6d336b 100644 --- a/test/asynchronous/test_pooling.py +++ b/test/asynchronous/test_pooling.py @@ -21,7 +21,7 @@ import random import socket import sys import time -from test.asynchronous.utils import async_get_pool, async_joinall +from test.asynchronous.utils import async_get_pool, async_joinall, flaky from bson.codec_options import DEFAULT_CODEC_OPTIONS from bson.son import SON @@ -429,6 +429,7 @@ class TestPooling(_TestPoolingBase): # maxConnecting = unbounded: 30+ connections in ~0.140+ seconds print(len(pool.conns)) + @flaky(reason="PYTHON-5492") @async_client_context.require_failCommand_appName async def test_csot_timeout_message(self): client = await self.async_rs_or_single_client(appName="connectionTimeoutApp") diff --git a/test/connection_logging/connection-logging.json b/test/connection_logging/connection-logging.json index 72103b3ca..5799e834d 100644 --- a/test/connection_logging/connection-logging.json +++ b/test/connection_logging/connection-logging.json @@ -446,22 +446,6 @@ } } }, - { - "level": "debug", - "component": "connection", - "data": { - "message": "Connection pool cleared", - "serverHost": { - "$$type": "string" - }, - "serverPort": { - "$$type": [ - "int", - "long" - ] - } - } - }, { "level": "debug", "component": "connection", @@ -514,6 +498,22 @@ ] } } + }, + { + "level": "debug", + "component": "connection", + "data": { + "message": "Connection pool cleared", + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } } ] } diff --git a/test/test_pooling.py b/test/test_pooling.py index b995c467c..5ce4284e3 100644 --- a/test/test_pooling.py +++ b/test/test_pooling.py @@ -21,7 +21,7 @@ import random import socket import sys import time -from test.utils import get_pool, joinall +from test.utils import flaky, get_pool, joinall from bson.codec_options import DEFAULT_CODEC_OPTIONS from bson.son import SON @@ -429,6 +429,7 @@ class TestPooling(_TestPoolingBase): # maxConnecting = unbounded: 30+ connections in ~0.140+ seconds print(len(pool.conns)) + @flaky(reason="PYTHON-5492") @client_context.require_failCommand_appName def test_csot_timeout_message(self): client = self.rs_or_single_client(appName="connectionTimeoutApp")