Tests | Attempt to fix enable file stream failures + fix flaky tests#4220
Open
cheenamalhotra wants to merge 3 commits into
Open
Tests | Attempt to fix enable file stream failures + fix flaky tests#4220cheenamalhotra wants to merge 3 commits into
cheenamalhotra wants to merge 3 commits into
Conversation
Co-authored-by: Copilot <copilot@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce intermittent CI failures by making Windows SQL Server FileStream enablement more reliable during pipeline setup, and by quarantining a small set of intermittently failing tests.
Changes:
- Restart SQL Server after the WMI
EnableFilestream(3, ...)call and increase the retry budget for the follow-upsp_configurestep. - Mark 3 intermittently failing tests as
[Trait("Category", "flaky")]so they are quarantined from default test runs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
eng/pipelines/common/templates/steps/configure-sql-server-win-step.yml |
Adds SQL Server restart + expands retry loop to reduce FileStream setup flakiness on Windows agents. |
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionFailoverTests.cs |
Quarantines a simulated failover unit test as flaky. |
src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/MetricsTest.cs |
Quarantines a metrics/manual test as flaky. |
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/SqlVariantParameterTests.cs |
Quarantines a sql_variant bulk copy manual test as flaky. |
paulmedynski
requested changes
Apr 22, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4220 +/- ##
==========================================
- Coverage 65.94% 64.41% -1.53%
==========================================
Files 277 270 -7
Lines 42949 65777 +22828
==========================================
+ Hits 28321 42369 +14048
- Misses 14628 23408 +8780
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Comment on lines
+187
to
+193
| #Enable FileStream via WMI. | ||
| # The sp_configure call is deferred to after the "Restart SQL Server [Win]" | ||
| # step so we don't need a separate restart here. | ||
| $instance = "${{parameters.instanceName }}" | ||
| $wmi = Get-WmiObject -Namespace "${{parameters.SQLRootPath }}" -Class FilestreamSettings | where {$_.InstanceName -eq $instance} | ||
| $wmi.EnableFilestream(3, $instance) | ||
|
|
||
| $machineName = $env:COMPUTERNAME | ||
|
|
||
| if ("${{parameters.instanceName }}" -ne "MSSQLSERVER"){ | ||
| $machineName += "\${{parameters.instanceName }}" | ||
| } | ||
|
|
||
| #Change the access level for FileStream for SQLServer | ||
| Set-ExecutionPolicy Unrestricted | ||
| Import-Module "sqlps" | ||
|
|
||
| # Retry loop: SQL Server may be temporarily unavailable after enabling FileStream via WMI. | ||
| # Worst-case budget: 10 attempts x (5s connection timeout + 5s sleep) = ~100s | ||
| $tries = 0 | ||
| while ($true) { | ||
| $tries++ | ||
| try { | ||
| Invoke-Sqlcmd -ServerInstance "$machineName" -ConnectionTimeout 5 @" | ||
| EXEC sp_configure filestream_access_level, 2; | ||
| RECONFIGURE; | ||
| "@ | ||
| Write-Host "FileStream access level configured successfully." | ||
| break | ||
| } catch { | ||
| if ($tries -ge 10) { | ||
| Write-Host "##[error]Failed to configure FileStream access level after $tries tries." | ||
| throw | ||
| } | ||
| Write-Host "Failed to connect to SQL Server (attempt $tries/10). Retrying in 5 seconds..." | ||
| Start-Sleep -Seconds 5 | ||
| } | ||
| } | ||
| Write-Host "FileStream enabled via WMI for instance '$instance'." |
apoorvdeshmukh
approved these changes
May 12, 2026
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.
Problem
The CI pipeline's Windows SQL Server configuration step intermittently fails in two places:
breakinstead ofthrow).EnableFilestream(3, ...)call, thesp_configure filestream_access_levelT-SQL command fails because SQL Server needs a restart for the WMI change to take effect.Example failure: https://sqlclientdrivers.visualstudio.com/public/_build/results?buildId=148483&view=logs&j=0d02c018-afa8-5f77-e1de-32c6d598a678&t=5b158d7f-5532-5d37-977c-ecb257065e86&s=da54b7cd-c327-58c0-3741-799c147adcfe
Fix
Pipeline (
configure-sql-server-win-step.yml):break→throwso failure is no longer silently ignored. Added-ConnectionTimeout 5to avoid hanging.EnableFilestreamcall. Moved thesp_configure filestream_access_levelT-SQL to a new step that runs after the existing "Restart SQL Server [Win]" step, eliminating the need for a double restart.Flaky test annotations:
Marked 3 intermittently failing tests with
[Trait("Category", "flaky")]:SqlVariantParameterTests.SqlType_BulkCopyFromDataRow_RoundTripsCorrectlyMetricsTest.TransactedConnectionPool_VerifyActiveConnectionCountersConnectionFailoverTests.TransientFault_IgnoreServerProvidedFailoverPartner_ShouldConnectToUserProvidedPartnerChecklist
sp_configureruns after