Skip to content

Alway skip failing UseSpa tests on Alpine #29552

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

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void UseSpa_ThrowsInvalidOperationException_IfRootpathNotSet()
}

[ConditionalFact]
[SkipOnHelix("Flaky on Alpine", Queues = "(Alpine.312.Amd64.Open)[email protected].com/dotnet-buildtools/prereqs:alpine-3.12-helix-20200908125345-56c6673")]
[SkipOnAlpine("https://github.com/dotnet/aspnetcore/issues/29549")]
public async Task UseSpa_KillsRds_WhenAppIsStopped()
{
var serviceProvider = GetServiceProvider(s => s.RootPath = "/");
Expand All @@ -59,7 +59,7 @@ public async Task UseSpa_KillsRds_WhenAppIsStopped()
}

[ConditionalFact]
[SkipOnHelix("Flaky on Alpine", Queues = "(Alpine.312.Amd64.Open)[email protected].com/dotnet-buildtools/prereqs:alpine-3.12-helix-20200908125345-56c6673")]
[SkipOnAlpine("https://github.com/dotnet/aspnetcore/issues/29549")]
public async Task UseSpa_KillsAngularCli_WhenAppIsStopped()
{
var serviceProvider = GetServiceProvider(s => s.RootPath = "/");
Expand Down
23 changes: 0 additions & 23 deletions src/ProjectTemplates/test/GrpcTemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,5 @@ public async Task GrpcTemplate()
}
}
}

/// <summary>
/// Skip test if running on Alpine Linux (which uses musl instead of glibc)
/// </summary>
private class SkipOnAlpineAttribute : Attribute, ITestCondition
{
public SkipOnAlpineAttribute(string issueUrl = "")
{
IssueUrl = issueUrl;
}

public string IssueUrl { get; }

public bool IsMet { get; } = !IsAlpine;

public string SkipReason => "Test cannot run on Alpine Linux.";

// This logic is borrowed from https://github.com/dotnet/runtime/blob/6a5a78bec9a6e14b4aa52cd5ac558f6cf5c6a211/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs
private static bool IsAlpine { get; } =
RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/etc/os-release") &&
File.ReadAllLines("/etc/os-release").Any(line =>
line.StartsWith("ID=", StringComparison.Ordinal) && line.Substring(3).Trim('"', '\'') == "alpine");
}
}
}
33 changes: 33 additions & 0 deletions src/Testing/src/xunit/SkipOnAlpineAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;

namespace Microsoft.AspNetCore.Testing
{
/// <summary>
/// Skip test if running on Alpine Linux (which uses musl instead of glibc)
/// </summary>
public class SkipOnAlpineAttribute : Attribute, ITestCondition
{
public SkipOnAlpineAttribute(string issueUrl = "")
{
IssueUrl = issueUrl;
}

public string IssueUrl { get; }

public bool IsMet { get; } = !IsAlpine;

public string SkipReason => "Test cannot run on Alpine Linux.";

// This logic is borrowed from https://github.com/dotnet/runtime/blob/6a5a78bec9a6e14b4aa52cd5ac558f6cf5c6a211/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs
private static bool IsAlpine { get; } =
RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/etc/os-release") &&
File.ReadAllLines("/etc/os-release").Any(line =>
line.StartsWith("ID=", StringComparison.Ordinal) && line.Substring(3).Trim('"', '\'') == "alpine");
}
}