Skip to content

[7.0] Test | Fix Diagnostic Tests and remove Remote Executor#4116

Open
paulmedynski wants to merge 1 commit intorelease/7.0from
cherry-pick/7.0/4078
Open

[7.0] Test | Fix Diagnostic Tests and remove Remote Executor#4116
paulmedynski wants to merge 1 commit intorelease/7.0from
cherry-pick/7.0/4078

Conversation

@paulmedynski
Copy link
Copy Markdown
Contributor

@paulmedynski paulmedynski commented Mar 31, 2026

Cherry-pick of #4078 to release/7.0


Original PR Description

Fixes AB#39873 and enables Diagnostics Test to run successfully.

Copilot AI review requested due to automatic review settings March 31, 2026 19:29
@github-project-automation github-project-automation bot moved this to To triage in SqlClient Board Mar 31, 2026
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 (cherry-pick of #4078 onto release/7.0) updates the manual diagnostics tracing tests to run successfully again by removing the RemoteExecutor dependency and tightening up how diagnostic events are observed during async connection open.

Changes:

  • Refactored DiagnosticTest to run in-proc (no RemoteExecutor) and added sync/async test groupings with shared helper validation.
  • Removed Microsoft.DotNet.RemoteExecutor package references from the ManualTests project and centralized test package versions.
  • Adjusted SqlConnection.InternalOpenAsync continuation registration to ensure the diagnostic completion continuation runs deterministically (even if the original operation is cancelled).

Reviewed changes

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

File Description
src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/DiagnosticTest.cs Reworks diagnostics tests to run in-process, adds collection-based serialization, and simplifies diagnostic payload validation.
src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj Removes RemoteExecutor dependency and tweaks project reference metadata.
src/Microsoft.Data.SqlClient/tests/Directory.Packages.props Removes the Microsoft.DotNet.RemoteExecutor package version entry.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs Updates the async-open continuation wiring for diagnostic “after/error” events.

using SqlCommand cmd = new("SELECT *, baddata = 1 / 0 FROM sys.objects FOR xml auto, xmldata;", conn);
#endif
conn.Open();
Assert.Throws<SqlException>(() => cmd.ExecuteXmlReader());
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

ExecuteXmlReaderAsyncErrorTest is intended to validate the async XML-reader error path, but it currently asserts on the sync ExecuteXmlReader() (and doesn’t use Assert.ThrowsAsync). This makes the test not cover the async API and may miss regressions in ExecuteXmlReaderAsync diagnostics.

Suggested change
Assert.Throws<SqlException>(() => cmd.ExecuteXmlReader());
await Assert.ThrowsAsync<SqlException>(() => cmd.ExecuteXmlReaderAsync());

Copilot uses AI. Check for mistakes.
Comment on lines +24 to 27
// Serialized execution: DiagnosticListener is global state, so these tests
// must not run in parallel with each other.
[Collection("DiagnosticTests")]
public class DiagnosticTest
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

These tests subscribe to the global SqlClientDiagnosticListener and enable/disable it via shared state. [Collection("DiagnosticTests")] only serializes tests within the collection; other test collections can still run in parallel and emit SqlClient diagnostics while the observer is enabled, which can cause flakiness/false positives now that RemoteExecutor isolation was removed. Consider adding a [CollectionDefinition("DiagnosticTests", DisableParallelization = true)] to prevent this collection from running concurrently with other collections.

Copilot uses AI. Check for mistakes.
@paulmedynski paulmedynski added this to the 7.0.1 milestone Mar 31, 2026
@mdaigle mdaigle moved this from To triage to In review in SqlClient Board Apr 1, 2026
@paulmedynski paulmedynski marked this pull request as ready for review April 2, 2026 15:46
@paulmedynski paulmedynski requested a review from a team as a code owner April 2, 2026 15:47
@paulmedynski paulmedynski modified the milestones: 7.0.1, 7.0.2 Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants