Skip to content

PYTHON-5366 - test_pool_reset waits until Pool.reset() increments gen…#2797

Open
NoahStapp wants to merge 3 commits intomongodb:masterfrom
NoahStapp:PYTHON-5366
Open

PYTHON-5366 - test_pool_reset waits until Pool.reset() increments gen…#2797
NoahStapp wants to merge 3 commits intomongodb:masterfrom
NoahStapp:PYTHON-5366

Conversation

@NoahStapp
Copy link
Copy Markdown
Contributor

…eration

PYTHON-5366

Changes in this PR

Make test.test_topology.TestTopologyErrors.test_pool_reset explicitly wait for the failed hello to trigger Pool.reset() and bump the generation instead of the current synchronization race.

Test Plan

Test fixing.

Checklist

Checklist for Author

  • [ ] Did you update the changelog (if necessary)?
  • Is there test coverage?
  • [ ] Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

@NoahStapp NoahStapp requested a review from a team as a code owner May 7, 2026 18:54
@NoahStapp NoahStapp requested review from aclark4life, caseyclements and Copilot and removed request for caseyclements May 7, 2026 18:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a race in TestTopologyErrors.test_pool_reset by making the test explicitly wait for the monitor thread’s failed hello to trigger Pool.reset() and increment the pool generation, instead of relying on immediate post-trigger state.

