[6.1] Fix xevent test failures, avoid orphaned sessions#3817
Conversation
- Added IsNotManagedInstance() for XEvents tests.
There was a problem hiding this comment.
Pull request overview
This pull request ports fixes from #3775 to the release/6.1 branch, addressing XEvent test failures and preventing orphaned XEvent sessions in test environments. The changes refactor the XEventScope test utility to include test names in session identifiers, add automatic session expiration for supported SQL Server versions, and convert affected test classes from static to instance-based to enable test name tracking.
Key changes:
- Refactored
XEventScopeto accept test name as first parameter and added MAX_DURATION support for Azure SQL and SQL Server 2025+ - Converted
XEventsTracingTestandDataStreamTestfrom static to instance-based classes withITestOutputHelperconstructors - Introduced
CurrentTestName()utility method using reflection to extract test names from xUnit's internal structures - Refactored
GetSqlServerProperty()to use aServerPropertyenum instead of string parameters
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/ManualTests/TracingTests/XEventsTracingTest.cs | Converted class to instance-based, added constructor with ITestOutputHelper, updated XEventScope usage to pass test name, added nullable annotations |
| src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs | Converted class to instance-based, added constructor with ITestOutputHelper, updated XEventScope usage with test name and explicit connection opening, flattened using statements |
| src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs | Added CurrentTestName() method with regex parsing, added ServerProperty enum, refactored GetSqlServerProperty() to use enum, added IsNotManagedInstance() method, enhanced XEventScope with test name parameter, MAX_DURATION support, and improved documentation |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/6.1 #3817 +/- ##
===============================================
+ Coverage 65.27% 66.11% +0.83%
===============================================
Files 279 279
Lines 61765 53290 -8475
===============================================
- Hits 40319 35234 -5085
+ Misses 21446 18056 -3390
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:
|
Description
Port of #3775 and #3819 to release/6.1