Skip to content

Conversation

@edwardneal
Copy link
Contributor

Description

XEvents are asynchronous, and are written to the target within MAX_DISPATCH_LATENCY seconds. We therefore need to wait that long before querying the target.

Issues

Fixes #3453.

Testing

I've run the corresponding test locally ten times while the SQL Server instance is under load, and this seems to work properly.
Could we run the pipeline a few times to prove the reliability please?

XEvents are asynchronous, and are written to the target within MAX_DISPATCH_LATENCY seconds. We therefore need to wait that long before querying the target.
@edwardneal edwardneal requested a review from a team as a code owner June 27, 2025 21:11
@paulmedynski
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

paulmedynski
paulmedynski previously approved these changes Jun 28, 2025
@codecov
Copy link

codecov bot commented Jun 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.62%. Comparing base (df35633) to head (cd3fdba).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3456      +/-   ##
==========================================
- Coverage   63.30%   59.62%   -3.69%     
==========================================
  Files         280      274       -6     
  Lines       62386    62076     -310     
==========================================
- Hits        39493    37012    -2481     
- Misses      22893    25064    +2171     
Flag Coverage Δ
addons ?
netcore 61.47% <ø> (-5.55%) ⬇️
netfx 63.46% <ø> (-2.70%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mdaigle
Copy link
Contributor

mdaigle commented Jul 1, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@apoorvdeshmukh apoorvdeshmukh requested a review from Copilot July 2, 2025 03:58
Copy link
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 updates XEvents tests to account for the asynchronous dispatch latency by waiting before querying the event target.

  • Extracts the dispatch latency into a constant and updates XEvent session settings.
  • Inserts a sleep in the test utility to wait for events to be dispatched.
  • Refactors XEventsTracingTest to open the connection early, capture ClientConnectionId, and filter XEvents by that ID.

Reviewed Changes

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

File Description
src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/XEventsTracingTest.cs Refactored test setup: open connection first, capture ID, apply filter.
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs Added MaxXEventsLatencyS constant, replaced hard-coded settings, inserted Thread.Sleep.
Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs:1095

  • [nitpick] The suffix 'S' in MaxXEventsLatencyS is ambiguous. Consider renaming to MaxXEventsLatencySeconds for clarity.
            private const int MaxXEventsLatencyS = 5;

@paulmedynski paulmedynski merged commit dc75c40 into dotnet:main Jul 4, 2025
237 checks passed
@edwardneal edwardneal deleted the tests/xevents-timings branch July 4, 2025 11:39
paulmedynski pushed a commit that referenced this pull request Sep 15, 2025
* Account for MAX_DISPATCH_LATENCY in XEvents tests

XEvents are asynchronous, and are written to the target within MAX_DISPATCH_LATENCY seconds. We therefore need to wait that long before querying the target.

* Filter XEvent session by client_connection_id
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.

XEvent tests intermittent failures

4 participants