Change temp folder name used in installer tests (#45523)
authorAndy Gocke <angocke@microsoft.com>
Tue, 8 Dec 2020 03:21:23 +0000 (19:21 -0800)
committerGitHub <noreply@github.com>
Tue, 8 Dec 2020 03:21:23 +0000 (19:21 -0800)
commitcbc10faf082a9626d13212a369f6e1002f46f743
tree6e26a2c46ca4b8ff5b53ec5c13206c4ba8e97a19
parent69e114c1abf91241a0eeecf1ecceab4711b8aa62
Change temp folder name used in installer tests (#45523)

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 avoid locking & contention by randomly generating folder names and
using a (hopefully atomically created) lock file to indicate ownership of a particular name.

Fixes #43316
src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/NetCoreApp3CompatModeTests.cs
src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/SingleFileApiTests.cs
src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/SingleFileSharedState.cs [new file with mode: 0644]
src/installer/tests/TestUtils/TestArtifact.cs