-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
73 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
29 changes: 29 additions & 0 deletions
29
...staller/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/SingleFileSharedState.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.IO; | ||
using Microsoft.DotNet.CoreSetup.Test; | ||
using Xunit; | ||
using static AppHost.Bundle.Tests.BundleTestBase; | ||
|
||
namespace AppHost.Bundle.Tests | ||
{ | ||
public class SingleFileSharedState : SharedTestStateBase, IDisposable | ||
{ | ||
public TestProjectFixture TestFixture { get; set; } | ||
|
||
public SingleFileSharedState() | ||
{ | ||
// We include mockcoreclr in our project to test native binaries extraction. | ||
string mockCoreClrPath = Path.Combine(RepoDirectories.Artifacts, "corehost_test", | ||
RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("mockcoreclr")); | ||
TestFixture = PreparePublishedSelfContainedTestProject("SingleFileApiTests", $"/p:AddFile={mockCoreClrPath}"); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
TestFixture.Dispose(); | ||
} | ||
} | ||
} |
This file contains 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