Skip to content

Dev/automation/pool blocking tests on main#4411

Draft
mdaigle wants to merge 2 commits into
mainfrom
dev/automation/pool-blocking-tests-on-main
Draft

Dev/automation/pool blocking tests on main#4411
mdaigle wants to merge 2 commits into
mainfrom
dev/automation/pool-blocking-tests-on-main

Conversation

@mdaigle

@mdaigle mdaigle commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Applies tests from #4395 directly against main to prove wait handle pool behavior is unchanged.

mdaigle added 2 commits June 26, 2026 11:50
Cherry-picks the new WaitHandleDbConnectionPool blocking-period tests onto main and adapts the pre-refactor pool to use a TimeProvider-driven error timer so FakeTimeProvider can drive the exit backoff. Adds the generic ADP.UnsafeCreateTimer<T> helper and a local SqlExceptionHelper. All 7 tests pass, confirming behavior parity.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds end-to-end unit tests to validate that WaitHandleDbConnectionPool’s blocking-period (error backoff / fast-fail) behavior remains unchanged, and introduces a small internal hook to make the blocking-period timer deterministic under test via an injected TimeProvider.

Changes:

  • Added comprehensive blocking-period end-to-end tests for WaitHandleDbConnectionPool, including fast-fail, NeverBlock policy, expiry recovery, and backoff reset/doubling.
  • Added a small test helper to create SqlException instances for pool-failure scenarios.
  • Updated WaitHandleDbConnectionPool to use TimeProvider + ITimer for the blocking-period timer, plus an ADP.UnsafeCreateTimer(TimeProvider, ...) helper to avoid ExecutionContext capture.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolBlockingPeriodTest.cs New end-to-end tests covering blocking-period entry, fast-fail, expiry, recovery, and backoff behavior using FakeTimeProvider.
src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/SqlExceptionHelper.cs Adds a helper to construct SqlException instances for deterministic failure injection in tests.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs Injects a TimeProvider and switches the blocking-period timer to ITimer to allow deterministic timer advancement in tests.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs Adds ADP.UnsafeCreateTimer(TimeProvider, ...) overload to create ITimer without flowing ExecutionContext.

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

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

2 participants