-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix intermittent PerformanceCounter test failures due to file access conflicts #117619
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
Merged
Conversation
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
…ess conflicts Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Copilot finished work on behalf of
ericstj
July 14, 2025 19:22
ericstj
reviewed
Jul 14, 2025
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.
@copilot please address this feedback.
src/libraries/System.Diagnostics.PerformanceCounter/tests/PerformanceCounterCategoryTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.PerformanceCounter/tests/PerformanceCounterCategoryTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.PerformanceCounter/tests/PerformanceCounterCategoryTests.cs
Show resolved
Hide resolved
…calls with RetryHelper and use Helpers.DeleteCategory Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Copilot finished work on behalf of
ericstj
July 14, 2025 20:51
ericstj
approved these changes
Jul 14, 2025
tarekgh
approved these changes
Jul 14, 2025
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.
LGTM!
This was referenced Jul 15, 2025
/ba-g Android tests timeout - not related, IO.Pipelines test dead-lettered - not touched in this PR. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR addresses intermittent test failures in
System.Diagnostics.Tests.PerformanceCounterTests.PerformanceCounter_IncrementBy_IncrementByReadOnly
and other performance counter tests that occur due to file access conflicts during category creation and deletion operations.Root Cause
The tests were failing with:
This error indicates file access conflicts, likely due to antivirus scanners or other processes temporarily accessing the performance counter files during test execution.
Solution
Enhanced the test helper methods with robust retry logic to handle transient file access issues:
1. Enhanced
CreateCategory
helperPerformanceCounterCategory.Create
calls withRetryHelper.Execute
2. Enhanced
DeleteCategory
helperPerformanceCounterCategory.Delete
calls withRetryHelper.Execute
3. Added intelligent exception filtering
IsRetriableException
method identifies specific exceptions that should trigger retries:Win32Exception
with error codes 32 (sharing violation), 5 (access denied), 33 (lock violation)IOException
for general file access issuesUnauthorizedAccessException
for permission issues4. Updated test cleanup
PerformanceCounterCategory.Delete
calls in test files to use the retry-enabledHelpers.DeleteCategory
methodExample of the fix in action
Before:
After:
The retry logic follows the same pattern already established in the codebase with
RetryOnAllPlatforms
methods, ensuring consistency with existing test infrastructure.Fixes #105925.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.