Skip to content

Fix race condition in MigrationTests with xUnit Collection#2154

Merged
myieye merged 2 commits intodevelopfrom
copilot/fix-test-failures-due-to-race-condition
Feb 5, 2026
Merged

Fix race condition in MigrationTests with xUnit Collection#2154
myieye merged 2 commits intodevelopfrom
copilot/fix-test-failures-due-to-race-condition

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

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 MigrationTests share a single RegressionTestHelper instance that recreates the same SQLite file. When xUnit runs these tests in parallel, multiple threads attempt to delete/recreate the same file simultaneously.

Changes

  • Add [Collection("MigrationTests")] attribute to serialize test execution within this class
[Collection("MigrationTests")]
public class MigrationTests : IAsyncLifetime
{
    private readonly RegressionTestHelper _helper = new("MigrationTest");
    // ...
}

Pattern 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.

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
Copilot AI requested a review from myieye February 5, 2026 13:52
@github-actions github-actions bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Feb 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

UI unit Tests

  1 files  ±0   50 suites  ±0   23s ⏱️ -1s
138 tests ±0  138 ✅ ±0  0 💤 ±0  0 ❌ ±0 
203 runs  ±0  203 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit c06a08d. ± Comparison against base commit f37f947.

@argos-ci
Copy link

argos-ci bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Feb 5, 2026, 2:12 PM

@myieye myieye marked this pull request as ready for review February 5, 2026 14:53
@myieye myieye merged commit 238e55d into develop Feb 5, 2026
15 checks passed
@myieye myieye deleted the copilot/fix-test-failures-due-to-race-condition branch February 5, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants