-
Notifications
You must be signed in to change notification settings - Fork 1.2k
.NET SDK managed workload installer #16530
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
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
src/Resolvers/Microsoft.DotNet.NativeWrapper/EnvironmentProvider.cs
Outdated
Show resolved
Hide resolved
src/Resolvers/Microsoft.DotNet.NativeWrapper/EnvironmentProvider.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/IWorkloadUnitInstaller.cs
Outdated
Show resolved
Hide resolved
Sorry please give me sometime to review this change carefully. including run the tests and see the test coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not done yet
src/Cli/dotnet/commands/dotnet-workload/install/IWorkloadInstaller.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/IWorkloadInstaller.cs
Outdated
Show resolved
Hide resolved
src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs
Outdated
Show resolved
Hide resolved
src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/WorkloadSuggestionFinderTests.cs
Outdated
Show resolved
Hide resolved
src/Tests/dotnet-workload-install.Tests/MockPackWorkloadInstaller.cs
Outdated
Show resolved
Hide resolved
src/Tests/dotnet-workload-install.Tests/GivenNetSdkManagedWorkloadInstall.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallManager.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallManager.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallManager.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallerFactory.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally finished a round of check.
Awesome work as always!
src/Cli/dotnet/commands/dotnet-workload/install/NetSdkManagedInstaller.cs
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/NetSdkManagedInstaller.cs
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/NetSdkManagedInstaller.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/NetSdkManagedInstaller.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/NetSdkManagedInstaller.cs
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/NetSdkManagedInstaller.cs
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/IWorkloadInstaller.cs
Outdated
Show resolved
Hide resolved
@dsplaisted @wli3 @joeloff I think I'm caught up on most of the feedback, is there anything else I should look at? I'm also consistently getting a test failure that I can't repro anywhere that's caused by a |
Let me check again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Feel free to go ahead and merge and address the feedback separately if that works better for you.
I didn't review the tests yet, I will try to still do that.
src/Cli/dotnet/commands/dotnet-workload/install/IWorkloadInstaller.cs
Outdated
Show resolved
Hide resolved
|
||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.DotNet.Workloads.Workload.Install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are going to want the workload resolver to be able to use the IAL (to check installation records for the current band). So can we factor out most of the workload installation code into a separate library that dotnet
and Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver
would reference (and would be included as source in the Microsoft.DotNet.MSBuildSdkResolver
project)?
src/Cli/dotnet/commands/dotnet-workload/install/NetSdkManagedInstaller.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallManager.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallManager.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallManager.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallManager.cs
Outdated
Show resolved
Hide resolved
@dsplaisted thanks for the feedback! I think I addressed all of it and there were some significant changes (especially in garbage collection) in the last commit, do you want to take a look before I merge? The only piece I've left out of this PR is refactoring this into a separate project per this comment. I've added it to #16483 as a follow up task. |
installer.InstalledPacks.Count.Should().Be(8); | ||
installer.InstalledPacks.Where(pack => pack.Id.Contains("Android")).Count().Should().Be(8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest calling Should().BeEquivalentTo()
and passing the list of 8 packs that should be installed.
try | ||
{ | ||
installManager.InstallWorkloads(mockWorkloadIds, true); | ||
|
||
// Install should have failed | ||
true.Should().BeFalse(); | ||
} | ||
catch (Exception e) | ||
{ | ||
e.Message.Should().Be("Failing workload: xamarin-android-build"); | ||
var expectedPacks = mockWorkloadIds | ||
.SelectMany(workloadId => workloadResolver.GetPacksInWorkload(workloadId.ToString())) | ||
.Select(packId => workloadResolver.TryGetPackInfo(packId)); | ||
installer.RolledBackPacks.ShouldBeEquivalentTo(expectedPacks); | ||
installer.WorkloadInstallRecord.Should().BeEmpty(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a try/catch block and a true.Should().BeFalse()
assertion, try using Assert.Throws
:
try | |
{ | |
installManager.InstallWorkloads(mockWorkloadIds, true); | |
// Install should have failed | |
true.Should().BeFalse(); | |
} | |
catch (Exception e) | |
{ | |
e.Message.Should().Be("Failing workload: xamarin-android-build"); | |
var expectedPacks = mockWorkloadIds | |
.SelectMany(workloadId => workloadResolver.GetPacksInWorkload(workloadId.ToString())) | |
.Select(packId => workloadResolver.TryGetPackInfo(packId)); | |
installer.RolledBackPacks.ShouldBeEquivalentTo(expectedPacks); | |
installer.WorkloadInstallRecord.Should().BeEmpty(); | |
} | |
var exceptionThrown = Assert.Throws<Exception>(() => installManager.InstallWorkloads(mockWorkloadIds, true)); | |
exceptionThrown.Message.Should().Be("Failing workload: xamarin-android-build"); | |
var expectedPacks = mockWorkloadIds | |
.SelectMany(workloadId => workloadResolver.GetPacksInWorkload(workloadId.ToString())) | |
.Select(packId => workloadResolver.TryGetPackInfo(packId)); | |
installer.RolledBackPacks.ShouldBeEquivalentTo(expectedPacks); | |
installer.WorkloadInstallRecord.Should().BeEmpty(); |
Separately, I think the test should hard-code the expected packs instead of calling into the workload resolver to figure out what packs make up the workload.
} | ||
} | ||
|
||
private (string, NetSdkManagedInstaller, INuGetPackageInstaller) GetTestInstaller([CallerMemberName] string identifier = "", bool failingInstaller = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use testName
here instead of identifier
. The identifier
is generally used to disambiguate between multiple instances of the same theory. As is, there's a mismatch on the next line where the identifier
is being passed in as the testName
parameter to CreateTestDirectory
.
} | ||
|
||
[Fact] | ||
public void GivenManagedInstallItCanGetFeatureBands() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think GetFeatureBandsWithInstallationRecords
should be changed so it only returns bands where there are actually workload installation records. So this test should be updated to account for that, and to test both empty and non-empty InstalledWorkloads
directories.
} | ||
|
||
[Fact] | ||
public void GivenManagedInstallItCanGetInstalledWorkloads() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this test I'd suggest writing some different workloads for a different feature band to verify it doesn't pick those up.
} | ||
|
||
[Fact] | ||
public void GivenManagedInstallItDetectInstalledPacks() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar nit
public void GivenManagedInstallItDetectInstalledPacks() | |
public void GivenManagedInstallItDetectsInstalledPacks() |
|
||
installer.InstallWorkloadPack(packInfo, new SdkFeatureBand(version)); | ||
|
||
_reporter.Lines.Should().Contain(string.Format(LocalizableStrings.WorkloadPackAlreadyInstalledMessage, packInfo.Id, packInfo.Version)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of (or in addition to) verifying the message, could this test check that the NuGet package installer was never called to download the package?
installer.InstallWorkloadPack(packInfo, new SdkFeatureBand(version)); | ||
|
||
// Install should have failed | ||
true.Should().BeFalse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch try/catch and true.Should().BeFalse()
for Assert.Throws
.
} | ||
|
||
[Fact] | ||
public void GivenManagedInstallItCanRollBackInstallFailures() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have coverage of what happens when multiple packs are supposed to be installed, and some install successfully but then one fails and they all need to be rolled back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what this test covers: https://github.com/dotnet/sdk/pull/16530/files#diff-c8bc89094b206b506f35f0cb9ac6e55591ae2468130efe0a19dab1810c0f0c1cR52, the first pack installs successfully, the second fails, and they are both rolled back.
} | ||
|
||
[Fact] | ||
public void GivenManagedInstallItDoesNotRemovePacksWithInstallRecords() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some packs to this test that aren't part of the xamarin-android-build
workload and verify that they get garbage collected?
Thanks for the feedback, I'll address it in a follow up PR |
Not included in this PR:
Garbage collectionTesting notes:
https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json
will successfully install (ex macOS, iOS workloads), others won't until we expand the nuget package installer APIdotnet workload install microsoft-ios-sdk-full --skip-manifest-update
, make sure to include skip manifest update flag