Skip to content

Commit e46389b

Browse files
Surayya Huseyn ZadaSurayya Huseyn Zada
authored andcommitted
implement skipping tests if containerd image store is not enabled
1 parent 929c2b3 commit e46389b

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

src/Containers/Microsoft.NET.Build.Containers/LocalDaemons/DockerCli.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ private static bool IsPodmanAlias()
625625
}
626626
}
627627

628-
private static bool IsContainerdStoreEnabledForDocker()
628+
internal static bool IsContainerdStoreEnabledForDocker()
629629
{
630630
try
631631
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ static class ContainerCli
99

1010
public static bool IsAvailable => _isAvailable.Value;
1111

12+
public static bool IsContainerdStoreEnabledForDocker => DockerCli.IsContainerdStoreEnabledForDocker();
13+
1214
public static RunExeCommand PullCommand(ITestOutputHelper log, params string[] args)
1315
=> CreateCommand(log, "pull", args);
1416

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ namespace Microsoft.NET.Build.Containers.IntegrationTests;
55

66
public class DockerIsAvailableAndSupportsArchFactAttribute : FactAttribute
77
{
8-
public DockerIsAvailableAndSupportsArchFactAttribute(string arch)
8+
public DockerIsAvailableAndSupportsArchFactAttribute(string arch, bool checkContainerdStoreAvailability = false)
99
{
1010
if (!DockerSupportsArchHelper.DaemonIsAvailable)
1111
{
1212
base.Skip = "Skipping test because Docker is not available on this host.";
1313
}
14+
else if (checkContainerdStoreAvailability && !DockerSupportsArchHelper.IsContainerdStoreEnabledForDocker)
15+
{
16+
base.Skip = "Skipping test because Docker daemon is not using containerd as the storage driver.";
17+
}
1418
else if (!DockerSupportsArchHelper.DaemonSupportsArch(arch))
1519
{
1620
base.Skip = $"Skipping test because Docker daemon does not support {arch}.";

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ internal static class DockerSupportsArchHelper
3636
{
3737
internal static bool DaemonIsAvailable => ContainerCli.IsAvailable;
3838

39+
internal static bool IsContainerdStoreEnabledForDocker => ContainerCli.IsContainerdStoreEnabledForDocker;
40+
3941
internal static bool DaemonSupportsArch(string arch)
4042
{
4143
// an optimization - this doesn't change over time so we can compute it once

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ public void EndToEnd_SingleArch_NoRid()
722722
processResultX64.Should().Pass().And.HaveStdOut("Hello, World!");
723723
}
724724

725-
[DockerIsAvailableAndSupportsArchFact("linux/arm64")]
725+
[DockerIsAvailableAndSupportsArchFact("linux/arm64", checkContainerdStoreAvailability: true)]
726726
public void EndToEndMultiArch_LocalRegistry()
727727
{
728728
string imageName = NewImageName();
@@ -905,7 +905,7 @@ private DirectoryInfo CreateNewProject(string template, [CallerMemberName] strin
905905
private string GetPublishArtifactsPath(string projectDir, string rid, string configuration = "Debug")
906906
=> Path.Combine(projectDir, "bin", configuration, ToolsetInfo.CurrentTargetFramework, rid, "publish");
907907

908-
[DockerIsAvailableAndSupportsArchFact("linux/arm64")]
908+
[DockerIsAvailableAndSupportsArchFact("linux/arm64", checkContainerdStoreAvailability: true)]
909909
public void EndToEndMultiArch_ArchivePublishing()
910910
{
911911
string imageName = NewImageName();
@@ -974,7 +974,7 @@ public void EndToEndMultiArch_ArchivePublishing()
974974
newProjectDir.Delete(true);
975975
}
976976

977-
[DockerIsAvailableAndSupportsArchFact("linux/arm64")]
977+
[DockerIsAvailableAndSupportsArchFact("linux/arm64", checkContainerdStoreAvailability: true)]
978978
public void EndToEndMultiArch_RemoteRegistry()
979979
{
980980
string imageName = NewImageName();
@@ -1053,7 +1053,7 @@ public void EndToEndMultiArch_RemoteRegistry()
10531053
newProjectDir.Delete(true);
10541054
}
10551055

1056-
[DockerAvailableFact]
1056+
[DockerAvailableFact(checkContainerdStoreAvailability: true)]
10571057
public void EndToEndMultiArch_ContainerRuntimeIdentifiersOverridesRuntimeIdentifiers()
10581058
{
10591059
// Create a new console project
@@ -1088,7 +1088,7 @@ public void EndToEndMultiArch_ContainerRuntimeIdentifiersOverridesRuntimeIdentif
10881088
newProjectDir.Delete(true);
10891089
}
10901090

1091-
[DockerIsAvailableAndSupportsArchFact("linux/arm64")]
1091+
[DockerIsAvailableAndSupportsArchFact("linux/arm64", checkContainerdStoreAvailability: true)]
10921092
public void EndToEndMultiArch_EnvVariables()
10931093
{
10941094
string imageName = NewImageName();
@@ -1158,7 +1158,7 @@ public void EndToEndMultiArch_EnvVariables()
11581158
newProjectDir.Delete(true);
11591159
}
11601160

1161-
[DockerIsAvailableAndSupportsArchFact("linux/arm64")]
1161+
[DockerIsAvailableAndSupportsArchFact("linux/arm64", checkContainerdStoreAvailability: true)]
11621162
public void EndToEndMultiArch_Ports()
11631163
{
11641164
string imageName = NewImageName();
@@ -1256,7 +1256,7 @@ private void CheckPorts(string containerName, int[] correctPorts, int[] incorrec
12561256
}
12571257
}
12581258

1259-
[DockerAvailableFact]
1259+
[DockerAvailableFact(checkContainerdStoreAvailability: true)]
12601260
public void EndToEndMultiArch_Labels()
12611261
{
12621262
string imageName = NewImageName();

src/Tests/Microsoft.NET.Build.Containers.UnitTests/DockerAvailableUtils.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ public class DockerAvailableFactAttribute : FactAttribute
2525
{
2626
public static string LocalRegistry => DockerCliStatus.LocalRegistry;
2727

28-
public DockerAvailableFactAttribute(bool skipPodman = false)
28+
public DockerAvailableFactAttribute(bool skipPodman = false, bool checkContainerdStoreAvailability = false)
2929
{
3030
if (!DockerCliStatus.IsAvailable)
3131
{
3232
base.Skip = "Skipping test because Docker is not available on this host.";
3333
}
34-
35-
if (skipPodman && DockerCliStatus.Command == DockerCli.PodmanCommand)
34+
else if (checkContainerdStoreAvailability && !DockerCli.IsContainerdStoreEnabledForDocker())
3635
{
37-
base.Skip = $"Skipping test with {DockerCliStatus.Command} cli.";
36+
base.Skip = "Skipping test because Docker daemon is not using containerd as the storage driver.";
3837
}
38+
else if (skipPodman && DockerCliStatus.Command == DockerCli.PodmanCommand)
39+
{
40+
base.Skip = $"Skipping test with {DockerCliStatus.Command} cli.";
41+
}
3942
}
4043
}
4144

0 commit comments

Comments
 (0)