-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[UserEvents] Add end-to-end runtime test #121316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 adds a new test for UserEvents tracing on Linux that validates the runtime's ability to emit trace events through the user_events subsystem. The test uses the Microsoft.OneCollect.RecordTrace tool to capture events from a tracee process and validates that GC events were properly recorded.
Key changes include:
- Addition of a new test infrastructure for UserEvents tracing
- Upgrade of TraceEvent library from version 3.1.16 to 3.1.28
- Implementation of multi-process test orchestration with native signal handling
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/tracing/eventpipe/userevents/usereventstracee.cs | Implements tracee process that generates GC events for validation |
| src/tests/tracing/eventpipe/userevents/userevents.csproj | Project configuration including NuGet package references and build targets |
| src/tests/tracing/eventpipe/userevents/userevents.cs | Main test orchestration: spawns processes, collects traces, validates events |
| src/tests/tracing/eventpipe/userevents/dotnet-common.script | Configuration script for record-trace tool specifying provider and flags |
| eng/Versions.props | Updates TraceEvent package version to 3.1.28 |
I like this approach. |
b1d4234 to
7395930
Compare
0286358 to
8c28d62
Compare
|
Looks like the reason the .NET runtime events aren't being captured in the .nettrace is because a session isn't actually being started. |
Even after switching to just enabling GCKeyword, the 1s tracee app had a 1% failure rate locally. On the other hand, AllocationSampled had no failures after 1000 runs.
eb14e69 to
368b499
Compare
|
I'm planning to open another cleaner PR featuring a reusable UserEvents TestRunner allowing quick extension to different scenarios (this thread). Plus this PR got a bit noisy with issue references due to testing commits to get the userevents tests working on Helix. |
|
Closing in favor of #122134, which has a cleaner commit history and less noisy (for now) discussion thread (from all of the helix test commits) |
With user_events support added in #115265, this PR looks to test a basic end-to-end user_events scenario.
Alternative testing approaches considered
Existing EventPipe runtime tests
Existing EventPipe tests under
src/tests/tracing/eventpipeare incompatible with testing the user_events scenario due to:Starting EventPipeSessions through DiagnosticClient ❌
DiagnosticClient does not have the support to send the IPC command to start a user_events based EventPipe session, because it requires the user_events_data file descriptor to be sent using SCM_RIGHTS (see https://github.com/dotnet/diagnostics/blob/main/documentation/design-docs/ipc-protocol.md#passing_file_descriptor).
Using an EventPipeEventSource to validate events streamed through EventPipe ❌
User_events based EventPipe sessions do not stream events. Instead, events are written to configured TraceFS tracepoints, and currently only RecordTrace from https://github.com/microsoft/one-collect/ is capable of generating
.nettracetraces from tracepoint user_events.Native EventPipe Unit Tests
There are Mono Native EventPipe tests under
src/mono/mono/eventpipe/testthat are not hooked up to CI. These unit tests are built through linking the shared EventPipe interface library against Mono's EventPipe runtime shims and using Mono's test runner. To update these unit tests into the standard runtime tests structure, a larger investment is needed to either migrate EventPipe from using runtime shims to a OS Pal source shared by coreclr/nativeaot/mono (see #118874 (comment)) or build an EventPipe shared library specifically for the runtime test using a runtime-agnostic shim.As existing mono unit tests don't currently test IPC commands, coupled with no existing runtime infrastructure to read events from tracepoints, there would be even more work on top of updating mono native eventpipe unit tests to even test the user_events scenario.
End-to-End Testing Added
A low-cost approach to testing .NET Runtime's user_events functionality leverages RecordTrace from https://github.com/microsoft/one-collect/, which is already capable of starting user_events based EventPipe sessions and generating
.nettraces. (Note: dotnet-trace wraps around RecordTrace)Despite adding an external dependency which allows RecordTrace failures to fail the end-to-end test, user_events was initially added with the intent to depend on RecordTrace for the end-to-end scenario, and there are no other ways to functionally test a user_events based eventpipe session.
Approach
.nettracefor particular events from Tracee appDependencies:
user_events_data.