-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Share SingleFileTest publishing between test classes #45523
Conversation
Tests in the AppHost.Bundle.Tests assembly seem to randomly fail due to a race condition with the file system. They try to create separate '0','1','2'... subdirectories to isolate the published files for each test, but I think what's happening is that files may be marked for deletion, but then not deleted until a later write. For instance, files in '2' may be marked for deletion and some may fail a File.Exists check, which leads to '2' being recreated, at which point deletion may occur, which will cause the current test to fail due to a concurrent write operation. This change tries to simplify the system by sharing the test state across all the classes in the assembly, instead of per-class, and then cleaning up only when all of them are finished executing. Fixes dotnet#43316
Tagging subscribers to this area: @agocke, @vitek-karas Issue DetailsTests in the AppHost.Bundle.Tests assembly seem to randomly fail due to a race condition This change tries to simplify the system by sharing the test state across all the classes Fixes #43316
|
I think that if your theory is correct then we should actually change the way TestFixtures are created in the test infra - instead of trying to reuse folders ( |
I can do that too -- GUID works but is probably overkill tbh. There's a GetTempFileName that's probably sufficient for lower levels of contention. I'll add that in a second commit |
+1 for @vitek-karas's suggestion for changing how we create the new path for test fixtures. If we do that, we shouldn't need to have the collection grouping, right? (So we can keep running the tests in parallel to avoid increasing test run times?) That approach should also handle other cases like the StaticHost tests (failed in this PR: https://dev.azure.com/dnceng/public/_build/results?buildId=906837&view=ms.vss-test-web.build-test-results-tab&runId=28928456&resultId=100001&paneView=debug) - assuming your theory applies to that as well |
@JeremyKuhne just curious, does this theory match your knowledge of how filesystems can work on Linux? I remember something similar on Windows. |
Historically Windows marked files for deletion and would remove them once all file handles were closed. That was recently changed so that the file is immediately moved to a new, "hidden" entry to open up the named location, specifically to better support Linux scenarios.
Best practice for tests is to always use a randomly generated sub-folder name. |
Tests in the AppHost.Bundle.Tests assembly seem to randomly fail due to a race condition
with the file system. They try to create separate '0','1','2'... subdirectories to isolate
the published files for each test, but I think what's happening is that files may be
marked for deletion, but then not deleted until a later write. For instance, files in
'2' may be marked for deletion and some may fail a File.Exists check, which leads to
'2' being recreated, at which point deletion may occur, which will cause the current test
to fail due to a concurrent write operation.
This change tries to simplify the system by sharing the test state across all the classes
in the assembly, instead of per-class, and then cleaning up only when all of them are
finished executing.
Fixes #43316