Introducing a in progress sentinel that gets verified before running the first time experience. If we can get a handle for this sentinel, we proceed with the first time run, otherwise, it means there is a first time experience running already, in which case we continue running dotnet normally, even though the final (real) sentinel is not present yet. This prevents multiple dotnet commands from running the first time experience in parallel and prevents us from running into parallel nuget restores.

This commit is contained in:
Livar Cunha 2016-06-10 15:06:48 -07:00
parent ed7e583ab6
commit 105e5ab051
12 changed files with 240 additions and 25 deletions

View file

@ -43,6 +43,21 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never);
}
[Fact]
public void It_does_not_prime_the_cache_if_first_run_experience_is_already_happening()
{
_nugetCacheSentinelMock.Setup(n => n.InProgressSentinelAlreadyExists()).Returns(true);
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
_nugetCachePrimerMock.Object,
_nugetCacheSentinelMock.Object,
_environmentProviderMock.Object);
dotnetFirstTimeUseConfigurer.Configure();
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never);
}
[Fact]
public void It_does_not_prime_the_cache_if_the_sentinel_exists_but_the_user_has_set_the_DOTNET_SKIP_FIRST_TIME_EXPERIENCE_environemnt_variable()
{
@ -74,6 +89,6 @@ namespace Microsoft.DotNet.Configurer.UnitTests
dotnetFirstTimeUseConfigurer.Configure();
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Once);
}
}
}
}