-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add installer tests project #46927
base: main
Are you sure you want to change the base?
Add installer tests project #46927
Conversation
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.
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/Microsoft.DotNet.Installer.Tests.csproj: Language not supported
Comments suppressed due to low confidence (3)
src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/DockerHelper.cs:150
- The outputHelper parameter is marked as non-nullable but is being passed as null in some cases, which could lead to a NullReferenceException.
Func<string, ITestOutputHelper, (Process Process, string StdOut, string StdErr)> executor)
src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/LinuxInstallerTests.cs:101
- Assert.Fail is not a valid method in xUnit. Use Assert.True(false, "Test failed for {image}: {ex}") instead.
Assert.Fail("Test failed for {image}: {ex}");
src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/LinuxInstallerTests.cs:229
- Assert.Fail is not a valid method in xUnit. Use Assert.True(false, "Build failed: {output}") instead.
Assert.Fail("Build failed: {output}");
string? scenarioTestsPackage = Directory.GetFiles(nugetPackagesDir, "Microsoft.DotNet.ScenarioTests.SdkTemplateTests*.nupkg", SearchOption.AllDirectories).FirstOrDefault(); | ||
if (scenarioTestsPackage == null) | ||
{ | ||
Assert.Fail("Scenario tests package not found"); |
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.
Assert.Fail is not a valid method in xUnit. Use Assert.True(false, "Scenario tests package not found") instead.
Assert.Fail("Scenario tests package not found"); | |
Assert.True(false, "Scenario tests package not found"); |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
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 true - Assert.Fail
exists and is new in v2 2.5, see https://xunit.net/docs/comparisons
} | ||
else | ||
{ | ||
Assert.Fail("Test summary not found"); |
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.
Assert.Fail is not a valid method in xUnit. Use Assert.True(false, "Test summary not found") instead.
Assert.Fail("Test summary not found"); | |
Assert.True(false, "Test summary not found"); |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
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 true - Assert.Fail
exists and is new in v2 2.5, see https://xunit.net/docs/comparisons
|
||
private readonly string[] RpmDistroImages = | ||
[ | ||
"mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-40" |
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 don't ship the Fedora packages any more (and I'm actually in the process of removing the runtime-deps package in another PR). Can we instead use Azure Linux 3.0 or OpenSuSE Leap 15.6 here? Those are both RPM distros where we currently ship the packages.
Also, could we use the shipping "runtime-deps" images as our baseline instead of the buildtools-prereqs images? The shipping images better represent our customer scenarios.
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.
Thanks - will fix.
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.
A deps image would likely be this one mcr.microsoft.com/dotnet/runtime-deps:9.0-azurelinux3.0
as we don't have 10.0 images yet. I don't think we want the OS base image like mcr.microsoft.com/azurelinux/base/core:3.0
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 we should have 10.0 images soon (when P1 comes out), but the 9.0 ones should be good for now.
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.
Fixed with 054366b
|
||
private readonly string[] DebDistroImages = | ||
[ | ||
"mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-24.04" |
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 don't ship the Ubuntu packages any more (and I'm actually in the process of removing the Ubuntu support from the runtime-deps package in another PR). Can we instead use Debian stable here? Debian is the only disto that we ship our Deb packages for now.
Also, could we use the shipping "runtime-deps" image as our baseline instead of the buildtools-prereqs image? The shipping images better represent our customer scenarios.
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.
Thanks - yeah makes sense, I'll update this.
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.
Deps image would likely be this one: mcr.microsoft.com/dotnet/runtime-deps:9.0-bookworm-slim
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.
Fixed with 054366b
string depsId = "fedora"; | ||
if (baseImage.Contains("fedora")) | ||
{ | ||
depsId = "fedora"; | ||
} | ||
else if (baseImage.Contains("centos")) | ||
{ | ||
depsId = "centos"; | ||
} | ||
else if (baseImage.Contains("rhel")) | ||
{ | ||
depsId = "rhel"; | ||
} | ||
else if (baseImage.Contains("opensuse")) |
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'm removing these deps packages, so we don't need these checks here.
string depsId = "fedora"; | |
if (baseImage.Contains("fedora")) | |
{ | |
depsId = "fedora"; | |
} | |
else if (baseImage.Contains("centos")) | |
{ | |
depsId = "centos"; | |
} | |
else if (baseImage.Contains("rhel")) | |
{ | |
depsId = "rhel"; | |
} | |
else if (baseImage.Contains("opensuse")) | |
string? depsId = null; | |
if (baseImage.Contains("opensuse" |
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.
Thanks, I'll incorporate this in an offline change, along other proposed changes.
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.
Fixed with 054366b
src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/LinuxInstallerTests.cs
Outdated
Show resolved
Hide resolved
sb.Append("RUN"); | ||
|
||
// TODO: remove --force-all when aspnet package versioning issue have been resolved - https://github.com/dotnet/source-build/issues/4895 | ||
string packageInstallationCommand = distroType == DistroType.Deb ? "dpkg -i --force-all" : "rpm -i"; |
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 construct these tests to point to a fake local package feed and install the packages via apt/tdnf/zypper instead of dpkg/rpm directly?
Doing so would let us better test actual end user scenarios
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 something we could consider in the future. It's not as trivial to now add that to current tests, at least not as easy as adding a local NuGet store. It would be easy to reuse most of the code for those tests.
For now we're automating current manual testing of RPMs an DEBs, in the same way they are executed.
Utilizing correct installation order also verifies the expected package dependencies.
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" /> |
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.
Given this is a new project, consider taking a dependency on STJ.
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.
Will take a look and update. We might not even need a dependency.
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.
Fixed with 08a4230
|
||
private readonly string[] RpmDistroImages = | ||
[ | ||
"mcr.microsoft.com/dotnet/runtime-deps:9.0-azurelinux3.0" |
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.
The version should be shared across RPM and Deb to ensure consistency and reduce maintenance.
I am afraid this is going to get stale quickly.
This should be using the 10-preview images out of nightly.
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.
Makes sense - will update.
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.
Fixed with 08a4230
private const string NetStandard21RpmPackage = @"https://dotnetcli.blob.core.windows.net/dotnet/Runtime/3.1.0/netstandard-targeting-pack-2.1.0-x64.rpm"; | ||
private const string NetStandard21DebPackage = @"https://dotnetcli.blob.core.windows.net/dotnet/Runtime/3.1.0/netstandard-targeting-pack-2.1.0-x64.deb"; | ||
|
||
private enum DistroType |
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.
private enum DistroType | |
private enum PackageType |
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.
Will fix - thanks!
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.
Fixed with 08a4230
[Fact] | ||
public void RunScenarioTestsForAllDistros() | ||
{ | ||
if (Config.TestRpmPackages) |
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.
Ideally these would be separate testcases. One of the primary reasons for this is that if one fails you would still get a read on the other. Also having explicitly testcases helps make it more obvious what is being tested.
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.
Yes, totally agree. Will do that.
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.
Fixed with 64fa1b8
private readonly string _tmpDir; | ||
private readonly string _contextDir; | ||
|
||
private readonly string[] RpmDistroImages = |
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.
Why is this an array? What is the thinking on how this would expand?
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 will likely add more images. Having it as array makes the future modification simpler.
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'm changing this to InlineData
in a Theory
.
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.
Fixed with 64fa1b8
{ | ||
output = e.Message; | ||
} | ||
Assert.Fail($"Build failed: {output}"); |
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.
How do you know this failed during the build vs run?
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 don't - will refactor this.
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.
Fixed with 64fa1b8
sb.AppendLine(""); | ||
sb.AppendLine($"ENTRYPOINT [ \"dotnet\", \"{scenarioTestsBinary}\", \"--dotnet-root\", \"/usr/share/dotnet\" ]"); | ||
|
||
string dockerfile = Path.Combine(_contextDir, Path.GetRandomFileName()); |
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 feel like debugging would be easier if the filename started with Dockerfile
with a random suffix.
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.
Fixed with 08a4230
if (distroType == DistroType.Rpm) | ||
{ | ||
string? depsId = null; | ||
if (baseImage.Contains("opensuse")) |
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.
Why is this not hardcoded to azurelinux since it appears to be the only exercisable codepath?
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 will likely add more at later time. Having support for other distros is cheap.
private string GetContentPackage(string prefix, DistroType distroType) | ||
{ | ||
string matchPattern = DistroType.Deb == distroType ? "*.deb" : "*.rpm"; | ||
string[] rpmFiles = Directory.GetFiles(_contextDir, prefix + matchPattern, SearchOption.AllDirectories) |
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.
These aren't necessarily rpm packages right? They could be deb files as well? If so the variable and exception message should be updated.
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.
Fixed with 08a4230
sb.AppendLine($"COPY packages packages"); | ||
|
||
sb.AppendLine(""); | ||
sb.AppendLine("# Copy RPM packages"); |
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.
These aren't necessarily RPM packages. There are a few RPM references
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.
Fixed with 08a4230
With 64fa1b8, I've split the tests and switched to I was getting the following, when using image as inline data: Splitting into |
} | ||
|
||
[ConditionalTheory(typeof(LinuxInstallerTests), nameof(IncludeRpmTests))] | ||
[InlineData("mcr.microsoft.com/dotnet/nightly/runtime-deps", "10.0-preview-azurelinux3.0")] |
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.
Consider shared constants here to ensure consistency and reduce maintenance across the Rpm and Deb testcases.
[InlineData("mcr.microsoft.com/dotnet/nightly/runtime-deps", "10.0-preview-azurelinux3.0")] | |
[InlineData(RuntimeDepsRepo, $"{RuntimeDepsVersion}-azurelinux3.0")] |
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.
Yeah, that's good - will fix.
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.
Fixed with 1f69d81
Contributes to dotnet/runtime#109848
This PR introduces test project for installer tests. It does not hook it up to build infra. There will be another PR soon that will introduce a job/step in
VMR Validation
stage that will run installer tests for both x64 and arm64 installers.Originally the plan was to run these tests as part of the mainline build job, but we are running that job as cross-build on x64 host, which precludes us from testing arm64 installers.
Some notes about the PR contents:
--force-all
to work around issues in [VMR] aspnetcore packages produced in VMR have incorrect prerelease versioning source-build#4895 - the fix is in PR and this will be removed in the near future. I opted not to include that fix as a patch, but that is a possibilityDockerHelper.cs
was borrowed from dotnet-docker repo: https://github.com/dotnet/dotnet-docker/blob/main/tests/Microsoft.DotNet.Docker.Tests/DockerfileHelper.cs. I have removed many unused methods