Dev/automation/pool blocking tests on main#4411
Draft
mdaigle wants to merge 2 commits into
Draft
Conversation
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.
4 tasks
Contributor
There was a problem hiding this comment.
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
SqlExceptioninstances for pool-failure scenarios. - Updated
WaitHandleDbConnectionPoolto useTimeProvider+ITimerfor the blocking-period timer, plus anADP.UnsafeCreateTimer(TimeProvider, ...)helper to avoidExecutionContextcapture.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Applies tests from #4395 directly against main to prove wait handle pool behavior is unchanged.