Fix flakiness/timeout in gRPC template tests (#19982)
Do not search for port number for cases where we are testing for failure.
This commit is contained in:
parent
2e2a82d445
commit
20f6d65828
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
|
|
@ -24,11 +25,16 @@ namespace Templates.Test
|
|||
public ProjectFactoryFixture ProjectFactory { get; }
|
||||
public ITestOutputHelper Output { get; }
|
||||
|
||||
[ConditionalFact(Skip = "This test run for over an hour")]
|
||||
[ConditionalFact]
|
||||
[SkipOnHelix("Not supported queues", Queues = "Windows.7.Amd64;Windows.7.Amd64.Open;OSX.1014.Amd64;OSX.1014.Amd64.Open")]
|
||||
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/19716")]
|
||||
public async Task GrpcTemplate()
|
||||
{
|
||||
// Setup AssemblyTestLog
|
||||
var assemblyLog = AssemblyTestLog.Create(Assembly.GetExecutingAssembly(), baseDirectory: Project.ArtifactsLogDir);
|
||||
using var testLog = assemblyLog.StartTestLog(Output, nameof(GrpcTemplateTest), out var loggerFactory);
|
||||
var logger = loggerFactory.CreateLogger("TestLogger");
|
||||
|
||||
Project = await ProjectFactory.GetOrCreateProject("grpc", Output);
|
||||
|
||||
var createResult = await Project.RunDotNetNewAsync("grpc");
|
||||
|
|
@ -40,18 +46,24 @@ namespace Templates.Test
|
|||
var buildResult = await Project.RunDotNetBuildAsync();
|
||||
Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", Project, buildResult));
|
||||
|
||||
using (var serverProcess = Project.StartBuiltProjectAsync())
|
||||
var isOsx = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
var isWindowsOld = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.OSVersion.Version < new Version(6, 2);
|
||||
var unsupported = isOsx || isWindowsOld;
|
||||
|
||||
using (var serverProcess = Project.StartBuiltProjectAsync(hasListeningUri: !unsupported, logger: logger))
|
||||
{
|
||||
// These templates are HTTPS + HTTP/2 only which is not supported on Mac due to missing ALPN support.
|
||||
// https://github.com/dotnet/aspnetcore/issues/11061
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
if (isOsx)
|
||||
{
|
||||
serverProcess.Process.WaitForExit(assertSuccess: false);
|
||||
Assert.True(serverProcess.Process.HasExited, "built");
|
||||
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on macOS due to missing ALPN support.",
|
||||
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built service", Project, serverProcess.Process));
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.OSVersion.Version < new Version(6, 2))
|
||||
else if (isWindowsOld)
|
||||
{
|
||||
serverProcess.Process.WaitForExit(assertSuccess: false);
|
||||
Assert.True(serverProcess.Process.HasExited, "built");
|
||||
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support.",
|
||||
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built service", Project, serverProcess.Process));
|
||||
|
|
@ -64,18 +76,20 @@ namespace Templates.Test
|
|||
}
|
||||
}
|
||||
|
||||
using (var aspNetProcess = Project.StartPublishedProjectAsync())
|
||||
using (var aspNetProcess = Project.StartPublishedProjectAsync(hasListeningUri: !unsupported))
|
||||
{
|
||||
// These templates are HTTPS + HTTP/2 only which is not supported on Mac due to missing ALPN support.
|
||||
// https://github.com/dotnet/aspnetcore/issues/11061
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
if (isOsx)
|
||||
{
|
||||
aspNetProcess.Process.WaitForExit(assertSuccess: false);
|
||||
Assert.True(aspNetProcess.Process.HasExited, "published");
|
||||
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on macOS due to missing ALPN support.",
|
||||
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published service", Project, aspNetProcess.Process));
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.OSVersion.Version < new Version(6, 2))
|
||||
else if (isWindowsOld)
|
||||
{
|
||||
aspNetProcess.Process.WaitForExit(assertSuccess: false);
|
||||
Assert.True(aspNetProcess.Process.HasExited, "published");
|
||||
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support.",
|
||||
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published service", Project, aspNetProcess.Process));
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Certificates.Generation;
|
|||
using Microsoft.AspNetCore.Internal;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Edge;
|
||||
|
|
@ -38,7 +39,8 @@ namespace Templates.Test.Helpers
|
|||
string dllPath,
|
||||
IDictionary<string, string> environmentVariables,
|
||||
bool published = true,
|
||||
bool hasListeningUri = true)
|
||||
bool hasListeningUri = true,
|
||||
ILogger logger = null)
|
||||
{
|
||||
_output = output;
|
||||
_httpClient = new HttpClient(new HttpClientHandler()
|
||||
|
|
@ -57,10 +59,18 @@ namespace Templates.Test.Helpers
|
|||
output.WriteLine("Running ASP.NET application...");
|
||||
|
||||
var arguments = published ? $"exec {dllPath}" : "run";
|
||||
|
||||
logger?.LogInformation($"AspNetProcess - process: {DotNetMuxer.MuxerPathOrDefault()} arguments: {arguments}");
|
||||
|
||||
Process = ProcessEx.Run(output, workingDirectory, DotNetMuxer.MuxerPathOrDefault(), arguments, envVars: environmentVariables);
|
||||
|
||||
logger?.LogInformation("AspNetProcess - process started");
|
||||
|
||||
if (hasListeningUri)
|
||||
{
|
||||
logger?.LogInformation("AspNetProcess - Getting listening uri");
|
||||
ListeningUri = GetListeningUri(output) ?? throw new InvalidOperationException("Couldn't find the listening URL.");
|
||||
logger?.LogInformation($"AspNetProcess - Got {ListeningUri.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Internal;
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
|
@ -207,7 +208,7 @@ namespace Templates.Test.Helpers
|
|||
return new AspNetProcess(Output, TemplateClientReleaseDir, projectDll, environment);
|
||||
}
|
||||
|
||||
internal AspNetProcess StartBuiltProjectAsync(bool hasListeningUri = true)
|
||||
internal AspNetProcess StartBuiltProjectAsync(bool hasListeningUri = true, ILogger logger = null)
|
||||
{
|
||||
var environment = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -220,7 +221,7 @@ namespace Templates.Test.Helpers
|
|||
};
|
||||
|
||||
var projectDll = Path.Combine(TemplateBuildDir, $"{ProjectName}.dll");
|
||||
return new AspNetProcess(Output, TemplateOutputDir, projectDll, environment, hasListeningUri: hasListeningUri);
|
||||
return new AspNetProcess(Output, TemplateOutputDir, projectDll, environment, hasListeningUri: hasListeningUri, logger: logger);
|
||||
}
|
||||
|
||||
internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@
|
|||
<ProjectReference Include="../Web.Spa.ProjectTemplates/Microsoft.DotNet.Web.Spa.ProjectTemplates.csproj" ReferenceOutputAssembly="false" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PreserveExistingLogsInOutput Condition="'$(PreserveExistingLogsInOutput)' == '' AND '$(ContinuousIntegrationBuild)' == 'true'">true</PreserveExistingLogsInOutput>
|
||||
<PreserveExistingLogsInOutput Condition="'$(PreserveExistingLogsInOutput)' == ''">false</PreserveExistingLogsInOutput>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
|
||||
<_Parameter1>DotNetEfFullPath</_Parameter1>
|
||||
|
|
@ -69,6 +74,11 @@
|
|||
<_Parameter1>ContinuousIntegrationBuild</_Parameter1>
|
||||
<_Parameter2>true</_Parameter2>
|
||||
</AssemblyAttribute>
|
||||
<AssemblyAttribute Include="Microsoft.AspNetCore.Testing.TestFrameworkFileLoggerAttribute">
|
||||
<_Parameter1>$(PreserveExistingLogsInOutput)</_Parameter1>
|
||||
<_Parameter2>$(TargetFramework)</_Parameter2>
|
||||
<_Parameter3></_Parameter3>
|
||||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PrepareForTest" BeforeTargets="CoreCompile" Condition="$(DesignTimeBuild) != true">
|
||||
|
|
|
|||
Loading…
Reference in New Issue