Changes:

  • Removes the @flaky decorator from test_pool_reset by fixing the underlying synchronization race.
  • Replaces a timing-sensitive assertNotEqual with a wait_until that polls until the pool generation changes.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.95%. Comparing base (0adf6df) to head (a2ddf1e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2797      +/-   ##
==========================================
+ Coverage   82.49%   87.95%   +5.45%     
==========================================
  Files         140      141       +1     
  Lines       24177    24406     +229     
  Branches     4131     4176      +45     
==========================================
+ Hits        19945    21466    +1521     
+ Misses       3359     2047    -1312     
- Partials      873      893      +20     
Flag Coverage Δ
auth-aws-rhel8-test-auth-aws-rapid-web-identity-python3.14-cov 35.01% <ø> (ø)
auth-aws-win64-test-auth-aws-rapid-web-identity-python3.14-cov 35.03% <ø> (+0.02%) ⬆️
auth-enterprise-macos-test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-cov 43.76% <ø> (?)
auth-enterprise-rhel8-test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-cov 43.75% <ø> (+<0.01%) ⬆️
auth-enterprise-win64-test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-cov 43.78% <ø> (+<0.01%) ⬆️
auth-oidc-local-ubuntu-22-test-auth-oidc-default 48.61% <ø> (?)
compression-snappy-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.34% <ø> (-0.01%) ⬇️
compression-snappy-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.48% <ø> (-0.03%) ⬇️
compression-snappy-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 61.09% <ø> (-0.03%) ⬇️
compression-snappy-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 59.00% <ø> (-0.02%) ⬇️
compression-zlib-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.35% <ø> (-0.01%) ⬇️
compression-zlib-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.51% <ø> (-0.02%) ⬇️
compression-zlib-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 61.09% <ø> (ø)
compression-zlib-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 59.00% <ø> (ø)
compression-zstd-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.34% <ø> (-0.01%) ⬇️
compression-zstd-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.50% <ø> (+0.03%) ⬆️
compression-zstd-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 61.09% <ø> (ø)
compression-zstd-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 59.00% <ø> (+<0.01%) ⬆️
compression-zstd-ubuntu-22-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 58.98% <ø> (ø)
coverage-report-coverage-report 87.91% <ø> (+6.70%) ⬆️
disable-test-commands-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.34% <ø> (-0.02%) ⬇️
disable-test-commands-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.51% <ø> (+0.03%) ⬆️
disable-test-commands-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 61.09% <ø> (ø)
disable-test-commands-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 59.02% <ø> (ø)
encryption-crypt_shared-macos-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 53.08% <ø> (?)
encryption-crypt_shared-macos-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.79% <ø> (?)
encryption-crypt_shared-macos-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.59% <ø> (?)
encryption-crypt_shared-rhel8-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 53.08% <ø> (?)
encryption-crypt_shared-rhel8-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.66% <ø> (?)
encryption-crypt_shared-rhel8-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.60% <ø> (?)
encryption-crypt_shared-win64-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.95% <ø> (?)
encryption-crypt_shared-win64-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.76% <ø> (?)
encryption-crypt_shared-win64-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.67% <ø> (?)
encryption-macos-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 53.08% <ø> (?)
encryption-macos-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.76% <ø> (?)
encryption-macos-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.58% <ø> (?)
encryption-pyopenssl-rhel8-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 53.74% <ø> (?)
encryption-pyopenssl-rhel8-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 55.34% <ø> (?)
encryption-pyopenssl-rhel8-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 55.28% <ø> (?)
encryption-rhel8-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 53.08% <ø> (?)
encryption-rhel8-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.66% <ø> (?)
encryption-rhel8-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.58% <ø> (?)
encryption-win64-test-non-standard-latest-python3.13-noauth-nossl-standalone-cov 52.95% <ø> (?)
encryption-win64-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 54.70% <ø> (?)
encryption-win64-test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov 54.66% <ø> (?)
load-balancer-test-non-standard-latest-python3.14-auth-ssl-sharded-cluster-cov 48.40% <ø> (?)
mongodb-latest-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 61.48% <ø> (+0.01%) ⬆️
mongodb-latest-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 59.35% <ø> (+<0.01%) ⬆️
mongodb-latest-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 59.51% <ø> (ø)
mongodb-latest-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 59.61% <ø> (+0.01%) ⬆️
mongodb-latest-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 61.41% <ø> (ø)
mongodb-rapid-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 61.48% <ø> (ø)
mongodb-rapid-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 59.33% <ø> (-0.02%) ⬇️
mongodb-rapid-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 59.50% <ø> (ø)
mongodb-rapid-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 59.59% <ø> (ø)
mongodb-rapid-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 61.41% <ø> (-0.01%) ⬇️
mongodb-v4.2-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 57.19% <ø> (ø)
mongodb-v4.2-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 55.63% <ø> (+0.02%) ⬆️
mongodb-v4.2-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.06% <ø> (ø)
mongodb-v4.2-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.17% <ø> (ø)
mongodb-v4.2-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 57.35% <ø> (+<0.01%) ⬆️
mongodb-v4.4-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 59.55% <ø> (-0.03%) ⬇️
mongodb-v4.4-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 57.58% <ø> (-0.02%) ⬇️
mongodb-v4.4-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.57% <ø> (ø)
mongodb-v4.4-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.65% <ø> (ø)
mongodb-v4.4-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 59.35% <ø> (-0.01%) ⬇️
mongodb-v5.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 59.76% <ø> (+<0.01%) ⬆️
mongodb-v5.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 57.76% <ø> (+<0.01%) ⬆️
mongodb-v5.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.77% <ø> (ø)
mongodb-v5.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.88% <ø> (-0.02%) ⬇️
mongodb-v5.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 59.58% <ø> (-0.01%) ⬇️
mongodb-v6.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 59.78% <ø> (+0.01%) ⬆️
mongodb-v6.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 57.76% <ø> (+<0.01%) ⬆️
mongodb-v6.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.79% <ø> (ø)
mongodb-v6.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.93% <ø> (ø)
mongodb-v6.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 59.73% <ø> (-0.01%) ⬇️
mongodb-v7.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 59.82% <ø> (+<0.01%) ⬆️
mongodb-v7.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 57.74% <ø> (+<0.01%) ⬆️
mongodb-v7.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 57.84% <ø> (ø)
mongodb-v7.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 57.93% <ø> (-0.02%) ⬇️
mongodb-v7.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 59.74% <ø> (+0.01%) ⬆️
mongodb-v8.0-test-server-version-python3.10-async-auth-ssl-sharded-cluster-min-deps-cov 61.48% <ø> (+<0.01%) ⬆️
mongodb-v8.0-test-server-version-python3.10-async-noauth-nossl-standalone-min-deps-cov 59.34% <ø> (-0.03%) ⬇️
mongodb-v8.0-test-server-version-python3.10-sync-auth-ssl-sharded-cluster-min-deps-cov 59.50% <ø> (ø)
mongodb-v8.0-test-server-version-python3.10-sync-noauth-nossl-replica-set-min-deps-cov 59.59% <ø> (ø)
mongodb-v8.0-test-server-version-python3.11-async-noauth-nossl-replica-set-cov 61.40% <ø> (-0.01%) ⬇️
no-c-ext-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 60.56% <ø> (+0.02%) ⬆️
no-c-ext-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 62.71% <ø> (-0.02%) ⬇️
no-c-ext-rhel8-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 62.30% <ø> (ø)
no-c-ext-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 60.21% <ø> (+0.01%) ⬆️
ocsp-rhel8-test-ocsp-ecdsa-valid-cert-server-staples-latest-python3.14-cov 34.21% <ø> (?)
ocsp-rhel8-test-ocsp-rsa-valid-cert-server-staples-latest-python3.14-cov 34.21% <ø> (?)
pyopenssl-macos-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.78% <ø> (?)
pyopenssl-rhel8-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.75% <ø> (?)
pyopenssl-win64-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.72% <ø> (?)
stable-api-accept-v2-rhel8-auth-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.35% <ø> (-0.04%) ⬇️
stable-api-accept-v2-rhel8-auth-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 59.00% <ø> (ø)
stable-api-require-v1-rhel8-auth-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.31% <ø> (-0.01%) ⬇️
stable-api-require-v1-rhel8-auth-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 60.95% <ø> (ø)
stable-api-require-v1-rhel8-auth-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 58.98% <ø> (ø)
storage-inmemory-rhel8-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.36% <ø> (+0.01%) ⬆️
storage-inmemory-rhel8-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 59.00% <ø> (-0.01%) ⬇️
test-macos-arm64-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.34% <ø> (+0.02%) ⬆️
test-macos-arm64-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.51% <ø> (+0.02%) ⬆️
test-macos-arm64-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 61.09% <ø> (-0.09%) ⬇️
test-macos-arm64-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 58.97% <ø> (-0.03%) ⬇️
test-macos-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.33% <ø> (?)
test-macos-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.45% <ø> (?)
test-macos-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 61.09% <ø> (?)
test-macos-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 58.98% <ø> (?)
test-numpy-macos-arm64-test-numpy-python3.14-python3.14-cov 32.61% <ø> (?)
test-numpy-macos-test-numpy-python3.14-python3.14-cov 32.61% <ø> (?)
test-numpy-rhel8-test-numpy-python3.14-python3.14-cov 32.61% <ø> (ø)
test-numpy-win32-test-numpy-python3.14-python3.14-cov 32.58% <ø> (-0.01%) ⬇️
test-numpy-win64-test-numpy-python3.14-python3.14-cov 32.59% <ø> (ø)
test-win32-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.20% <ø> (-0.03%) ⬇️
test-win32-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.43% <ø> (-0.01%) ⬇️
test-win32-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 61.05% <ø> (-0.03%) ⬇️
test-win32-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 58.87% <ø> (+0.01%) ⬆️
test-win64-test-standard-latest-python3.11-async-noauth-nossl-standalone-cov 59.22% <ø> (-0.01%) ⬇️
test-win64-test-standard-latest-python3.12-async-noauth-ssl-replica-set-cov 61.43% <ø> (-0.03%) ⬇️
test-win64-test-standard-latest-python3.13-async-auth-ssl-sharded-cluster-cov 61.07% <ø> (+<0.01%) ⬆️
test-win64-test-standard-latest-python3.14-async-noauth-nossl-standalone-cov 58.85% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants