Tests | Account for MAX_DISPATCH_LATENCY in XEvents tests#3456
Merged
Conversation
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.
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
paulmedynski
previously approved these changes
Jun 28, 2025
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
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:
|
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Contributor
There was a problem hiding this comment.
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
XEventsTracingTestto open the connection early, captureClientConnectionId, 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
MaxXEventsLatencySis ambiguous. Consider renaming toMaxXEventsLatencySecondsfor clarity.
private const int MaxXEventsLatencyS = 5;
paulmedynski
approved these changes
Jul 2, 2025
mdaigle
approved these changes
Jul 2, 2025
samsharma2700
approved these changes
Jul 3, 2025
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
This was referenced Mar 17, 2026
This was referenced Jun 29, 2026
Closed
Closed
Open
Open
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.
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?