Fix flaky LinuxResourceHealthCheckTests by isolating MeterListener with ReferenceEquals#7302
Conversation
Co-authored-by: stephentoub <[email protected]>
Co-authored-by: stephentoub <[email protected]>
Co-authored-by: stephentoub <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR addresses CI flakiness in LinuxResourceHealthCheckTests.TestCpuAndMemoryChecks_WithMetrics by avoiding cross-test metric contamination from MeterListener subscriptions that match meters globally by name, and instead isolating metric collection to the specific Meter instance created by the test.
Changes:
- Replaced the test’s use of
ResourceUtilizationHealthCheck’s internalMeterListenerwith a locally-scopedMeterListenerfiltered viaReferenceEquals(meter, instrument.Meter). - Captured CPU/memory utilization measurements from observable instruments and evaluated health via
ResourceUtilizationHealthCheck.EvaluateHealthStatusAsync. - Removed unused variables (
dataTracker,meterName,checkContext) and switched to string literals for instrument names to avoid type ambiguity.
|
@copilot CI is complaining about code coverage. Can you take a look? |
…istener for correctness Co-authored-by: stephentoub <[email protected]>
Head branch was pushed to by a user without write access
Fixed in f335eda. The test now calls |
Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Microsoft Reviewers: Open in CodeFlow