Skip to content

Commit 1ec4897

Browse files
committed
add test to pin OCI behavior for multi-rid tarball publish
1 parent a81b916 commit 1ec4897

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

src/Tests/Microsoft.NET.Build.Containers.IntegrationTests/EndToEndTests.cs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ public void EndToEndMultiArch_RemoteRegistry()
10121012
.And.HaveStdOutContaining($"Pushed image '{imageX64}' to registry '{registry}'.")
10131013
.And.HaveStdOutContaining($"Pushed image '{imageArm64}' to registry '{registry}'.")
10141014
.And.HaveStdOutContaining($"Pushed image index '{imageIndex}' to registry '{registry}'.");
1015-
1015+
10161016
// Check that the containers can be run
10171017
// First pull the image from the registry for each platform
10181018
ContainerCli.PullCommand(
@@ -1029,7 +1029,7 @@ public void EndToEndMultiArch_RemoteRegistry()
10291029
imageFromRegistry)
10301030
.Execute()
10311031
.Should().Pass();
1032-
1032+
10331033
// Run the containers
10341034
ContainerCli.RunCommand(
10351035
_testOutput,
@@ -1351,4 +1351,45 @@ static string[] DecideEntrypoint(string rid, string appName, string workingDir)
13511351
return new[] { $"{workingDir}/{binary}" };
13521352
}
13531353
}
1354+
1355+
[DockerAvailableFact(checkContainerdStoreAvailability: true)]
1356+
public void EnforcesOciSchemaForMultiRIDTarballOutput()
1357+
{
1358+
string imageName = NewImageName();
1359+
string tag = "1.0";
1360+
1361+
// Create new console app
1362+
DirectoryInfo newProjectDir = CreateNewProject("webapp");
1363+
1364+
// Run PublishContainer for multi-arch with ContainerGenerateLabels
1365+
var publishResult = new DotnetCommand(
1366+
_testOutput,
1367+
"publish",
1368+
"/t:PublishContainer",
1369+
"/p:RuntimeIdentifiers=\"linux-x64;linux-arm64\"",
1370+
$"/p:ContainerBaseImage={DockerRegistryManager.FullyQualifiedBaseImageAspNet}",
1371+
$"/p:ContainerRepository={imageName}",
1372+
$"/p:ContainerImageTag={tag}",
1373+
"/p:EnableSdkContainerSupport=true",
1374+
"/p:ContainerArchiveOutputPath=archive.tar.gz",
1375+
"-getProperty:GeneratedImageIndex",
1376+
"-getItem:GeneratedContainers",
1377+
"/bl")
1378+
.WithWorkingDirectory(newProjectDir.FullName)
1379+
.Execute();
1380+
1381+
publishResult.Should().Pass();
1382+
var jsonDump = JsonDocument.Parse(publishResult.StdOut);
1383+
var index = JsonDocument.Parse(jsonDump.RootElement.GetProperty("Properties").GetProperty("GeneratedImageIndex").ToString());
1384+
var containers = jsonDump.RootElement.GetProperty("Items").GetProperty("GeneratedContainers").EnumerateArray().ToArray();
1385+
1386+
index.RootElement.GetProperty("mediaType").GetString().Should().Be("application/vnd.oci.image.index.v1+json");
1387+
containers.Should().HaveCount(2);
1388+
foreach (var container in containers)
1389+
{
1390+
container.GetProperty("ManifestMediaType").GetString().Should().Be("application/vnd.oci.image.manifest.v1+json");
1391+
}
1392+
// Cleanup
1393+
newProjectDir.Delete(true);
1394+
}
13541395
}

0 commit comments

Comments
 (0)