Fix flaky test: retry binlog copy on IOException - #54831
Merged
MichaelSimons merged 1 commit intoJun 18, 2026
Merged
Conversation
Extract FileUtility.TryCopyFile that retries File.Copy on IOException with backoff. If the destination already exists the copy is skipped with a diagnostic log. If all retries are exhausted the failure is logged as a warning without throwing. Use TryCopyFile for binlog uploads in TestCommand so that transient file locks (e.g. MSBuild still holding the binlog handle) do not fail tests. Fixes #54817 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
baronfel
approved these changes
Jun 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Helix test flakiness caused by transient IOException file locks when copying *.binlog files for upload by moving the binlog copy into a retrying helper and using it from TestCommand.Execute.
Changes:
- Added
FileUtility.TryCopyFilehelper to copy a file with retry-on-IOExceptionand non-fatal logging. - Updated
TestCommand.Executeto useFileUtility.TryCopyFilefor Helix binlog uploads so diagnostic upload failures don’t fail the test.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Microsoft.NET.TestFramework/Utilities/FileUtility.cs | Introduces a retrying file-copy helper used for diagnostic binlog upload. |
| test/Microsoft.NET.TestFramework/Commands/TestCommand.cs | Switches Helix binlog upload copy to the new retrying helper. |
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.
Summary
Fixes #54817
The
File.Copyfor binlog upload to Helix can throwIOExceptionwhen MSBuild hasn't fully released the file handle, causing test failures unrelated to the test logic.Changes
New
FileUtility.TryCopyFile(test/Microsoft.NET.TestFramework/Utilities/FileUtility.cs): A reusable utility that copies a file with retry-on-IOException and diagnostic logging:Updated
TestCommand.Executeto useFileUtility.TryCopyFilefor binlog uploads so transient file locks do not fail tests.Testing
Binlog upload is diagnostic-only — copy failures will not fail the test.