Fix race condition in MigrationTests with xUnit Collection#2154
Merged
Fix race condition in MigrationTests with xUnit Collection#2154
Conversation
Co-authored-by: myieye <12587509+myieye@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix race condition causing test failures
Fix race condition in MigrationTests with xUnit Collection
Feb 5, 2026
Contributor
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
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.
Four MigrationTests intermittently failed on Windows CI with
IOException: The process cannot access the file 'MigrationTest.sqlite' because it is being used by another process.All test methods in
MigrationTestsshare a singleRegressionTestHelperinstance that recreates the same SQLite file. When xUnit runs these tests in parallel, multiple threads attempt to delete/recreate the same file simultaneously.Changes
[Collection("MigrationTests")]attribute to serialize test execution within this classPattern already used elsewhere in the codebase for shared-resource tests (e.g.,
BulkCreateEntriesTests,ProjectServiceTest).Original prompt
Fix these tests that just failed (https://github.com/sillsdev/languageforge-lexbox/actions/runs/21713352794/job/62622431811):
I'm fairly certain that no recent change broke them. I think it must just be a race condition.
[xUnit.net 00:00:55.44] LcmCrdt.Tests.Data.MigrationTests.VerifyAfterMigrationFromScriptedDb(regressionVersion: v2) [FAIL]
[xUnit.net 00:00:55.44] LcmCrdt.Tests.Data.MigrationTests.VerifyAfterMigrationFromScriptedDb(regressionVersion: v1) [FAIL]
[xUnit.net 00:00:55.44] LcmCrdt.Tests.Data.MigrationTests.GetEntries_WorksAfterMigrationFromScriptedDb(regressionVersion: v1) [FAIL]
[xUnit.net 00:00:55.44] LcmCrdt.Tests.Data.MigrationTests.GetEntries_WorksAfterMigrationFromScriptedDb(regressionVersion: v2) [FAIL]
Error: System.IO.IOException : The process cannot access the file 'D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\bin\Debug\net9.0\MigrationTest.sqlite' because it is being used by another process.
Failed LcmCrdt.Tests.Data.MigrationTests.VerifyAfterMigrationFromScriptedDb(regressionVersion: v2) [5 ms]
Error Message:
System.IO.IOException : The process cannot access the file 'D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\bin\Debug\net9.0\MigrationTest.sqlite' because it is being used by another process.
Stack Trace:
at System.IO.FileSystem.DeleteFile(String fullPath)
at LcmCrdt.Tests.Data.RegressionTestHelper.InitDbFromScripts(RegressionVersion version) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\Data\RegressionTestHelper.cs:line 19
at LcmCrdt.Tests.Data.RegressionTestHelper.InitializeAsync(RegressionVersion version) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\Data\RegressionTestHelper.cs:line 52
at LcmCrdt.Tests.Data.MigrationTests.VerifyAfterMigrationFromScriptedDb(RegressionVersion regressionVersion) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\Data\MigrationTests.cs:line 58
--- End of stack trace from previous location ---
Error: System.IO.IOException : The process cannot access the file 'D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\bin\Debug\net9.0\MigrationTest.sqlite' because it is being used by another process.
Failed LcmCrdt.Tests.Data.MigrationTests.VerifyAfterMigrationFromScriptedDb(regressionVersion: v1) [1 ms]
Error Message:
System.IO.IOException : The process cannot access the file 'D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\bin\Debug\net9.0\MigrationTest.sqlite' because it is being used by another process.
Stack Trace:
at System.IO.FileSystem.DeleteFile(String fullPath)
at LcmCrdt.Tests.Data.RegressionTestHelper.InitDbFromScripts(RegressionVersion version) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\Data\RegressionTestHelper.cs:line 19
at LcmCrdt.Tests.Data.RegressionTestHelper.InitializeAsync(RegressionVersion version) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\Data\RegressionTestHelper.cs:line 52
at LcmCrdt.Tests.Data.MigrationTests.VerifyAfterMigrationFromScriptedDb(RegressionVersion regressionVersion) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\Data\MigrationTests.cs:line 58
--- End of stack trace from previous location ---
Error: System.IO.IOException : The process cannot access the file 'D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\bin\Debug\net9.0\MigrationTest.sqlite' because it is being used by another process.
Failed LcmCrdt.Tests.Data.MigrationTests.GetEntries_WorksAfterMigrationFromScriptedDb(regressionVersion: v1) [2 ms]
Error Message:
System.IO.IOException : The process cannot access the file 'D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\bin\Debug\net9.0\MigrationTest.sqlite' because it is being used by another process.
Stack Trace:
at System.IO.FileSystem.DeleteFile(String fullPath)
at LcmCrdt.Tests.Data.RegressionTestHelper.InitDbFromScripts(RegressionVersion version) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\Data\RegressionTestHelper.cs:line 19
at LcmCrdt.Tests.Data.RegressionTestHelper.InitializeAsync(RegressionVersion version) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\Data\RegressionTestHelper.cs:line 52
at LcmCrdt.Tests.Data.MigrationTests.GetEntries_WorksAfterMigrationFromScriptedDb(RegressionVersion regressionVersion) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\Data\MigrationTests.cs:line 41
--- End of stack trace from previous location ---
Error: System.IO.IOException : The process cannot access the file 'D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt.Tests\bin\Debug\net9.0\MigrationTest.sqlite' because it is being used by another process....
💡 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.